1#ifndef STAN_MATH_REV_FUNCTOR_JACOBIAN_HPP
2#define STAN_MATH_REV_FUNCTOR_JACOBIAN_HPP
15 const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
16 Eigen::Matrix<double, Eigen::Dynamic, 1>& fx,
17 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& J) {
23 Matrix<var, Dynamic, 1> x_var(x);
24 Matrix<var, Dynamic, 1> fx_var = f(x_var);
25 fx.resize(fx_var.size());
26 J.resize(x.size(), fx_var.size());
29 J.col(0) = x_var.adj();
30 for (
int i = 1; i < fx_var.size(); ++i) {
33 J.col(i) = x_var.adj();
void set_zero_all_adjoints()
Reset all adjoint values in this nested stack to zero.
A class following the RAII idiom to start and recover nested autodiff scopes.
void jacobian(const F &f, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, Eigen::Matrix< T, Eigen::Dynamic, 1 > &fx, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &J)
static void grad()
Compute the gradient for all variables starting from the end of the AD tape.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...