Stan Math Library  2.20.0
reverse mode automatic differentiation
vector_vari.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_VECTOR_VARI_HPP
2 #define STAN_MATH_REV_CORE_VECTOR_VARI_HPP
3 
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
11 class op_vector_vari : public vari {
12  protected:
13  const size_t size_;
15 
16  public:
17  op_vector_vari(double f, const std::vector<var>& vs)
18  : vari(f), size_(vs.size()) {
19  vis_ = reinterpret_cast<vari**>(operator new(sizeof(vari*) * vs.size()));
20  for (size_t i = 0; i < vs.size(); ++i)
21  vis_[i] = vs[i].vi_;
22  }
23  vari* operator[](size_t n) const { return vis_[n]; }
24  size_t size() { return size_; }
25 };
26 
27 } // namespace math
28 } // namespace stan
29 #endif
op_vector_vari(double f, const std::vector< var > &vs)
Definition: vector_vari.hpp:17
vari * operator[](size_t n) const
Definition: vector_vari.hpp:23
The variable implementation base class.
Definition: vari.hpp:30

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