1 #ifndef STAN_MATH_REV_CORE_PRECOMPUTED_GRADIENTS_HPP
2 #define STAN_MATH_REV_CORE_PRECOMPUTED_GRADIENTS_HPP
59 const std::vector<var>& vars,
60 const std::vector<double>& gradients)
66 .alloc_array<double>(vars.
size())) {
67 if (vars.size() != gradients.size())
70 for (
size_t i = 0; i < vars.size(); ++i)
72 std::copy(gradients.begin(), gradients.end(),
gradients_);
80 for (
size_t i = 0; i <
size_; ++i)
99 const std::vector<var>& operands,
100 const std::vector<double>& gradients) {
var precomputed_gradients(const double value, const std::vector< var > &operands, const std::vector< double > &gradients)
This function returns a var for an expression that has the specified value, vector of operands...
The variable implementation base class.
Independent (input) and dependent (output) variables for gradients.
A variable implementation taking a sequence of operands and partial derivatives with respect to the o...
precomputed_gradients_vari(double val, const std::vector< var > &vars, const std::vector< double > &gradients)
Construct a precomputed vari with the specified value, operands, and gradients.
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.
void chain()
Implements the chain rule for this variable, using the prestored operands and gradient.
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
precomputed_gradients_vari(double val, size_t size, vari **varis, double *gradients)
Construct a precomputed vari with the specified value, operands, and gradients.