30#include "Teuchos_UnitTestHarness.hpp"
31#include "Teuchos_UnitTestRepository.hpp"
32#include "Teuchos_GlobalMPISession.hpp"
33#include "Teuchos_TestingHelpers.hpp"
47struct C :
public A {};
61 TEST_EQUALITY( is_b_a,
false );
62 TEST_EQUALITY( is_a_b,
true );
63 TEST_EQUALITY( is_c_a,
true );
64 TEST_EQUALITY( is_int_double,
true );
65 TEST_EQUALITY( is_double_int,
true );
66 TEST_EQUALITY( is_double_a,
false );
69template <
typename ad_type>
76 const bool is_value_ad =
78 const bool is_ad_value =
80 const bool is_scalar_ad =
82 const bool is_ad_scalar =
86 const bool is_int_ad =
89 TEST_EQUALITY( is_value_ad, is_not_view );
90 TEST_EQUALITY_CONST( is_ad_value,
false );
91 TEST_EQUALITY( is_scalar_ad, is_not_view );
92 TEST_EQUALITY_CONST( is_ad_scalar,
false );
93 TEST_EQUALITY( is_int_ad, is_not_view );
95#ifdef HAVE_SACADO_CXX11
99 typedef decltype(std::declval<ad_type>()*std::declval<ad_type>()) ad_expr_type;
100 typedef decltype(std::declval<value_type>()*std::declval<value_type>()) val_expr_type;
102 const bool is_ad_expr_ad =
104 const bool is_val_expr_ad =
107 TEST_EQUALITY( is_ad_expr_ad, is_not_view );
108 TEST_EQUALITY( is_val_expr_ad, is_not_view );
121 typedef typename ad_type::value_type value_type;
125 success = success && test_ad_conversions<ad_type>(out);
126 success = success && test_ad_conversions<ad_ad_type>(out);
131 x.fastAccessDx(
i) = 2.0;
132 ad_ad_type
y =
x +
x;
133 TEST_EQUALITY_CONST(
y.val().val(), 3.0 );
135 TEST_EQUALITY_CONST(
y.val().dx(
i), 4.0 );
136 TEST_EQUALITY_CONST(
y.dx(
i).val(), 0.0 );
138 TEST_EQUALITY_CONST(
y.dx(
i).dx(j), 0.0 );
142 ad_ad_type
z = (
x +
x) +
y;
143 TEST_EQUALITY_CONST(
z.val().val(), 6.0 );
145 TEST_EQUALITY_CONST(
z.val().dx(
i), 8.0 );
146 TEST_EQUALITY_CONST(
z.dx(
i).val(), 0.0 );
148 TEST_EQUALITY_CONST(
z.dx(
i).dx(j), 0.0 );
153 TEST_EQUALITY_CONST(
y.val().val(), 4.0 );
155 TEST_EQUALITY_CONST(
y.val().dx(
i), 4.0 );
156 TEST_EQUALITY_CONST(
y.dx(
i).val(), 0.0 );
158 TEST_EQUALITY_CONST(
y.dx(
i).dx(j), 0.0 );
169 success = success && test_ad_conversions<ad_type>(out);
170 success = success && test_ad_conversions<ad_ad_type>(out);
185 success = success && test_ad_conversions<ad_type>(out);
186 success = success && test_ad_conversions<fad_ad_type>(out);
195TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
Fad_DFadType )
196TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
Fad_SLFadType )
197TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
Fad_SFadType )
198TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
Fad_DVFadType )
199TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
Fad_SimpleFadType )
200TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ViewConversions,
Fad_VFadType )
206TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
ELRFad_DFadType )
207TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
ELRFad_SLFadType )
208TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
ELRFad_SFadType )
209TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ViewConversions,
ELRFad_VFadType )
215TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
CacheFad_DFadType )
217TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ADConversions,
CacheFad_SFadType )
218TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, ViewConversions,
CacheFad_VFadType )
239TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
LFadType )
240TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
SFCType )
241TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
TaylorType )
242TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
CacheTaylorType )
243TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
RadType )
244TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
Rad2Type )
245TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Conversion, OtherConversions,
RadVecType )
247int main(
int argc,
char* argv[] ) {
248 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
250 return Teuchos::UnitTestRepository::runUnitTestsFromMain(argc, argv);
Sacado::Fad::SLFad< double, global_fad_size > Fad_SLFadType
bool test_ad_conversions(Teuchos::FancyOStream &out)
Sacado::Fad::ViewFad< double, global_fad_size, 1, Fad_DFadType > Fad_VFadType
Sacado::Fad::DFad< double > Fad_DFadType
Sacado::Fad::DVFad< double > Fad_DVFadType
Sacado::Fad::SFad< double, global_fad_size > Fad_SFadType
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Conversion, ADConversions, AD)
Sacado::Fad::SimpleFad< double > Fad_SimpleFadType
const int global_fad_size
TEUCHOS_UNIT_TEST(Conversion, IsConvertible)
Fad specializations for Teuchos::BLAS wrappers.
Templated flop counter class.
Forward-mode AD class using dynamic memory allocation.
Determine whether a given type is a view.
F::template apply< A1, A2, A3, A4, A5 >::type type