Stan Math Library  2.20.0
reverse mode automatic differentiation
VectorBuilderHelper.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HELPER_HPP
2 #define STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HELPER_HPP
3 
4 #include <stdexcept>
5 
6 namespace stan {
7 
23 template <typename T1, bool used, bool is_vec>
25  public:
26  explicit VectorBuilderHelper(size_t /* n */) {}
27 
28  T1& operator[](size_t /* i */) {
29  throw std::logic_error("used is false. this should never be called");
30  }
31 
32  typedef T1 type;
33 
34  inline type& data() {
35  throw std::logic_error("used is false. this should never be called");
36  }
37 };
38 
39 template <typename T1>
40 class VectorBuilderHelper<T1, true, false> {
41  private:
42  T1 x_;
43 
44  public:
45  explicit VectorBuilderHelper(size_t /* n */) : x_(0) {}
46  T1& operator[](size_t /* i */) { return x_; }
47 
48  typedef T1 type;
49 
50  inline type& data() { return x_; }
51 };
52 
53 } // namespace stan
54 #endif
VectorBuilder allocates type T1 values to be used as intermediate values.

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