| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/rev/core/vari.hpp>
5
6 namespace stan {
7 namespace math {
8
17 class stored_gradient_vari : public vari {
18 protected:
19 size_t size_;
20 vari** dtrs_;
21 double* partials_;
22
23 public:
34 stored_gradient_vari(double value,
35 size_t size,
36 vari** dtrs,
37 double* partials)
38 : vari(value),
39 size_(size),
40 dtrs_(dtrs),
41 partials_(partials) {
42 }
43
48 void chain() {
49 for (size_t i = 0; i < size_; ++i)
50 dtrs_[i]->adj_ += adj_ * partials_[i];
51 }
52 };
53
54 }
55 }
56
57 #endif
stan::math::stored_gradient_vari::stored_gradient_vari
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...
Definition: stored_gradient_vari.hpp:34
vari.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::vari
The variable implementation base class.
Definition: vari.hpp:30
stan::math::stored_gradient_vari
A var implementation that stores the daughter variable implementation pointers and the partial deriva...
Definition: stored_gradient_vari.hpp:17
stan::math::stored_gradient_vari::partials_
double * partials_
Definition: stored_gradient_vari.hpp:21
stan::math::stored_gradient_vari::chain
void chain()
Propagate derivatives through this vari with partial derivatives given for the daughter vari by the s...
Definition: stored_gradient_vari.hpp:48
stan::math::stored_gradient_vari::size_
size_t size_
Definition: stored_gradient_vari.hpp:19
stan::math::stored_gradient_vari::dtrs_
vari ** dtrs_
Definition: stored_gradient_vari.hpp:20
stan::math::size
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
Definition: size.hpp:17
stan::math::vari::adj_
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
Definition: vari.hpp:44

[ Stan Home Page ] © 2011–2016, Stan Development Team.