Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TayUnitTests.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef TAYLORUNITTESTS_HPP
31 #define TAYLORUNITTESTS_HPP
32 
33 // ADOL-C includes
34 #include "adolc/adouble.h"
35 #include "adolc/interfaces.h"
36 
37 // Sacado includes
38 #include "Sacado_No_Kokkos.hpp"
39 #include "Sacado_Random.hpp"
40 
41 inline adouble max(const adouble& a, const adouble& b) { return fmax(a,b); }
42 inline adouble max(const adouble& a, double v) { return fmax(a,v); }
43 inline adouble max(double v, const adouble& b) { return fmax(v,b); }
44 inline adouble min(const adouble& a, const adouble& b) { return fmin(a,b); }
45 inline adouble min(const adouble& a, double v) { return fmin(a,v); }
46 inline adouble min(double v, const adouble& b) { return fmin(v,b); }
47 
48 // Cppunit includes
49 #include <cppunit/extensions/HelperMacros.h>
50 
51 #define COMPARE_DOUBLES(a, b) \
52  CPPUNIT_ASSERT( fabs(a-b) < tol_a + tol_r*fabs(a) );
53 
54 #define COMPARE_POLYS(x_dtay, x_adolc) \
55  CPPUNIT_ASSERT(x_dtay.degree() == d); \
56  for (int i=0; i<=d; i++) { \
57  COMPARE_DOUBLES(x_dtay.coeff(i), x_adolc[i]); \
58  } \
59  ;
60 
61 #define COMPARE_TAYS(x_dtay, y_dtay) \
62  CPPUNIT_ASSERT(x_dtay.degree() == y_dtay.degree()); \
63  for (int i=0; i<=x_dtay.degree(); i++) { \
64  COMPARE_DOUBLES(x_dtay.coeff(i), y_dtay.coeff(i)); \
65  } \
66  ;
67 
68 #define BINARY_OP2_TEST(TESTNAME,OP) \
69  void TESTNAME () { \
70  c_dtay = a_dtay OP b_dtay; \
71  trace_on(0); \
72  adouble aa, ab, ac; \
73  aa <<= X[0][0]; \
74  ab <<= X[1][0]; \
75  ac = aa OP ab; \
76  ac >>= Y[0][0]; \
77  trace_off(); \
78  forward(0,1,2,d,0,X,Y); \
79  COMPARE_POLYS(c_dtay,Y[0]); \
80  }
81 
82 #define BINARY_OPRC_TEST(TESTNAME,OP) \
83  void TESTNAME () { \
84  double val = urand.number(); \
85  c_dtay = a_dtay OP val; \
86  trace_on(0); \
87  adouble aa, ac; \
88  aa <<= X[0][0]; \
89  ac = aa OP val; \
90  ac >>= Y[0][0]; \
91  trace_off(); \
92  forward(0,1,1,d,0,X,Y); \
93  COMPARE_POLYS(c_dtay,Y[0]); \
94  }
95 
96 #define BINARY_OPLC_TEST(TESTNAME,OP) \
97  void TESTNAME () { \
98  double val = urand.number(); \
99  c_dtay = val OP a_dtay; \
100  trace_on(0); \
101  adouble aa, ac; \
102  aa <<= X[0][0]; \
103  ac = val OP aa; \
104  ac >>= Y[0][0]; \
105  trace_off(); \
106  forward(0,1,1,d,0,X,Y); \
107  COMPARE_POLYS(c_dtay,Y[0]); \
108  }
109 
110 #define BINARY_OP_TEST(TESTNAME,OP) \
111  BINARY_OP2_TEST(TESTNAME,OP); \
112  BINARY_OPLC_TEST(TESTNAME ## LeftConstant,OP); \
113  BINARY_OPRC_TEST(TESTNAME ## RightConstant,OP)
114 
115 #define CPPUNIT_BINARY_OP_TEST(TESTNAME) \
116  CPPUNIT_TEST(TESTNAME); \
117  CPPUNIT_TEST(TESTNAME ## LeftConstant); \
118  CPPUNIT_TEST(TESTNAME ## RightConstant)
119 
120 #define RELOP_OP2_TEST(TESTNAME,OP) \
121  void TESTNAME () { \
122  bool r1 = a_dtay OP b_dtay; \
123  bool r2 = a_dtay.coeff(0) OP b_dtay.coeff(0); \
124  CPPUNIT_ASSERT(r1 == r2); \
125  }
126 
127 #define RELOP_OPLC_TEST(TESTNAME,OP) \
128  void TESTNAME () { \
129  double val = urand.number(); \
130  bool r1 = val OP b_dtay; \
131  bool r2 = val OP b_dtay.coeff(0); \
132  CPPUNIT_ASSERT(r1 == r2); \
133  }
134 
135 #define RELOP_OPRC_TEST(TESTNAME,OP) \
136  void TESTNAME () { \
137  double val = urand.number(); \
138  bool r1 = a_dtay OP val; \
139  bool r2 = a_dtay.coeff(0) OP val; \
140  CPPUNIT_ASSERT(r1 == r2); \
141  }
142 
143 #define RELOP_OP_TEST(TESTNAME,OP) \
144  RELOP_OP2_TEST(TESTNAME,OP); \
145  RELOP_OPLC_TEST(TESTNAME ## LeftConstant,OP); \
146  RELOP_OPRC_TEST(TESTNAME ## RightConstant,OP)
147 
148 #define CPPUNIT_RELOP_OP_TEST(TESTNAME) \
149  CPPUNIT_TEST(TESTNAME); \
150  CPPUNIT_TEST(TESTNAME ## LeftConstant); \
151  CPPUNIT_TEST(TESTNAME ## RightConstant)
152 
153 #define BINARY_FUNC2_TEST(TESTNAME,FUNC) \
154  void TESTNAME () { \
155  c_dtay = FUNC (a_dtay, b_dtay); \
156  trace_on(0); \
157  adouble aa, ab, ac; \
158  aa <<= X[0][0]; \
159  ab <<= X[1][0]; \
160  ac = FUNC (aa, ab); \
161  ac >>= Y[0][0]; \
162  trace_off(); \
163  forward(0,1,2,d,0,X,Y); \
164  COMPARE_POLYS(c_dtay,Y[0]); \
165  }
166 
167 #define BINARY_FUNCRC_TEST(TESTNAME,FUNC) \
168  void TESTNAME () { \
169  double val = urand.number(); \
170  c_dtay = FUNC (a_dtay, val); \
171  trace_on(0); \
172  adouble aa, ac; \
173  aa <<= X[0][0]; \
174  ac = FUNC (aa, val); \
175  ac >>= Y[0][0]; \
176  trace_off(); \
177  forward(0,1,1,d,0,X,Y); \
178  COMPARE_POLYS(c_dtay,Y[0]); \
179  }
180 
181 #define BINARY_FUNCLC_TEST(TESTNAME,FUNC) \
182  void TESTNAME () { \
183  double val = urand.number(); \
184  c_dtay = FUNC (val, a_dtay); \
185  trace_on(0); \
186  adouble aa, ac; \
187  aa <<= X[0][0]; \
188  ac = FUNC (val, aa); \
189  ac >>= Y[0][0]; \
190  trace_off(); \
191  forward(0,1,1,d,0,X,Y); \
192  COMPARE_POLYS(c_dtay,Y[0]); \
193  }
194 
195 #define BINARY_FUNC_TEST(TESTNAME,FUNC) \
196  BINARY_FUNC2_TEST(TESTNAME,FUNC); \
197  BINARY_FUNCLC_TEST(TESTNAME ## LeftConstant,FUNC); \
198  BINARY_FUNCRC_TEST(TESTNAME ## RightConstant,FUNC)
199 
200 #define CPPUNIT_BINARY_FUNC_TEST(TESTNAME) \
201  CPPUNIT_TEST(TESTNAME); \
202  CPPUNIT_TEST(TESTNAME ## LeftConstant); \
203  CPPUNIT_TEST(TESTNAME ## RightConstant)
204 
205 #define UNARY_OP_TEST(TESTNAME,OP) \
206  void TESTNAME () { \
207  c_dtay = OP a_dtay; \
208  trace_on(0); \
209  adouble aa, ac; \
210  aa <<= X[0][0]; \
211  ac = OP aa; \
212  ac >>= Y[0][0]; \
213  trace_off(); \
214  forward(0,1,1,d,0,X,Y); \
215  COMPARE_POLYS(c_dtay,Y[0]); \
216  }
217 
218 #define UNARY_FUNC_TEST(TESTNAME,FUNC) \
219  void TESTNAME () { \
220  c_dtay = FUNC (a_dtay); \
221  trace_on(0); \
222  adouble aa, ac; \
223  aa <<= X[0][0]; \
224  ac = FUNC (aa); \
225  ac >>= Y[0][0]; \
226  trace_off(); \
227  forward(0,1,1,d,0,X,Y); \
228  COMPARE_POLYS(c_dtay,Y[0]); \
229  }
230 
231 #define UNARY_ASSIGNOP2_TEST(TESTNAME,OP) \
232  void TESTNAME () { \
233  c_dtay = a_dtay; \
234  c_dtay OP b_dtay; \
235  trace_on(0); \
236  adouble aa, ab, ac; \
237  aa <<= X[0][0]; \
238  ab <<= X[1][0]; \
239  ac = aa; \
240  ac OP ab; \
241  ac >>= Y[0][0]; \
242  trace_off(); \
243  forward(0,1,2,d,0,X,Y); \
244  COMPARE_POLYS(c_dtay,Y[0]); \
245  }
246 
247 #define UNARY_ASSIGNOPRC_TEST(TESTNAME,OP) \
248  void TESTNAME () { \
249  double val = urand.number(); \
250  c_dtay = a_dtay; \
251  c_dtay OP val; \
252  trace_on(0); \
253  adouble aa, ac; \
254  aa <<= X[0][0]; \
255  ac = aa; \
256  ac OP val; \
257  ac >>= Y[0][0]; \
258  trace_off(); \
259  forward(0,1,1,d,0,X,Y); \
260  COMPARE_POLYS(c_dtay,Y[0]); \
261  }
262 
263 #define UNARY_ASSIGNOPLC_TEST(TESTNAME,OP) \
264  void TESTNAME () { \
265  double val = urand.number(); \
266  c_dtay = val; \
267  c_dtay OP a_dtay; \
268  trace_on(0); \
269  adouble aa, ac; \
270  aa <<= X[0][0]; \
271  ac = val; \
272  ac OP aa; \
273  ac >>= Y[0][0]; \
274  trace_off(); \
275  forward(0,1,1,d,0,X,Y); \
276  COMPARE_POLYS(c_dtay,Y[0]); \
277  }
278 
279 #define UNARY_ASSIGNOP_TEST(TESTNAME,OP) \
280  UNARY_ASSIGNOP2_TEST(TESTNAME,OP); \
281  UNARY_ASSIGNOPLC_TEST(TESTNAME ## LeftConstant,OP); \
282  UNARY_ASSIGNOPRC_TEST(TESTNAME ## RightConstant,OP)
283 
284 #define CPPUNIT_UNARY_ASSIGNOP_TEST(TESTNAME) \
285  CPPUNIT_TEST(TESTNAME); \
286  CPPUNIT_TEST(TESTNAME ## LeftConstant); \
287  CPPUNIT_TEST(TESTNAME ## RightConstant)
288 
289 // A class for testing each Taylor operation
290 template <class TaylorType>
291 class TaylorOpsUnitTest : public CppUnit::TestFixture {
292 
294 
295  CPPUNIT_BINARY_OP_TEST(testAddition);
296  CPPUNIT_BINARY_OP_TEST(testSubtraction);
297  CPPUNIT_BINARY_OP_TEST(testMultiplication);
298  CPPUNIT_BINARY_OP_TEST(testDivision);
299 
300  CPPUNIT_RELOP_OP_TEST(testEquals);
301  CPPUNIT_RELOP_OP_TEST(testNotEquals);
302  CPPUNIT_RELOP_OP_TEST(testLessThanOrEquals);
303  CPPUNIT_RELOP_OP_TEST(testGreaterThanOrEquals);
304  CPPUNIT_RELOP_OP_TEST(testLessThan);
305  CPPUNIT_RELOP_OP_TEST(testGreaterThan);
306 
307  CPPUNIT_BINARY_FUNC_TEST(testPow);
308  CPPUNIT_BINARY_FUNC_TEST(testMax);
309  CPPUNIT_BINARY_FUNC_TEST(testMin);
310 
311  CPPUNIT_TEST(testUnaryPlus);
312  CPPUNIT_TEST(testUnaryMinus);
313 
314  CPPUNIT_TEST(testExp);
315  CPPUNIT_TEST(testLog);
316  CPPUNIT_TEST(testLog10);
317  CPPUNIT_TEST(testSqrt);
318  CPPUNIT_TEST(testCos);
319  CPPUNIT_TEST(testSin);
320  CPPUNIT_TEST(testTan);
321  CPPUNIT_TEST(testACos);
322  CPPUNIT_TEST(testASin);
323  CPPUNIT_TEST(testATan);
324  CPPUNIT_TEST(testCosh);
325  CPPUNIT_TEST(testSinh);
326  CPPUNIT_TEST(testTanh);
327  CPPUNIT_TEST(testFAbs);
328 
329  CPPUNIT_UNARY_ASSIGNOP_TEST(testPlusEquals);
330  CPPUNIT_UNARY_ASSIGNOP_TEST(testMinusEquals);
331  CPPUNIT_UNARY_ASSIGNOP_TEST(testTimesEquals);
332  CPPUNIT_UNARY_ASSIGNOP_TEST(testDivideEquals);
333 
335 
338 
340 
341 public:
342 
344 
345  TaylorOpsUnitTest(int degree, double absolute_tolerance,
346  double relative_tolerance);
347 
349 
350  void setUp();
351 
352  void tearDown();
353 
354  BINARY_OP_TEST(testAddition, +);
355  BINARY_OP_TEST(testSubtraction, -);
356  BINARY_OP_TEST(testMultiplication, *);
357  BINARY_OP_TEST(testDivision, /);
358 
359  RELOP_OP_TEST(testEquals, ==);
360  RELOP_OP_TEST(testNotEquals, !=);
361  RELOP_OP_TEST(testLessThanOrEquals, <=);
362  RELOP_OP_TEST(testGreaterThanOrEquals, >=);
363  RELOP_OP_TEST(testLessThan, <);
364  RELOP_OP_TEST(testGreaterThan, >);
365 
366  BINARY_FUNC_TEST(testPow, pow);
367  BINARY_FUNC_TEST(testMax, max);
368  BINARY_FUNC_TEST(testMin, min);
369 
370  UNARY_OP_TEST(testUnaryPlus, +);
371  UNARY_OP_TEST(testUnaryMinus, -);
372 
373  UNARY_FUNC_TEST(testExp, exp);
374  UNARY_FUNC_TEST(testLog, log);
375  UNARY_FUNC_TEST(testLog10, log10);
376  UNARY_FUNC_TEST(testSqrt, sqrt);
377  UNARY_FUNC_TEST(testCos, cos);
378  UNARY_FUNC_TEST(testSin, sin);
379  UNARY_FUNC_TEST(testTan, tan);
380  UNARY_FUNC_TEST(testACos, acos);
381  UNARY_FUNC_TEST(testASin, asin);
382  UNARY_FUNC_TEST(testATan, atan);
383  UNARY_FUNC_TEST(testCosh, cosh);
384  UNARY_FUNC_TEST(testSinh, sinh);
385  UNARY_FUNC_TEST(testTanh, tanh);
386  UNARY_FUNC_TEST(testFAbs, fabs);
387 
388  UNARY_ASSIGNOP_TEST(testPlusEquals, +=);
389  UNARY_ASSIGNOP_TEST(testMinusEquals, -=);
390  UNARY_ASSIGNOP_TEST(testTimesEquals, *=);
391  UNARY_ASSIGNOP_TEST(testDivideEquals, /=);
392 
393  template <typename ScalarT>
394  ScalarT composite1(const ScalarT& a, const ScalarT& b) {
395  ScalarT t1 = 3. * a + sin(b) / log(fabs(a - b * 7.));
396  ScalarT t2 = 1.0e3;
397  ScalarT t3 = 5.7e4;
398  ScalarT t4 = 3.2e5;
399  t1 *= cos(a + exp(t1)) / 6. - tan(t1*sqrt(fabs(a * log10(fabs(b)))));
400  t1 -= acos((6.+asin(pow(fabs(a),b)/t2))/t3) * asin(pow(fabs(b),2.)*1.0/t4) * atan((b*pow(2.,log(fabs(a))))/(t3*t4));
401  t1 /= cosh(b - 0.7) + 7.*sinh(t1 + 0.8)*tanh(9./(a+1.)) - 9.;
402  t1 += pow(fabs(a*4.),b-8.)/cos(a*b*a);
403 
404  return t1;
405 }
406 
407  void testComposite1() {
409  trace_on(0);
410  adouble aa, ab, ac;
411  aa <<= X[0][0];
412  ab <<= X[1][0];
413  ac = composite1(aa,ab);
414  ac >>= Y[0][0];
415  trace_off();
416  forward(0,1,2,d,0,X,Y);
417  COMPARE_POLYS(c_dtay,Y[0]);
418  }
419 
420  void testDiff1() {
421  TaylorType a_diff1 = diff(a_dtay);
422  TaylorType a_diff2(d-1);
423  for (int i=1; i<=d; ++i)
424  a_diff2.fastAccessCoeff(i-1) = a_dtay.fastAccessCoeff(i)*i;
425  COMPARE_TAYS(a_diff1, a_diff2);
426  }
427 
428  void testDiff3() {
429  TaylorType a_diff1 = diff(a_dtay, 3);
430  TaylorType a_diff2 = diff( diff( diff(a_dtay) ) );
431  COMPARE_TAYS(a_diff1, a_diff2);
432  }
433 
434  void print_poly(double *x);
435 
436  void print_diff(const TaylorType& x_dtay, double* x_adolc);
437 
438 protected:
439 
440  // Taylor variables
442 
443  // ADOL-C arrays
444  double **X, **Y;
445 
446  // Random number generator
448 
449  // Degree of polynomials
450  int d;
451 
452  // Tolerances to which fad objects should be the same
453  double tol_a, tol_r;
454 
455 }; // class TaylorOpsUnitTest
456 
457 template <class TaylorType>
459  urand(), d(5), tol_a(1.0e-11), tol_r(1.0e-10)
460 {
461  X = new double*[2];
462  X[0] = new double[d+1];
463  X[1] = new double[d+1];
464 
465  Y = new double*[1];
466  Y[0] = new double[d+1];
467 }
468 
469 template <class TaylorType>
471  double absolute_tolerance,
472  double relative_tolerance) :
473  urand(),
474  d(degree),
475  tol_a(absolute_tolerance),
476  tol_r(relative_tolerance)
477 {
478  X = new double*[2];
479  X[0] = new double[d+1];
480  X[1] = new double[d+1];
481 
482  Y = new double*[1];
483  Y[0] = new double[d+1];
484 }
485 
486 template <class TaylorType>
488 {
489  delete [] X[1];
490  delete [] X[0];
491  delete [] X;
492 
493  delete [] Y[0];
494  delete [] Y;
495 }
496 
497 template <class TaylorType>
499  double val;
500 
501  a_dtay = TaylorType(d,0.0);
502  b_dtay = TaylorType(d,0.0);
503 
504  for (int i=0; i<=d; i++) {
505  val = urand.number();
506  a_dtay.fastAccessCoeff(i) = val;
507  X[0][i] = val;
508 
509  val = urand.number();
510  b_dtay.fastAccessCoeff(i) = val;
511  X[1][i] = val;
512 
513  Y[0][i] = 0.0;
514  }
515 }
516 
517 template <class TaylorType>
519 
520 template <class TaylorType>
522  std::cout.setf(std::ios::fixed,std::ios::floatfield);
523  std::cout.width(12);
524  std::cout << "[";
525 
526  for (int i=0; i<=d; i++) {
527  std::cout.width(12);
528  std::cout << x[i];
529  }
530 
531  std::cout << "]\n";
532 }
533 
534 template <class TaylorType>
536  double *x) {
537  std::cout.setf(std::ios::scientific,std::ios::floatfield);
538  //std::cout.width(12);
539  std::cout << "[";
540 
541  for (int i=0; i<=d; i++) {
542  //std::cout.width(12);
543  std::cout << x_dtay.coeff(i) - x[i] << " ";
544  }
545 
546  std::cout << "]\n";
547 }
548 
550 // CacheTaylor unit tests that don't test max/min, since this class
551 // doesn't define those yet
553  public TaylorOpsUnitTest< Sacado::Tay::CacheTaylor<double> > {
554 
556 
557  CPPUNIT_BINARY_OP_TEST(testAddition);
558  CPPUNIT_BINARY_OP_TEST(testSubtraction);
559  CPPUNIT_BINARY_OP_TEST(testMultiplication);
560  CPPUNIT_BINARY_OP_TEST(testDivision);
561 
562  CPPUNIT_RELOP_OP_TEST(testEquals);
563  CPPUNIT_RELOP_OP_TEST(testNotEquals);
564  CPPUNIT_RELOP_OP_TEST(testLessThanOrEquals);
565  CPPUNIT_RELOP_OP_TEST(testGreaterThanOrEquals);
566  CPPUNIT_RELOP_OP_TEST(testLessThan);
567  CPPUNIT_RELOP_OP_TEST(testGreaterThan);
568 
569  CPPUNIT_BINARY_FUNC_TEST(testPow);
572 
573  CPPUNIT_TEST(testUnaryPlus);
574  CPPUNIT_TEST(testUnaryMinus);
575 
576  CPPUNIT_TEST(testExp);
577  CPPUNIT_TEST(testLog);
578  CPPUNIT_TEST(testLog10);
579  CPPUNIT_TEST(testSqrt);
580  CPPUNIT_TEST(testCos);
581  CPPUNIT_TEST(testSin);
582  CPPUNIT_TEST(testTan);
583  CPPUNIT_TEST(testACos);
584  CPPUNIT_TEST(testASin);
585  CPPUNIT_TEST(testATan);
586  CPPUNIT_TEST(testCosh);
587  CPPUNIT_TEST(testSinh);
588  CPPUNIT_TEST(testTanh);
589  CPPUNIT_TEST(testFAbs);
590 
591  CPPUNIT_UNARY_ASSIGNOP_TEST(testPlusEquals);
592  CPPUNIT_UNARY_ASSIGNOP_TEST(testMinusEquals);
593  CPPUNIT_UNARY_ASSIGNOP_TEST(testTimesEquals);
594  CPPUNIT_UNARY_ASSIGNOP_TEST(testDivideEquals);
595 
597 
599 
600 public:
601 
603 
604  CacheTaylorOpsUnitTest(int degree, double absolute_tolerance,
605  double relative_tolerance) :
606  TaylorOpsUnitTest< Sacado::Tay::CacheTaylor<double> >(degree,
607  absolute_tolerance,
608  relative_tolerance) {}
609 
611 
612  void testMax() {}
613  void testMin() {}
614 
615 };
616 
617 #endif // TAYLORUNITTESTS_HPP
CPPUNIT_BINARY_FUNC_TEST(testPow)
CPPUNIT_UNARY_ASSIGNOP_TEST(testPlusEquals)
asin(expr.val())
BINARY_OP_TEST(testAddition,+)
cosh(expr.val())
CPPUNIT_TEST(testUnaryPlus)
CPPUNIT_TEST_SUITE(CacheTaylorOpsUnitTest)
BINARY_FUNC_TEST(testPow, pow)
UNARY_OP_TEST(testUnaryPlus,+)
CPPUNIT_RELOP_OP_TEST(testEquals)
CPPUNIT_TEST(testUnaryPlus)
atan(expr.val())
Sacado::Random< double > urand
#define COMPARE_TAYS(x_dtay, y_dtay)
Sacado::Tay::Taylor< double > TaylorType
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)
CacheTaylorOpsUnitTest(int degree, double absolute_tolerance, double relative_tolerance)
CPPUNIT_UNARY_ASSIGNOP_TEST(testPlusEquals)
expr val()
CPPUNIT_BINARY_OP_TEST(testAddition)
tanh(expr.val())
ScalarT composite1(const ScalarT &a, const ScalarT &b)
CacheTaylor< T > diff(const CacheTaylor< T > &x, int n=1)
Compute Taylor series of n-th derivative of x.
T & fastAccessCoeff(int i)
Returns degree i term without bounds checking.
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
CPPUNIT_RELOP_OP_TEST(testEquals)
sqrt(expr.val())
sinh(expr.val())
tan(expr.val())
#define COMPARE_POLYS(x_dtay, x_adolc)
void print_diff(const TaylorType &x_dtay, double *x_adolc)
const T * coeff() const
Returns Taylor coefficient array.
sin(expr.val())
log(expr.val())
void print_poly(double *x)
CPPUNIT_BINARY_FUNC_TEST(testPow)
UNARY_FUNC_TEST(testExp, exp)
acos(expr.val())
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
CPPUNIT_TEST_SUITE(TaylorOpsUnitTest)
RELOP_OP_TEST(testEquals,==)
UNARY_ASSIGNOP_TEST(testPlusEquals,+=)
exp(expr.val())
fabs(expr.val())
log10(expr.val())
cos(expr.val())
CPPUNIT_BINARY_OP_TEST(testAddition)