All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
stored_gradient_vari.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_CORE_STORED_GRADIENT_VARI_HPP
#define STAN_MATH_REV_CORE_STORED_GRADIENT_VARI_HPP
#include <stan/math/rev/core/vari.hpp>
namespace stan {
namespace math {
class stored_gradient_vari : public vari {
protected:
size_t size_;
vari** dtrs_;
double* partials_;
public:
stored_gradient_vari(double value,
size_t size,
vari** dtrs,
double* partials)
: vari(value),
size_(size),
dtrs_(dtrs),
partials_(partials) {
}
void chain() {
for (size_t i = 0; i < size_; ++i)
dtrs_[i]->adj_ += adj_ * partials_[i];
}
};
}
}
#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:35
vari.hpp
stan::math::vari
The variable implementation base class.
Definition: vari.hpp:28
stan::math::stored_gradient_vari
A var implementation that stores the daughter variable implementation pointers and the partial deriva...
Definition: stored_gradient_vari.hpp:18
stan::math::stored_gradient_vari::partials_
double * partials_
Definition: stored_gradient_vari.hpp:22
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:49
stan::math::stored_gradient_vari::size_
size_t size_
Definition: stored_gradient_vari.hpp:20
stan::math::stored_gradient_vari::dtrs_
vari ** dtrs_
Definition: stored_gradient_vari.hpp:21
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:42

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