1 #ifndef STAN_MATH_PRIM_MAT_FUNCTOR_FINITE_DIFF_GRADIENT_AUTO_HPP 2 #define STAN_MATH_PRIM_MAT_FUNCTOR_FINITE_DIFF_GRADIENT_AUTO_HPP 52 Eigen::VectorXd& grad_fx) {
53 Eigen::VectorXd x_temp(x);
55 grad_fx.resize(x.size());
56 for (
int i = 0; i < x.size(); ++i) {
61 x_temp(i) = x(i) + 3 * h;
64 x_temp(i) = x(i) + 2 * h;
65 delta_f -= 9 * f(x_temp);
68 delta_f += 45 * f(x_temp);
70 x_temp(i) = x(i) + -3 * h;
73 x_temp(i) = x(i) + -2 * h;
74 delta_f += 9 * f(x_temp);
77 delta_f -= 45 * f(x_temp);
void finite_diff_gradient_auto(const F &f, const Eigen::VectorXd &x, double &fx, Eigen::VectorXd &grad_fx)
Calculate the value and the gradient of the specified function at the specified argument using finite...
double finite_diff_stepsize(double u)
Return the stepsize for finite difference evaluations at the specified scalar.