| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
VectorBuilder.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
2 #define STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
3
4 #include <stan/math/prim/scal/meta/contains_vector.hpp>
5 #include <stdexcept>
6 #include <vector>
7
8 namespace stan {
9
27 template<typename T1, bool used, bool is_vec>
28 class VectorBuilderHelper {
29 public:
30 explicit VectorBuilderHelper(size_t /* n */) { }
31 T1& operator[](size_t /* i */) {
32 throw std::logic_error("used is false. this should never be called");
33 }
34 };
35
36 template<typename T1>
37 class VectorBuilderHelper<T1, true, false> {
38 private:
39 T1 x_;
40 public:
41 explicit VectorBuilderHelper(size_t /* n */) : x_(0.0) { }
42 T1& operator[](size_t /* i */) {
43 return x_;
44 }
45 };
46
47 template<typename T1>
48 class VectorBuilderHelper<T1, true, true> {
49 private:
50 std::vector<T1> x_;
51 public:
52 explicit VectorBuilderHelper(size_t n) : x_(n) { }
53 T1& operator[](size_t i) {
54 return x_[i];
55 }
56 };
57
58 template<bool used, typename T1, typename T2, typename T3 = double,
59 typename T4 = double, typename T5 = double, typename T6 = double,
60 typename T7 = double>
61 class VectorBuilder {
62 public:
63 VectorBuilderHelper<T1, used,
64 contains_vector<T2, T3, T4, T5, T6, T7>::value> a;
65 explicit VectorBuilder(size_t n) : a(n) { }
66 T1& operator[](size_t i) {
67 return a[i];
68 }
69 };
70
71 }
72 #endif
73
stan::VectorBuilderHelper< T1, true, true >::operator[]
T1 & operator[](size_t i)
Definition: VectorBuilder.hpp:53
stan::VectorBuilder::a
VectorBuilderHelper< T1, used, contains_vector< T2, T3, T4, T5, T6, T7 >::value > a
Definition: VectorBuilder.hpp:64
stan::VectorBuilderHelper::operator[]
T1 & operator[](size_t)
Definition: VectorBuilder.hpp:31
stan::VectorBuilderHelper< T1, true, false >::operator[]
T1 & operator[](size_t)
Definition: VectorBuilder.hpp:42
stan::VectorBuilderHelper
VectorBuilder allocates type T1 values to be used as intermediate values.
Definition: VectorBuilder.hpp:28
contains_vector.hpp
stan::VectorBuilderHelper< T1, true, true >::VectorBuilderHelper
VectorBuilderHelper(size_t n)
Definition: VectorBuilder.hpp:52
stan::VectorBuilder::operator[]
T1 & operator[](size_t i)
Definition: VectorBuilder.hpp:66
stan::VectorBuilder
Definition: VectorBuilder.hpp:61
stan::contains_vector
Definition: contains_vector.hpp:14
stan::VectorBuilder::VectorBuilder
VectorBuilder(size_t n)
Definition: VectorBuilder.hpp:65
stan::VectorBuilderHelper::VectorBuilderHelper
VectorBuilderHelper(size_t)
Definition: VectorBuilder.hpp:30
stan::VectorBuilderHelper< T1, true, false >::VectorBuilderHelper
VectorBuilderHelper(size_t)
Definition: VectorBuilder.hpp:41

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