Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
jacobian.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__JACOBIAN_HPP__
2 #define __STAN__AGRAD__REV__JACOBIAN_HPP__
3 
4 #include <vector>
5 #include <stan/agrad/rev/var.hpp>
6 
7 namespace stan {
8  namespace agrad {
9 
36  inline void jacobian(std::vector<var>& dependents,
37  std::vector<var>& independents,
38  std::vector<std::vector<double> >& jacobian) {
39  jacobian.resize(dependents.size());
40  for (size_t i = 0; i < dependents.size(); ++i) {
41  jacobian[i].resize(independents.size());
42  if (i > 0)
44  jacobian.push_back(std::vector<double>(0));
45  grad(dependents[i].vi_);
46  for (size_t j = 0; j < independents.size(); ++j)
47  jacobian[i][j] = independents[j].adj();
48  }
49  }
50 
51  }
52 }
53 #endif

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