32 #ifndef LOGICALSPARSEUNITTESTS_HPP
33 #define LOGICALSPARSEUNITTESTS_HPP
43 #include <cppunit/extensions/HelperMacros.h>
45 #define BINARY_OP_TEST(TESTNAME,OP) \
47 c_dfad = a_dfad OP b_dfad; \
48 c_ls = a_ls OP b_ls; \
49 compareFads(c_dfad, c_ls); \
51 double val = urand.number(); \
52 c_dfad = a_dfad OP val; \
54 compareFads(c_dfad, c_ls); \
56 c_dfad = val OP b_dfad; \
58 compareFads(c_dfad, c_ls); \
61 #define RELOP_TEST(TESTNAME,OP) \
63 bool r1 = a_dfad OP b_dfad; \
64 bool r2 = a_ls OP b_ls; \
65 CPPUNIT_ASSERT(r1 == r2); \
67 double val = urand.number(); \
70 CPPUNIT_ASSERT(r1 == r2); \
74 CPPUNIT_ASSERT(r1 == r2); \
77 #define BINARY_FUNC_TEST(TESTNAME,FUNC) \
79 c_dfad = FUNC (a_dfad,b_dfad); \
80 c_ls = FUNC (a_ls,b_ls); \
81 compareFads(c_dfad, c_ls); \
83 double val = urand.number(); \
84 c_dfad = FUNC (a_dfad,val); \
85 c_ls = FUNC (a_ls,val); \
86 compareFads(c_dfad, c_ls); \
88 c_dfad = FUNC (val,b_dfad); \
89 c_ls = FUNC (val,b_ls); \
90 compareFads(c_dfad, c_ls); \
93 #define UNARY_OP_TEST(TESTNAME,OP) \
97 compareFads(c_dfad, c_ls); \
100 #define UNARY_FUNC_TEST(TESTNAME,FUNC) \
102 c_dfad = FUNC (a_dfad); \
103 c_ls = FUNC (a_ls); \
104 compareFads(c_dfad, c_ls); \
107 #define UNARY_ASSIGNOP_TEST(TESTNAME,OP) \
111 compareFads(c_dfad, c_ls); \
113 double val = urand.number(); \
116 compareFads(c_dfad, c_ls); \
178 double relative_tolerance);
237 template <
typename ScalarT>
239 ScalarT t1 = 3. * a +
sin(b) /
log(
fabs(a - b * 7.));
245 t1 /=
cosh(b - 0.7) + 7.*
sinh(t1 + 0.8)*
tanh(9./a) - 9.;
262 aa_dfad = aa_dfad +
b_dfad;
263 aa_ls = aa_ls +
b_ls;
272 aa_dfad = aa_dfad -
b_dfad;
273 aa_ls = aa_ls -
b_ls;
282 aa_dfad = aa_dfad *
b_dfad;
283 aa_ls = aa_ls *
b_ls;
292 aa_dfad = aa_dfad /
b_dfad;
293 aa_ls = aa_ls /
b_ls;
316 #endif // LOGICALSPARSEUNITTESTS_HPP
void compareDoubles(double a, double b)
UNARY_OP_TEST(testUnaryPlus,+)
void compareDx(double a, bool b)
LogicalSparseOpsUnitTest()
RELOP_TEST(testEquals,==)
Sacado::Fad::DFad< double > DFadType
void compareBools(bool a, bool b)
CPPUNIT_TEST(testAddition)
KOKKOS_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
CPPUNIT_TEST_SUITE(LogicalSparseOpsUnitTest)
ScalarT composite1(const ScalarT &a, const ScalarT &b)
UNARY_ASSIGNOP_TEST(testPlusEquals,+=)
Sacado::LFad::LogicalSparse< double, bool > LSType
UNARY_FUNC_TEST(testExp, exp)
Sacado::Random< double > urand
BINARY_OP_TEST(testAddition,+)
BINARY_FUNC_TEST(testPow, pow)
void compareFads(const DFadType &x_dfad, const LSType &x_ls)