Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ finite_diff_hessian_times_vector_auto()

template<typename F >
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.

Template Parameters
FType of function
Parameters
[in]fFunction
[in]xArgument to function
[in]vVector to multiply Hessian with
[out]fxFunction applied to argument
[out]hvpProduct of Hessian and vector at argument

Definition at line 44 of file finite_diff_hessian_times_vector_auto.hpp.