1 #ifndef STAN_MATH_PRIM_MAT_FUNCTOR_FINITE_DIFF_HESSIAN_HELPER_HPP 2 #define STAN_MATH_PRIM_MAT_FUNCTOR_FINITE_DIFF_HESSIAN_HELPER_HPP 31 double epsilon = 1
e-03) {
32 Eigen::VectorXd x_temp(x);
34 x_temp(i) = x(i) + 2 * epsilon;
35 double grad = -f(x_temp);
37 x_temp(i) = x(i) + -2 * epsilon;
40 x_temp(i) = x(i) + epsilon;
41 grad += 8 * f(x_temp);
43 x_temp(i) = x(i) + -epsilon;
44 grad -= 8 * f(x_temp);
static void grad(vari *vi)
Compute the gradient for all variables starting from the specified root variable implementation.
double finite_diff_hessian_helper(const F &f, const Eigen::VectorXd &x, int i, double epsilon=1e-03)
Return the subcalculation required by finite_diff_hessian and finite_diff_hessian_auto.
double e()
Return the base of the natural logarithm.