1 #ifndef STAN__AGRAD__REV__INTERNAL__PRECOMPUTED_GRADIENTS_HPP
2 #define STAN__AGRAD__REV__INTERNAL__PRECOMPUTED_GRADIENTS_HPP
42 std::vector<vari *>& varis,
43 const std::vector<double>& gradients)
48 throw std::invalid_argument(
"sizes of varis and gradients do not match");
59 for (
size_t n = 0; n <
varis_.size(); n++) {
87 const std::vector<var>& vars,
88 const std::vector<double>& gradients) {
89 std::vector<vari *> varis;
90 varis.resize(vars.size());
91 for (
size_t n = 0; n < vars.size(); n++) {
92 varis[n] = vars[n].
vi_;
This is a var implementation class that takes precomputed gradient values.
std::vector< double > gradients_
var precomputed_gradients(const double value, const std::vector< var > &vars, const std::vector< double > &gradients)
This function is provided for Stan users that want to compute gradients without using Stan's auto-dif...
void chain()
Implements the chain rule for this variable.
vari * vi_
Pointer to the implementation of this variable.
std::vector< vari * > varis_
The variable implementation base class.
Independent (input) and dependent (output) variables for gradients.
precomputed_gradients_vari(const double val, std::vector< vari * > &varis, const std::vector< double > &gradients)
Constructs a precomputed_gradients_vari.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...