Automatic Differentiation
 
Loading...
Searching...
No Matches
stored_gradient_vari.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CORE_STORED_GRADIENT_VARI_HPP
2#define STAN_MATH_REV_CORE_STORED_GRADIENT_VARI_HPP
3
5
6namespace stan {
7namespace math {
8
17class stored_gradient_vari : public vari {
18 protected:
19 size_t size_;
21 double* partials_;
22
23 public:
34 stored_gradient_vari(double value, size_t size, vari** dtrs, double* partials)
35 : vari(value), size_(size), dtrs_(dtrs), partials_(partials) {}
36
41 void chain() {
42 for (size_t i = 0; i < size_; ++i) {
43 dtrs_[i]->adj_ += adj_ * partials_[i];
44 }
45 }
46};
47
48} // namespace math
49} // namespace stan
50
51#endif
void chain()
Propagate derivatives through this vari with partial derivatives given for the daughter vari by the s...
stored_gradient_vari(double value, size_t size, vari **dtrs, double *partials)
Construct a stored gradient vari with the specified value, size, daughter varis, and partial derivati...
A var implementation that stores the daughter variable implementation pointers and the partial deriva...
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
Definition size.hpp:19
constexpr auto & partials(internal::partials_propagator< Types... > &x) noexcept
Access the partials for an edge of an partials_propagator
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...