Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
grad.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__MATRIX__GRAD_HPP
2 #define STAN__AGRAD__REV__MATRIX__GRAD_HPP
3 
4 
7 #include <stan/agrad/rev/var.hpp>
8 
9 namespace stan {
10 
11  namespace agrad {
12 
27  void grad(var& v,
28  Eigen::Matrix<var,Eigen::Dynamic,1>& x,
29  Eigen::VectorXd& g) {
31  g.resize(x.size());
32  for (int i = 0; i < x.size(); ++i)
33  g(i) = x(i).vi_->adj_;
34  }
35 
36  }
37 }
38 
39 #endif
static void grad(chainable *vi)
Compute the gradient for all variables starting from the specified root variable implementation.
Definition: chainable.hpp:110
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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