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

◆ finite_diff_hessian_auto()

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

Template Parameters
FType of function
Parameters
[in]fFunction
[in]xArgument to function
[out]fxFunction applied to argument
[out]grad_fxGradient of function at argument
[out]hess_fxHessian of function at argument

Definition at line 43 of file finite_diff_hessian_auto.hpp.