Stan Math Library  2.20.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 
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
19 template <typename T>
21  private:
22  std::vector<T> x_;
23 
24  public:
28  array_builder() : x_() {}
29 
36  template <typename S>
37  array_builder& add(const S& u) {
38  x_.push_back(promote_elements<T, S>::promote(u));
39  return *this;
40  }
41 
47  std::vector<T> array() { return x_; }
48 };
49 
50 } // namespace math
51 } // namespace stan
52 #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–2018, Stan Development Team.