32 #include <type_traits>
44 template <
typename ad_type>
57 typedef decltype(-std::declval<ad_type>()) expr_type;
60 is_same<
typename Promote<ad_type,ad_type>::type, ad_type >::value,
61 "Promote<ad_type,ad_type>::type != ad_type");
64 is_same<
typename Promote<ad_type,value_type>::type, ad_type >::value,
65 "Promote<ad_type,value_type>::type != ad_type");
68 is_same<
typename Promote<value_type,ad_type>::type, ad_type >::value,
69 "Promote<value_type,ad_type>::type != ad_type");
72 is_same<
typename Promote<ad_type,scalar_type>::type, ad_type >::value,
73 "Promote<ad_type,scalar_type>::type != ad_type");
76 is_same<
typename Promote<scalar_type,ad_type>::type, ad_type >::value,
77 "Promote<scalar_type,ad_type>::type != ad_type");
80 is_same<
typename Promote<ad_type,expr_type>::type, ad_type >::value,
81 "Promote<ad_type,expr_type>::type != ad_type");
84 is_same<
typename Promote<expr_type,ad_type>::type, ad_type >::value,
85 "Promote<expr_type,ad_type>::type != ad_type");
88 is_same<
typename Promote<expr_type,value_type>::type, ad_type >::value,
89 "Promote<expr_type,value_type>::type != ad_type");
92 is_same<
typename Promote<value_type,expr_type>::type, ad_type >::value,
93 "Promote<value_type,expr_type>::type != ad_type");
96 is_same<
typename Promote<expr_type,scalar_type>::type, ad_type >::value,
97 "Promote<expr_type,scalar_type>::type != ad_type");
100 is_same<
typename Promote<scalar_type,expr_type>::type, ad_type >::value,
101 "Promote<scalar_type,expr_type>::type != ad_type");
108 template <
typename view_type>
115 typedef typename view_type::base_fad_type base_fad_type;
122 typedef decltype(-std::declval<view_type>()) expr_type;
125 is_same<
typename Promote<view_type,view_type>::type, base_fad_type >::value,
126 "Promote<view_type,view_type>::type != base_fad_type");
129 is_same<
typename Promote<view_type,value_type>::type, base_fad_type >::value,
130 "Promote<view_type,value_type>::type != base_fad_type");
133 is_same<
typename Promote<value_type,view_type>::type, base_fad_type >::value,
134 "Promote<value_type,view_type>::type != base_fad_type");
137 is_same<
typename Promote<view_type,scalar_type>::type, base_fad_type >::value,
138 "Promote<view_type,scalar_type>::type != base_fad_type");
141 is_same<
typename Promote<scalar_type,view_type>::type, base_fad_type >::value,
142 "Promote<scalar_type,view_type>::type != base_fad_type");
145 is_same<
typename Promote<view_type,expr_type>::type, base_fad_type >::value,
146 "Promote<view_type,expr_type>::type != base_fad_type");
149 is_same<
typename Promote<expr_type,view_type>::type, base_fad_type >::value,
150 "Promote<expr_type,view_type>::type != base_fad_type");
153 is_same<
typename Promote<expr_type,value_type>::type, base_fad_type >::value,
154 "Promote<expr_type,value_type>::type != base_fad_type");
157 is_same<
typename Promote<value_type,expr_type>::type, base_fad_type >::value,
158 "Promote<value_type,expr_type>::type != base_fad_type");
161 is_same<
typename Promote<expr_type,scalar_type>::type, base_fad_type >::value,
162 "Promote<expr_type,scalar_type>::type != base_fad_type");
165 is_same<
typename Promote<scalar_type,expr_type>::type, base_fad_type >::value,
166 "Promote<scalar_type,expr_type>::type != base_fad_type");
173 template <
typename fad_type>
184 typedef typename view_fad_type::base_fad_type base_fad_type;
185 typedef typename view_fad_fad_type::base_fad_type base_fad_fad_type;
187 testADPromote<fad_type>();
188 testADPromote<fad_fad_type>();
189 testViewPromote<view_fad_type>();
190 testViewPromote<view_fad_fad_type>();
191 testViewPromote<view_view_fad_type>();
194 is_same<
typename Promote<view_fad_type,fad_type>::type, fad_type >::value,
195 "Promote<view_fad_type,fad_type>::type != fad_type");
198 is_same<
typename Promote<fad_type,view_fad_type>::type, fad_type >::value,
199 "Promote<fad_type,view_fad_type>::type != fad_type");
202 is_same<
typename Promote<view_fad_fad_type,fad_fad_type>::type, fad_fad_type >::value,
203 "Promote<view_fad_fad_type,fad_fad_type>::type != fad_fad_type");
206 is_same<
typename Promote<fad_fad_type,view_fad_fad_type>::type, fad_fad_type >::value,
207 "Promote<fad_fad_type,view_fad_fad_type>::type != fad_fad_type");
209 typedef decltype(std::declval<fad_type>()*std::declval<fad_type>()) fad_expr_type;
210 typedef decltype(std::declval<view_fad_type>()*std::declval<view_fad_type>()) view_fad_expr_type;
213 is_same<
typename Promote<view_fad_type,fad_expr_type>::type, base_fad_type >::value,
214 "Promote<view_fad_type,fad_expr_type>::type != base_fad_type");
217 is_same<
typename Promote<fad_expr_type,view_fad_type>::type, base_fad_type >::value,
218 "Promote<fad_expr_type,view_fad_type>::type != base_fad_type");
221 is_same<
typename Promote<fad_type,view_fad_expr_type>::type, fad_type >::value,
222 "Promote<fad_type,view_fad_expr_type>::type != fad_type");
225 is_same<
typename Promote<view_fad_expr_type,fad_type>::type, fad_type >::value,
226 "Promote<view_fad_expr_type,fad_type>::type != fad_type");
228 typedef decltype(-std::declval<fad_fad_type>()) fad_fad_expr_type;
229 typedef decltype(-std::declval<view_fad_fad_type>()) view_fad_fad_expr_type;
230 typedef decltype(-std::declval<view_view_fad_type>()) view_view_fad_expr_type;
233 is_same<
typename Promote<view_fad_type,fad_fad_expr_type>::type, fad_fad_type >::value,
234 "Promote<view_fad_type,fad_fad_expr_type>::type != fad_fad_type");
237 is_same<
typename Promote<fad_fad_expr_type,view_fad_type>::type, fad_fad_type >::value,
238 "Promote<fad_fad_expr_type,view_fad_type>::type != fad_fad_type");
241 is_same<
typename Promote<view_fad_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::value,
242 "Promote<view_fad_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
245 is_same<
typename Promote<view_fad_fad_expr_type,view_fad_type>::type, base_fad_fad_type >::value,
246 "Promote<view_fad_fad_expr_type,view_fad_type>::type != base_fad_fad_type");
249 is_same<
typename Promote<fad_type,view_view_fad_expr_type>::type, base_fad_fad_type >::value,
250 "Promote<fad_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
253 is_same<
typename Promote<view_view_fad_expr_type,fad_type>::type, base_fad_fad_type >::value,
254 "Promote<view_fad_fad_expr_type,fad_type>::type != base_fad_fad_type");
257 is_same<
typename Promote<fad_expr_type,fad_fad_expr_type>::type, fad_fad_type >::value,
258 "Promote<fad_expr_type,fad_fad_expr_type>::type != fad_fad_type");
261 is_same<
typename Promote<fad_fad_expr_type,fad_expr_type>::type, fad_fad_type >::value,
262 "Promote<fad_fad_expr_type,fad_expr_type>::type != fad_fad_type");
265 is_same<
typename Promote<view_fad_expr_type,fad_fad_expr_type>::type, fad_fad_type >::value,
266 "Promote<view_fad_expr_type,fad_fad_expr_type>::type != fad_fad_type");
269 is_same<
typename Promote<fad_fad_expr_type,view_fad_expr_type>::type, fad_fad_type >::value,
270 "Promote<fad_fad_expr_type,view_fad_expr_type>::type != fad_fad_type");
273 is_same<
typename Promote<fad_expr_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::value,
274 "Promote<fad_expr_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
277 is_same<
typename Promote<view_fad_fad_expr_type,fad_expr_type>::type, base_fad_fad_type >::value,
278 "Promote<view_fad_fad_expr_type,fad_expr_type>::type != base_fad_fad_type");
281 is_same<
typename Promote<view_fad_expr_type,view_fad_fad_expr_type>::type, base_fad_fad_type >::value,
282 "Promote<view_fad_expr_type,view_fad_fad_expr_type>::type != base_fad_fad_type");
285 is_same<
typename Promote<view_fad_fad_expr_type,view_fad_expr_type>::type, base_fad_fad_type >::value,
286 "Promote<view_fad_fad_expr_type,view_fad_expr_type>::type != base_fad_fad_type");
289 is_same<
typename Promote<fad_expr_type,view_view_fad_expr_type>::type, base_fad_fad_type >::value,
290 "Promote<fad_expr_type,view_view_fad_expr_type>::type != base_fad_fad_type");
293 is_same<
typename Promote<view_view_fad_expr_type,fad_expr_type>::type, base_fad_fad_type >::value,
294 "Promote<view_view_fad_expr_type,fad_expr_type>::type != base_fad_fad_type");
297 is_same<
typename Promote<view_fad_expr_type,view_view_fad_expr_type>::type, base_fad_fad_type >::value,
298 "Promote<view_fad_expr_type,view_view_fad_expr_type>::type != base_fad_fad_type");
301 is_same<
typename Promote<view_view_fad_expr_type,view_fad_expr_type>::type, base_fad_fad_type >::value,
302 "Promote<view_view_fad_expr_type,view_fad_expr_type>::type != base_fad_fad_type");
309 template <
typename scalar_type>
313 testADPromote<scalar_type>();
314 testADPromote<fad_scalar_type>();
323 success = testFadPromote<FAD>();
328 success = testPromote<AD>();
338 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_SFadType )
339 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_SLFadType )
340 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad,
Fad_DVFadType )
345 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_DFadType )
346 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_SFadType )
347 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRFad_SLFadType )
352 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_DFadType )
353 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_SFadType )
354 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, CacheFad_SLFadType )
360 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_DFadType )
361 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_SFadType )
362 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Fad, ELRCacheFad_SLFadType )
365 typedef Sacado::LFad::LogicalSparse<
double,
bool>
LFadType;
366 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, SimpleFadType )
367 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, LFadType )
369 typedef Sacado::FlopCounterPack::ScalarFlopCounter<
double>
SFCType;
370 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, SFCType )
374 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, TaylorType )
375 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, CacheTaylorType )
380 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, RadType )
381 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, Rad2Type )
382 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Promote, Other, RadVecType )
384 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.