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

◆ finite_diff_grad_hessian_auto()

template<typename F >
void stan::math::finite_diff_grad_hessian_auto ( const F &  f,
const Eigen::VectorXd &  x,
double &  fx,
Eigen::MatrixXd &  hess,
std::vector< Eigen::MatrixXd > &  grad_hess_fx 
)

Calculate the value, Hessian, and the gradient of the Hessian of the specified function at the specified argument using second-order autodiff and first-order finite difference.

The functor must implement

double operator()(const Eigen::VectorXd&) const;

Reference for finite difference to compute gradient:


De Levie: An improved numerical approximation for the first derivative, page 3

Step size for dimension i is set automatically using stan::math::finite_diff_stepsize(H(i, j)); the nested finite differences are over entries in the Hessian.

Evaluating this function involves 6 calls to the Hessian autodiff function for each entry in the Hessian.

Template Parameters
FType of function
Parameters
[in]fFunction
[in]xArgument to function
[out]fxFunction applied to argument
[out]hessHessian matrix
[out]grad_hess_fxgradient of Hessian of function at argument

Definition at line 44 of file finite_diff_grad_hessian_auto.hpp.