Automatic Differentiation
 
Loading...
Searching...
No Matches
grad.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CORE_GRAD_HPP
2#define STAN_MATH_REV_CORE_GRAD_HPP
3
9#include <vector>
10
11namespace stan {
12namespace math {
13
26static inline void grad() {
27 size_t end = ChainableStack::instance_->var_stack_.size();
28 size_t beginning = empty_nested() ? 0 : end - nested_size();
29 for (size_t i = end; i-- > beginning;) {
31 }
32}
33
50template <typename Vari>
51static void grad(Vari* vi) {
52 vi->init_dependent();
53 grad();
54}
55
56} // namespace math
57} // namespace stan
58
59#endif
static bool empty_nested()
Return true if there is no nested autodiff being executed.
static size_t nested_size()
static void grad()
Compute the gradient for all variables starting from the end of the AD tape.
Definition grad.hpp:26
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static thread_local AutodiffStackStorage * instance_