pysolver_view.differentiation.hessians module#
Existing Hessian utilities; optional JAX loads on demand.
- pysolver_view.differentiation.hessians.approx_jacobian_hessians(f, x, abs_step=1e-05, lower_triangular=True)[source]#
Calculate the Hessian matrices for each component of a vector-valued function using finite differences.
- Parameters:
- fcallable
The function for which to find the Hessian matrices. It must take a single argument which is a numpy array and can return a scalar or a numpy array.
- xnumpy array
The point at which the Hessian matrices are calculated.
- abs_stepfloat, optional
The step size for the finite differences, default is 1e-5.
- lower_triangularbool, optional
If True, the Hessians are returned in a lower triangular form suitable for Pygmo, default is True.
- Returns:
- Hessiansnumpy array
A tensor where each slice along the first dimension corresponds to the Hessian matrix of each component of the function f at x. If f returns a scalar, the first dimension size is 1. If lower_triangular is True, the Hessians are returned in a lower triangular form.
- pysolver_view.differentiation.hessians.compute_hessians_jax(fitness_function, x, lower_triangular=True)[source]#
Compute the Hessians of a vector-valued fitness function.
- Parameters:
- fitness_functioncallable
The vector-valued function for which to compute the Hessians.
- xarray-like
The point at which to compute the Hessians.
- lower_triangularbool, optional
If True, return the Hessians in lower triangular format. Default is True.
- Returns:
- Hessiansndarray
A tensor where each slice along the first dimension corresponds to the Hessian of a component of the fitness function. If lower_triangular is True, the Hessians are returned in a flattened lower triangular format.