Stan Math Library
4.9.0
Automatic Differentiation
|
void stan::math::internal::finite_diff_hessian_auto | ( | const F & | f, |
const Eigen::VectorXd & | x, | ||
double & | fx, | ||
Eigen::VectorXd & | grad_fx, | ||
Eigen::MatrixXd & | hess_fx | ||
) |
Calculate the value and the Hessian of the specified function at the specified argument using first-order finite difference of gradients, automatically setting the stepsize between the function evaluations along a dimension.
The functor must implement
double operator()(const Eigen::VectorXd&)
For details of the algorithm, see "Central difference approximation", under "Second-order derivatives based on gradient", in: https://v8doc.sas.com/sashtml/ormp/chap5/sect28.htm
Step size for dimension i
is set automatically using stan::math::finite_diff_stepsize(x(i))
.
2n gradient calls are needed for the algorithm.
F | Type of function |
[in] | f | Function |
[in] | x | Argument to function |
[out] | fx | Function applied to argument |
[out] | grad_fx | Gradient of function at argument |
[out] | hess_fx | Hessian of function at argument |
Definition at line 43 of file finite_diff_hessian_auto.hpp.