Stan Math Library  2.15.0
reverse mode automatic differentiation
array_builder.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_ARRAY_BUILDER_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_ARRAY_BUILDER_HPP
3 
5 #include <vector>
6 
7 namespace stan {
8  namespace math {
9 
18  template <typename T>
19  class array_builder {
20  private:
21  std::vector<T> x_;
22 
23  public:
27  array_builder() : x_() { }
28 
35  template <typename S>
36  array_builder& add(const S& u) {
37  x_.push_back(promote_elements<T, S>::promote(u));
38  return *this;
39  }
40 
46  std::vector<T> array() {
47  return x_;
48  }
49  };
50 
51  }
52 }
53 #endif
Struct with static function for elementwise type promotion.
array_builder & add(const S &u)
Add one element of type S to array, promoting to type T.
std::vector< T > array()
Getter method to return array itself.
Structure for building up arrays in an expression (rather than in statements) using an argumentchaini...
array_builder()
Construct an array_builder.

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