mappy_ds.SystemFunction#
- class mappy_ds.SystemFunction(fun, dom_dim, cod_dim, direction=0, name=None)#
A vector-valued function \(f(y, p)\) with symbolic derivatives.
- Parameters:
- funcallable
Python function
fun(y, params).yis a one-dimensional array of lengthdom_dimandparamsa mapping of parameter values that must be read asparams[key]. The return value must be convertible to a vector of lengthcod_dim.- dom_dimint
Dimension of the domain (length of
y).- cod_dimint
Dimension of the codomain (length of the returned vector).
- directionint, optional
Only meaningful for border functions: direction of the zero crossing that terminates a continuous mode (
1,-1or0for both), forwarded toscipy.integrate.solve_ivp()events.- namestr, optional
Name of the function, by default
fun.__name__. Border names identify borders in transition rules.
- Attributes:
param_keystuple of strNames of the parameters the function reads (discovered by tracing).
Notes
The function is traced with SymPy on first use. The Jacobian follows the convention
jac[i, j] = ∂f_i/∂y_j, the Hessianhes[i, j, k] = ∂²f_i/(∂y_j ∂y_k), the parameter Jacobianjac_p[i, m] = ∂f_i/∂p_mand the mixed Hessianhes_p[i, j, m] = ∂²f_i/(∂y_j ∂p_m), withmindexingparam_keys.Properties
Symbolic expression of the function as a
cod_dim × 1matrix.Symbolic Hessian (
cod_dim × dom_dim × dom_dim).Symbolic Jacobian (
cod_dim × dom_dim).Symbolic mixed derivative
∂²f/∂y∂p(cod_dim × dom_dim × k).Names of the parameters the function reads (discovered by tracing).
Symbolic derivative with respect to the parameters (
cod_dim × k).Methods
__call__(y[, params])Evaluate the function numerically.
eval(y, p)Evaluate with a pre-extracted parameter array (hot path).
eval_hessian(y, p)Hessian with a pre-extracted parameter array (hot path).
eval_jacobian(y, p)Jacobian with a pre-extracted parameter array (hot path).
eval_mixed_hessian(y, p)Mixed Hessian with a pre-extracted parameter array (hot path).
eval_mixed_hessian_for(y, p, keys)Mixed Hessian with the last axis laid out along
keys.eval_parameter_jacobian(y, p)Parameter Jacobian with a pre-extracted parameter array (hot path).
eval_parameter_jacobian_for(y, p, keys)Parameter Jacobian with columns laid out along
keys.hessian(y[, params])Evaluate the Hessian tensor at
y.jacobian(y[, params])Evaluate the Jacobian matrix at
y.mixed_hessian(y[, params])Evaluate
∂²f/∂y∂paty; last axis in the order ofparam_keys.parameter_jacobian(y[, params])Evaluate
∂f/∂paty, columns in the order ofparam_keys.params_array(params)Extract
param_keysfromparamsas a float array.