Stan Math Library  2.10.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 
5 #include <stdexcept>
6 
7 namespace stan {
8 
24  template<typename T1, bool used, bool is_vec>
26  public:
27  explicit VectorBuilderHelper(size_t /* n */) { }
28 
29  T1& operator[](size_t /* i */) {
30  throw std::logic_error("used is false. this should never be called");
31  }
32 
33  typedef T1 type;
34 
35  inline type& data() {
36  throw std::logic_error("used is false. this should never be called");
37  }
38  };
39 
40  template<typename T1>
41  class VectorBuilderHelper<T1, true, false> {
42  private:
43  T1 x_;
44  public:
45  explicit VectorBuilderHelper(size_t /* n */) : x_(0.0) { }
46  T1& operator[](size_t /* i */) {
47  return x_;
48  }
49 
50  typedef T1 type;
51 
52  inline type& data() {
53  return x_;
54  }
55  };
56 
57 }
58 #endif
VectorBuilder allocates type T1 values to be used as intermediate values.

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