Stan Math Library
5.0.0
Automatic Differentiation
|
void stan::math::internal::finite_diff_hessian_times_vector_auto | ( | const F & | f, |
const Eigen::VectorXd & | x, | ||
const Eigen::VectorXd & | v, | ||
double & | fx, | ||
Eigen::VectorXd & | hvp | ||
) |
Calculate the value and the product of the Hessian and the specified vector of the specified function at the specified argument using central finite difference of gradients, automatically setting the stepsize between the function evaluations along a dimension.
The functor must implement
double operator()(const Eigen::Matrix<stan::math::var, -1, 1>&)
For details of the algorithm, see https://justindomke.wordpress.com/2009/01/17/hessian-vector-products/
Step size is set automatically using sqrt(epsilon) * (1 + ||x||) / ||v||
, as suggested in https://doi.org/10.1016/j.cam.2008.12.024
2 gradient calls are needed for the algorithm.
F | Type of function |
[in] | f | Function |
[in] | x | Argument to function |
[in] | v | Vector to multiply Hessian with |
[out] | fx | Function applied to argument |
[out] | hvp | Product of Hessian and vector at argument |
Definition at line 44 of file finite_diff_hessian_times_vector_auto.hpp.