Stan Math Library  2.15.0
reverse mode automatic differentiation
promote_elements.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_PROMOTE_ELEMENTS_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_PROMOTE_ELEMENTS_HPP
3 
5 #include <vector>
6 #include <cstddef>
7 
8 namespace stan {
9  namespace math {
10 
20  template <typename T, typename S>
21  struct promote_elements<std::vector<T>, std::vector<S> > {
28  inline static std::vector<T> promote(const std::vector<S>& u) {
29  std::vector<T> t;
30  t.reserve(u.size());
31  for (size_t i = 0; i < u.size(); ++i)
32  t.push_back(promote_elements<T, S>::promote(u[i]));
33  return t;
34  }
35  };
36 
44  template <typename T>
45  struct promote_elements<std::vector<T>, std::vector<T> > {
52  inline static const std::vector<T>& promote(const std::vector<T>& u) {
53  return u;
54  }
55  };
56 
57  }
58 }
59 
60 #endif
static const std::vector< T > & promote(const std::vector< T > &u)
Return input vector.
Struct with static function for elementwise type promotion.
static std::vector< T > promote(const std::vector< S > &u)
Return input vector of type S as vector of type T.

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