Stan Math Library  2.20.0
reverse mode automatic differentiation
ad_promotable.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_META_AD_PROMOTABLE_HPP
2 #define STAN_MATH_PRIM_SCAL_META_AD_PROMOTABLE_HPP
3 
4 #include <type_traits>
5 
6 namespace stan {
7 namespace math {
8 
21 template <typename V, typename T>
22 struct ad_promotable {
23  enum { value = false };
24 };
25 
31 template <typename T>
33  typename std::enable_if<std::is_arithmetic<T>::value, T>::type, T> {
34  enum { value = true };
35 };
36 
40 template <>
41 struct ad_promotable<bool, double> {
42  enum { value = true };
43 };
44 
48 template <>
49 struct ad_promotable<char, double> {
50  enum { value = true };
51 };
52 
56 template <>
57 struct ad_promotable<unsigned char, double> {
58  enum { value = true };
59 };
60 
64 template <>
65 struct ad_promotable<short, double> { // NOLINT(runtime/int)
66  enum { value = true };
67 };
68 
72 template <>
73 struct ad_promotable<unsigned short, double> { // NOLINT(runtime/int)
74  enum { value = true };
75 };
76 
80 template <>
81 struct ad_promotable<int, double> {
82  enum { value = true };
83 };
84 
88 template <>
89 struct ad_promotable<unsigned int, double> {
90  enum { value = true };
91 };
92 
96 template <>
97 struct ad_promotable<long, double> { // NOLINT(runtime/int)
98  enum { value = true };
99 };
100 
104 template <>
105 struct ad_promotable<unsigned long, double> { // NOLINT(runtime/int)
106  enum { value = true };
107 };
108 
112 template <>
113 struct ad_promotable<long long, double> { // NOLINT(runtime/int)
114  enum { value = true };
115 };
116 
120 template <>
121 struct ad_promotable<unsigned long long, double> { // NOLINT(runtime/int)
122  enum { value = true };
123 };
124 
128 template <>
129 struct ad_promotable<float, double> {
130  enum { value = true };
131 };
132 
136 template <>
137 struct ad_promotable<double, double> {
138  enum { value = true };
139 };
140 
144 template <>
145 struct ad_promotable<long double, double> {
146  enum { value = true };
147 };
148 
149 } // namespace math
150 } // namespace stan
151 #endif
Template traits metaprogram to determine if a variable of one template type can be promoted to a seco...

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