Stan Math Library
5.0.0
Automatic Differentiation
|
void stan::math::gradient | ( | const F & | f, |
const Eigen::Matrix< T, Eigen::Dynamic, 1 > & | x, | ||
T & | fx, | ||
Eigen::Matrix< T, Eigen::Dynamic, 1 > & | grad_fx | ||
) |
Calculate the value and the gradient of the specified function at the specified argument.
The functor must implement
fvar<T> operator()(const Eigen::Matrix<T, Eigen::Dynamic, 1>&)
using only operations that are defined for fvar
. 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.
Time and memory usage is on the order of the size of the fully unfolded expression for the function applied to the argument, independently of dimension.
T | type of the elements in the vector |
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 |
Definition at line 40 of file gradient.hpp.