Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
promote_scalar.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_HPP
3 
7 #include <vector>
8 
9 namespace stan {
10 
11  namespace math {
12 
21  template <typename T, typename S>
34  static T apply(S x) {
35  return T(x);
36  }
37  };
38 
46  template <typename T>
47  struct promote_scalar_struct<T, T> {
54  static T apply(const T& x) {
55  return x;
56  }
57  };
58 
68  template <typename T, typename S>
69  struct promote_scalar_struct<T, std::vector<S> > {
78  static std::vector<typename promote_scalar_type<T, S>::type>
79  apply(const std::vector<S>& x) {
80  typedef std::vector<typename promote_scalar_type<T, S>::type> return_t;
81  typedef typename index_type<return_t>::type idx_t;
82  return_t y(x.size());
83  for (idx_t i = 0; i < x.size(); ++i)
85  return y;
86  }
87  };
88 
98  template <typename T, typename S>
99  typename promote_scalar_type<T, S>::type
100  promote_scalar(const S& x) {
102  }
103 
104 
105  }
106 }
107 
108 #endif
static T apply(const T &x)
Return the unmodified input.
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...
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...
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:19
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...

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