Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
vector_vari.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__OP__VECTOR_VARI_HPP__
2 #define __STAN__AGRAD__REV__OP__VECTOR_VARI_HPP__
3 
4 #include <vector>
5 #include <stan/agrad/rev/var.hpp>
7 
8 namespace stan {
9  namespace agrad {
10 
11  // FIXME: memory leak -- copy vector to local memory
12  class op_vector_vari : public vari {
13  protected:
14  const size_t size_;
16  public:
17  op_vector_vari(double f, const std::vector<stan::agrad::var>& vs) :
18  vari(f),
19  size_(vs.size()) {
20  vis_ = (vari**) operator new(sizeof(vari*) * vs.size());
21  for (size_t i = 0; i < vs.size(); ++i)
22  vis_[i] = vs[i].vi_;
23  }
24  vari* operator[](size_t n) const {
25  return vis_[n];
26  }
27  size_t size() {
28  return size_;
29  }
30  };
31 
32  }
33 }
34 #endif

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