Stan Math Library  2.10.0
reverse mode automatic differentiation
matrix_vari.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_MATRIX_VARI_HPP
2 #define STAN_MATH_REV_CORE_MATRIX_VARI_HPP
3 
8 
9 namespace stan {
10  namespace math {
11 
12  class op_matrix_vari : public vari {
13  protected:
14  const size_t size_;
16  public:
17  template <int R, int C>
18  op_matrix_vari(double f,
19  const Eigen::Matrix<stan::math::var, R, C>& vs) :
20  vari(f),
21  size_(vs.size()) {
22  vis_ = reinterpret_cast<vari**>
23  (operator new(sizeof(vari*) * vs.size()));
24  for (int i = 0; i < vs.size(); ++i)
25  vis_[i] = vs(i).vi_;
26  }
27  vari* operator[](size_t n) const {
28  return vis_[n];
29  }
30  size_t size() {
31  return size_;
32  }
33  };
34 
35  }
36 }
37 #endif
The variable implementation base class.
Definition: vari.hpp:30
vari * operator[](size_t n) const
Definition: matrix_vari.hpp:27
op_matrix_vari(double f, const Eigen::Matrix< stan::math::var, R, C > &vs)
Definition: matrix_vari.hpp:18

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