Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
promote_scalar.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__FUNCTIONS__PROMOTE_SCALAR_HPP
2 #define STAN__MATH__FUNCTIONS__PROMOTE_SCALAR_HPP
3 
4 #include <vector>
7 
8 namespace stan {
9 
10  namespace math {
11 
20  template <typename T, typename S>
22 
34  static T apply(S x) {
35  return T(x);
36  }
37  };
38 
46  template <typename T>
47  struct promote_scalar_struct<T,T> {
48 
55  static T apply(const T& x) {
56  return x;
57  }
58  };
59 
69  template <typename T, typename S>
70  struct promote_scalar_struct<T, std::vector<S> > {
71 
80  static std::vector<typename promote_scalar_type<T,S>::type>
81  apply(const std::vector<S>& x) {
82  typedef std::vector<typename promote_scalar_type<T,S>::type> return_t;
83  typedef typename index_type<return_t>::type idx_t;
84  return_t y(x.size());
85  for (idx_t i = 0; i < x.size(); ++i)
87  return y;
88  }
89 
90  };
91 
101  template <typename T, typename S>
102  typename promote_scalar_type<T,S>::type
103  promote_scalar(const S& x) {
105  }
106 
107 
108  }
109 }
110 
111 #endif
static std::vector< typename promote_scalar_type< T, S >::type > apply(const std::vector< S > &x)
Return the standard vector consisting of the recursive promotion of the elements of the input standar...
static T apply(const T &x)
Return the unmodified input.
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:21
General struct to hold static function for promoting underlying scalar types.
static T apply(S x)
Return the value of the input argument promoted to the type specified by the template parameter...
promote_scalar_type< T, S >::type promote_scalar(const S &x)
This is the top-level function to call to promote the scalar types of an input of type S to type T...

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