12 #include <type_traits>
24 template <
typename ad_type>
37 typedef decltype(-std::declval<ad_type>()) expr_type;
40 is_same<
typename Promote<ad_type,ad_type>::type, ad_type >::
value,
41 "Promote<ad_type,ad_type>::type != ad_type");
44 is_same<
typename Promote<ad_type,value_type>::type, ad_type >::
value,
45 "Promote<ad_type,value_type>::type != ad_type");
48 is_same<
typename Promote<value_type,ad_type>::type, ad_type >::
value,
49 "Promote<value_type,ad_type>::type != ad_type");
52 is_same<
typename Promote<ad_type,scalar_type>::type, ad_type >::
value,
53 "Promote<ad_type,scalar_type>::type != ad_type");
56 is_same<
typename Promote<scalar_type,ad_type>::type, ad_type >::
value,
57 "Promote<scalar_type,ad_type>::type != ad_type");
60 is_same<
typename Promote<ad_type,expr_type>::type, ad_type >::
value,
61 "Promote<ad_type,expr_type>::type != ad_type");
64 is_same<
typename Promote<expr_type,ad_type>::type, ad_type >::
value,
65 "Promote<expr_type,ad_type>::type != ad_type");
68 is_same<
typename Promote<expr_type,value_type>::type, ad_type >::
value,
69 "Promote<expr_type,value_type>::type != ad_type");
72 is_same<
typename Promote<value_type,expr_type>::type, ad_type >::
value,
73 "Promote<value_type,expr_type>::type != ad_type");
76 is_same<
typename Promote<expr_type,scalar_type>::type, ad_type >::
value,
77 "Promote<expr_type,scalar_type>::type != ad_type");
80 is_same<
typename Promote<scalar_type,expr_type>::type, ad_type >::
value,
81 "Promote<scalar_type,expr_type>::type != ad_type");
88 template <
typename view_type>
95 typedef typename view_type::base_fad_type base_fad_type;
102 typedef decltype(-std::declval<view_type>()) expr_type;
105 is_same<
typename Promote<view_type,view_type>::type, base_fad_type >::
value,
106 "Promote<view_type,view_type>::type != base_fad_type");
109 is_same<
typename Promote<view_type,value_type>::type, base_fad_type >::
value,
110 "Promote<view_type,value_type>::type != base_fad_type");
113 is_same<
typename Promote<value_type,view_type>::type, base_fad_type >::
value,
114 "Promote<value_type,view_type>::type != base_fad_type");
117 is_same<
typename Promote<view_type,scalar_type>::type, base_fad_type >::
value,
118 "Promote<view_type,scalar_type>::type != base_fad_type");
121 is_same<
typename Promote<scalar_type,view_type>::type, base_fad_type >::
value,
122 "Promote<scalar_type,view_type>::type != base_fad_type");
125 is_same<
typename Promote<view_type,expr_type>::type, base_fad_type >::
value,
126 "Promote<view_type,expr_type>::type != base_fad_type");
129 is_same<
typename Promote<expr_type,view_type>::type, base_fad_type >::
value,
130 "Promote<expr_type,view_type>::type != base_fad_type");
133 is_same<
typename Promote<expr_type,value_type>::type, base_fad_type >::
value,
134 "Promote<expr_type,value_type>::type != base_fad_type");
137 is_same<
typename Promote<value_type,expr_type>::type, base_fad_type >::
value,
138 "Promote<value_type,expr_type>::type != base_fad_type");
141 is_same<
typename Promote<expr_type,scalar_type>::type, base_fad_type >::
value,
142 "Promote<expr_type,scalar_type>::type != base_fad_type");
145 is_same<
typename Promote<scalar_type,expr_type>::type, base_fad_type >::
value,
146 "Promote<scalar_type,expr_type>::type != base_fad_type");
153 template <
typename fad_type>
164 typedef typename view_fad_type::base_fad_type base_fad_type;
165 typedef typename view_fad_fad_type::base_fad_type base_fad_fad_type;
167 testADPromote<fad_type>();
168 testADPromote<fad_fad_type>();
169 testViewPromote<view_fad_type>();
170 testViewPromote<view_fad_fad_type>();
171 testViewPromote<view_view_fad_type>();
174 is_same<
typename Promote<view_fad_type,fad_type>::type, fad_type >::
value,
175 "Promote<view_fad_type,fad_type>::type != fad_type");
178 is_same<
typename Promote<fad_type,view_fad_type>::type, fad_type >::
value,
179 "Promote<fad_type,view_fad_type>::type != fad_type");
182 is_same<
typename Promote<view_fad_fad_type,fad_fad_type>::type, fad_fad_type >::
value,
183 "Promote<view_fad_fad_type,fad_fad_type>::type != fad_fad_type");
186 is_same<
typename Promote<fad_fad_type,view_fad_fad_type>::type, fad_fad_type >::
value,
187 "Promote<fad_fad_type,view_fad_fad_type>::type != fad_fad_type");
189 typedef decltype(std::declval<fad_type>()*std::declval<fad_type>()) fad_expr_type;
190 typedef decltype(std::declval<view_fad_type>()*std::declval<view_fad_type>()) view_fad_expr_type;
193 is_same<
typename Promote<view_fad_type,fad_expr_type>::type, base_fad_type >::
value,
194 "Promote<view_fad_type,fad_expr_type>::type != base_fad_type");
197 is_same<
typename Promote<fad_expr_type,view_fad_type>::type, base_fad_type >::
value,
198 "Promote<fad_expr_type,view_fad_type>::type != base_fad_type");
201 is_same<
typename Promote<fad_type,view_fad_expr_type>::type, fad_type >::
value,
202 "Promote<fad_type,view_fad_expr_type>::type != fad_type");
205 is_same<
typename Promote<view_fad_expr_type,fad_type>::type, fad_type >::
value,
206 "Promote<view_fad_expr_type,fad_type>::type != fad_type");
208 typedef decltype(-std::declval<fad_fad_type>()) fad_fad_expr_type;
209 typedef decltype(-std::declval<view_fad_fad_type>()) view_fad_fad_expr_type;
210 typedef decltype(-std::declval<view_view_fad_type>()) view_view_fad_expr_type;
213 is_same<
typename Promote<view_fad_type,fad_fad_expr_type>::type, fad_fad_type >::
value,
214 "Promote<view_fad_type,fad_fad_expr_type>::type != fad_fad_type");
217 is_same<
typename Promote<fad_fad_expr_type,view_fad_type>::type, fad_fad_type >::
value,
218 "Promote<fad_fad_expr_type,view_fad_type>::type != fad_fad_type");
221 is_same<
typename Promote<view_fad_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::
value,
222 "Promote<view_fad_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
225 is_same<
typename Promote<view_fad_fad_expr_type,view_fad_type>::type, base_fad_fad_type >::
value,
226 "Promote<view_fad_fad_expr_type,view_fad_type>::type != base_fad_fad_type");
229 is_same<
typename Promote<fad_type,view_view_fad_expr_type>::type, base_fad_fad_type >::
value,
230 "Promote<fad_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
233 is_same<
typename Promote<view_view_fad_expr_type,fad_type>::type, base_fad_fad_type >::
value,
234 "Promote<view_fad_fad_expr_type,fad_type>::type != base_fad_fad_type");
237 is_same<
typename Promote<fad_expr_type,fad_fad_expr_type>::type, fad_fad_type >::
value,
238 "Promote<fad_expr_type,fad_fad_expr_type>::type != fad_fad_type");
241 is_same<
typename Promote<fad_fad_expr_type,fad_expr_type>::type, fad_fad_type >::
value,
242 "Promote<fad_fad_expr_type,fad_expr_type>::type != fad_fad_type");
245 is_same<
typename Promote<view_fad_expr_type,fad_fad_expr_type>::type, fad_fad_type >::
value,
246 "Promote<view_fad_expr_type,fad_fad_expr_type>::type != fad_fad_type");
249 is_same<
typename Promote<fad_fad_expr_type,view_fad_expr_type>::type, fad_fad_type >::
value,
250 "Promote<fad_fad_expr_type,view_fad_expr_type>::type != fad_fad_type");
253 is_same<
typename Promote<fad_expr_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::
value,
254 "Promote<fad_expr_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
257 is_same<
typename Promote<view_fad_fad_expr_type,fad_expr_type>::type, base_fad_fad_type >::
value,
258 "Promote<view_fad_fad_expr_type,fad_expr_type>::type != base_fad_fad_type");
261 is_same<
typename Promote<view_fad_expr_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::
value,
262 "Promote<view_fad_expr_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
265 is_same<
typename Promote<view_fad_fad_expr_type,view_fad_expr_type>::type, base_fad_fad_type >::
value,
266 "Promote<view_fad_fad_expr_type,view_fad_expr_type>::type != base_fad_fad_type");
269 is_same<
typename Promote<fad_expr_type,view_view_fad_expr_type>::type, base_fad_fad_type >::
value,
270 "Promote<fad_expr_type,view_view_fad_expr_type>::type != base_fad_fad_type");
273 is_same<
typename Promote<view_view_fad_expr_type,fad_expr_type>::type, base_fad_fad_type >::
value,
274 "Promote<view_view_fad_expr_type,fad_expr_type>::type != base_fad_fad_type");
277 is_same<
typename Promote<view_fad_expr_type,view_view_fad_expr_type>::type, base_fad_fad_type >::
value,
278 "Promote<view_fad_expr_type,view_view_fad_expr_type>::type != base_fad_fad_type");
281 is_same<
typename Promote<view_view_fad_expr_type,view_fad_expr_type>::type, base_fad_fad_type >::
value,
282 "Promote<view_view_fad_expr_type,view_fad_expr_type>::type != base_fad_fad_type");
289 template <
typename scalar_type>
293 testADPromote<scalar_type>();
294 testADPromote<fad_scalar_type>();
303 success = testFadPromote<FAD>();
308 success = testPromote<AD>();
318 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_SFadType )
319 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_SLFadType )
320 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_DVFadType )
325 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_DFadType )
326 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_SFadType )
327 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_SLFadType )
332 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_DFadType )
333 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_SFadType )
334 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_SLFadType )
340 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_DFadType )
341 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_SFadType )
342 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_SLFadType )
345 typedef Sacado::LFad::LogicalSparse<
double,
bool>
LFadType;
346 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, SimpleFadType )
347 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, LFadType )
349 typedef Sacado::FlopCounterPack::ScalarFlopCounter<
double>
SFCType;
350 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, SFCType )
354 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, TaylorType )
355 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, CacheTaylorType )
360 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, RadType )
361 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, Rad2Type )
362 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, RadVecType )
364 int main(
int argc,
char* argv[] ) {
Sacado::CacheFad::SLFad< double, 10 > Fad_SLFadType
Forward-mode AD class using dynamic memory allocation.
const int global_fad_size
Sacado::CacheFad::DFad< double > Fad_DFadType
GeneralFad< StaticStorage< T, Num > > SLFad
Forward-mode AD class using dynamic memory allocation but no expression templates.
F::template apply< A1, A2, A3, A4, A5 >::type type
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(ConditionalReturnType, Fad, FAD)
Sacado::Fad::DVFad< double > Fad_DVFadType
static int runUnitTestsFromMain(int argc, char *argv[])
GeneralFad< DynamicStorage< T > > DFad
Forward-mode AD class using dynamic memory allocation and expression templates.
Templated flop counter class.
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, TYPE)
GeneralFad< ViewStorage< T, static_length, static_stride, U > > ViewFad
GeneralFad< StaticFixedStorage< T, Num > > SFad
Sacado::CacheFad::SFad< double, 5 > Fad_SFadType
Get view type for any Fad type.