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

◆ hessian() [1/2]

template<typename T , typename F >
void stan::math::hessian ( const F &  f,
const Eigen::Matrix< T, Eigen::Dynamic, 1 > &  x,
T &  fx,
Eigen::Matrix< T, Eigen::Dynamic, 1 > &  grad,
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  H 
)

Calculate the value, the gradient, and the Hessian, of the specified function at the specified argument in time O(N^3) time and O(N^2) space.

The advantage over the mixed definition, which is faster for Hessians, is that this version is itself differentiable.

The functor must implement

fvar<fvar<T> > operator()(const Eigen::Matrix<fvar<fvar<T> >, Eigen::Dynamic, 1>&)

using only operations that are defined for the argument type.

This latter constraint usually requires the functions to be defined in terms of the libraries defined in Stan or in terms of functions with appropriately general namespace imports that eventually depend on functions defined in Stan.

Template Parameters
Ttype of elements in the vector and matrix
Ftype of function
Parameters
[in]fFunction
[in]xArgument to function
[out]fxFunction applied to argument
[out]gradgradient of function at argument
[out]HHessian of function at argument

Definition at line 41 of file hessian.hpp.