derivkit.calculus.calculus_core module#
Core utilities for calculus-based derivative computations.
This module provides shared helper functions for building derivative objects (gradients, Jacobians, Hessians, higher-order tensors) of scalar- and tensor-valued functions using DerivativeKit.
- derivkit.calculus.calculus_core.component_scalar_eval(theta_vec: ndarray[tuple[Any, ...], dtype[float64]], *, function: Callable[[ArrayLike], float | ndarray], idx: int) float#
Evaluates a single element of the model output
function(theta_vec)as a scalar.This helper is used internally when building derivatives of models that return multiple outputs (e.g. vectors or arrays). Derivative routines operate on scalar-valued functions, so one output component is selected and treated as a scalar function of the parameters.
- Parameters:
theta_vec – 1D parameter vector.
function – Original function.
idx – Index of the output component to differentiate, where the output is first flattened with NumPy C-order (i.e.
np.ravel(y, order="C")).
- Returns:
Scalar value of the specified output component.
- Raises:
IndexError – If
idxis out of bounds for the model output.