| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

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