1#ifndef STAN_MATH_PRIM_FUNCTOR_FINITE_DIFF_GRADIENT_AUTO_HPP
2#define STAN_MATH_PRIM_FUNCTOR_FINITE_DIFF_GRADIENT_AUTO_HPP
49template <
typename F,
typename VectorT,
50 typename ScalarT = return_type_t<VectorT>>
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);
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void finite_diff_gradient_auto(const F &f, const VectorT &x, ScalarT &fx, VectorT &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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...