All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
VectorBuilder.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
#define STAN_MATH_PRIM_SCAL_META_VECTORBUILDER_HPP
#include <stan/math/prim/scal/meta/contains_vector.hpp>
#include <stdexcept>
#include <vector>
namespace stan {
template<typename T1, bool used, bool is_vec>
class VectorBuilderHelper {
public:
explicit VectorBuilderHelper(size_t /* n */) { }
T1& operator[](size_t /* i */) {
throw std::logic_error("used is false. this should never be called");
}
};
template<typename T1>
class VectorBuilderHelper<T1, true, false> {
private:
T1 x_;
public:
explicit VectorBuilderHelper(size_t /* n */) : x_(0.0) { }
T1& operator[](size_t /* i */) {
return x_;
}
};
template<typename T1>
class VectorBuilderHelper<T1, true, true> {
private:
std::vector<T1> x_;
public:
explicit VectorBuilderHelper(size_t n) : x_(n) { }
T1& operator[](size_t i) {
return x_[i];
}
};
template<bool used, typename T1, typename T2, typename T3 = double,
typename T4 = double, typename T5 = double, typename T6 = double,
typename T7 = double>
class VectorBuilder {
public:
VectorBuilderHelper<T1, used,
contains_vector<T2, T3, T4, T5, T6, T7>::value> a;
explicit VectorBuilder(size_t n) : a(n) { }
T1& operator[](size_t i) {
return a[i];
}
};
}
#endif
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.