Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tradoptest_38.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 /* Try to test all combinations of types and operations */
11 
12 
13 
14 #define ADT_RAD Sacado::Rad::
15 
16 
17 
18 #include "Sacado_trad.hpp"
19 
20 #include <cstdio>
21 
22 using std::printf;
23 
24 
25 
26 typedef ADT_RAD IndepADvar<double> AI;
27 
28 typedef ADT_RAD ADvar<double> A;
29 
30 typedef ADT_RAD ConstADvar<double> C;
31 
32 typedef ADT_RAD ADvari<double> Ai;
33 
34 typedef const ADT_RAD IndepADvar<double> cAI;
35 
36 typedef const ADT_RAD ADvar<double> cA;
37 
38 typedef const ADT_RAD ConstADvar<double> cC;
39 
40 typedef const ADT_RAD ADvari<double> cAi;
41 
42 static int rc;
43 
44 
45 
46 /* This is to be run through an awk program that changes lines */
47 
48 /* with "BINTEST" or "UNOPTEST" at the beginning of the line into */
49 
50 /* a the desired C++ (which we can then inspect). */
51 
52 
53 
54  void
55 
56 botch(const char *what, double wanted, double got)
57 
58 {
59 
60  printf("%s: expected %g, got %g, diff = %.2g\n", what, wanted, got, wanted-got);
61 
62  rc = 1;
63 
64  }
65 
66 
67 
68  const double tol = 5e-16;
69 
70 
71 
72  int
73 
74 differ(double a, double b)
75 
76 {
77 
78  double d = a - b;
79 
80  if (d < 0.)
81 
82  d = -d;
83 
84  if (a < 0.)
85 
86  a = -a;
87 
88  if (b < 0.)
89 
90  b = -b;
91 
92  if (a < b)
93 
94  a = b;
95 
96  if (a > 0.)
97 
98  d /= a;
99 
100  return d > tol;
101 
102  }
103 
104 
105 
106 #ifndef RAD_EQ_ALIAS
107 
108 #define Plus_dx 1.
109 
110 #else
111 
112 #ifdef RAD_AUTO_AD_Const
113 
114 #define Plus_dx 1.
115 
116 #else
117 
118 #define Plus_dx 0.
119 
120 #endif
121 
122 #endif
123 
124 
125 
126  int
127 
128 main(void)
129 
130 {
131 
132  AI xAI, yAI;
133 
134  A fA, xA, yA;
135 
136  C xC, yC;
137 
138  double dx, dy, f, xd, yd;
139 
140  long xL, yL;
141 
142  int xi, yi;
143 
144 
145 
146  rc = 0;
147 
148 
149  /**** Test of > ****/
150 
151  xd = 4.; yd = 3.; f = 1.; dx = 0.; dy = 0.;
152  xAI = xd;
153  yAI = yd;
154  fA = xAI > yAI;
155  A::Gradcomp();
156  if (differ(fA.val(), f)) botch("fA = xAI > yAI", f, fA.val());
157  else if (differ(xAI.adj(), dx)) botch("d xAI > yAI/dx", dx, xAI.adj());
158  else if (differ(yAI.adj(), dy)) botch("d xAI > yAI/dy", dy, yAI.adj());
159  {
160  A::aval_reset();
161  cAI xcAI(xd);
162  yAI = yd;
163  fA = xcAI > yAI;
164  A::Gradcomp();
165  if (differ(fA.val(), f)) botch("fA = xcAI > yAI", f, fA.val());
166  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yAI/dx", dx, xcAI.adj());
167  else if (differ(yAI.adj(), dy)) botch("d xcAI > yAI/dy", dy, yAI.adj());
168  }
169  {
170  A::aval_reset();
171  xAI = xd;
172  cAI ycAI(yd);
173  fA = xAI > ycAI;
174  A::Gradcomp();
175  if (differ(fA.val(), f)) botch("fA = xAI > ycAI", f, fA.val());
176  else if (differ(xAI.adj(), dx)) botch("d xAI > ycAI/dx", dx, xAI.adj());
177  else if (differ(ycAI.adj(), dy)) botch("d xAI > ycAI/dy", dy, ycAI.adj());
178  }
179  {
180  A::aval_reset();
181  cAI xcAI(xd);
182  cAI ycAI(yd);
183  fA = xcAI > ycAI;
184  A::Gradcomp();
185  if (differ(fA.val(), f)) botch("fA = xcAI > ycAI", f, fA.val());
186  else if (differ(xcAI.adj(), dx)) botch("d xcAI > ycAI/dx", dx, xcAI.adj());
187  else if (differ(ycAI.adj(), dy)) botch("d xcAI > ycAI/dy", dy, ycAI.adj());
188  }
189  xAI = xd;
190  yA = yd;
191  fA = xAI > yA;
192  A::Gradcomp();
193  if (differ(fA.val(), f)) botch("fA = xAI > yA", f, fA.val());
194  else if (differ(xAI.adj(), dx)) botch("d xAI > yA/dx", dx, xAI.adj());
195  else if (differ(yA.adj(), dy)) botch("d xAI > yA/dy", dy, yA.adj());
196  {
197  A::aval_reset();
198  cAI xcAI(xd);
199  yA = yd;
200  fA = xcAI > yA;
201  A::Gradcomp();
202  if (differ(fA.val(), f)) botch("fA = xcAI > yA", f, fA.val());
203  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yA/dx", dx, xcAI.adj());
204  else if (differ(yA.adj(), dy)) botch("d xcAI > yA/dy", dy, yA.adj());
205  }
206  {
207  A::aval_reset();
208  xAI = xd;
209  cA ycA(yd);
210  fA = xAI > ycA;
211  A::Gradcomp();
212  if (differ(fA.val(), f)) botch("fA = xAI > ycA", f, fA.val());
213  else if (differ(xAI.adj(), dx)) botch("d xAI > ycA/dx", dx, xAI.adj());
214  else if (differ(ycA.adj(), dy)) botch("d xAI > ycA/dy", dy, ycA.adj());
215  }
216  {
217  A::aval_reset();
218  cAI xcAI(xd);
219  cA ycA(yd);
220  fA = xcAI > ycA;
221  A::Gradcomp();
222  if (differ(fA.val(), f)) botch("fA = xcAI > ycA", f, fA.val());
223  else if (differ(xcAI.adj(), dx)) botch("d xcAI > ycA/dx", dx, xcAI.adj());
224  else if (differ(ycA.adj(), dy)) botch("d xcAI > ycA/dy", dy, ycA.adj());
225  }
226  xAI = xd;
227  yC = yd;
228  fA = xAI > yC;
229  A::Gradcomp();
230  if (differ(fA.val(), f)) botch("fA = xAI > yC", f, fA.val());
231  else if (differ(xAI.adj(), dx)) botch("d xAI > yC/dx", dx, xAI.adj());
232  else if (differ(yC.adj(), dy)) botch("d xAI > yC/dy", dy, yC.adj());
233  {
234  A::aval_reset();
235  cAI xcAI(xd);
236  yC = yd;
237  fA = xcAI > yC;
238  A::Gradcomp();
239  if (differ(fA.val(), f)) botch("fA = xcAI > yC", f, fA.val());
240  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yC/dx", dx, xcAI.adj());
241  else if (differ(yC.adj(), dy)) botch("d xcAI > yC/dy", dy, yC.adj());
242  }
243  {
244  A::aval_reset();
245  xAI = xd;
246  cC ycC(yd);
247  fA = xAI > ycC;
248  A::Gradcomp();
249  if (differ(fA.val(), f)) botch("fA = xAI > ycC", f, fA.val());
250  else if (differ(xAI.adj(), dx)) botch("d xAI > ycC/dx", dx, xAI.adj());
251  else if (differ(ycC.adj(), dy)) botch("d xAI > ycC/dy", dy, ycC.adj());
252  }
253  {
254  A::aval_reset();
255  cAI xcAI(xd);
256  cC ycC(yd);
257  fA = xcAI > ycC;
258  A::Gradcomp();
259  if (differ(fA.val(), f)) botch("fA = xcAI > ycC", f, fA.val());
260  else if (differ(xcAI.adj(), dx)) botch("d xcAI > ycC/dx", dx, xcAI.adj());
261  else if (differ(ycC.adj(), dy)) botch("d xcAI > ycC/dy", dy, ycC.adj());
262  }
263  {
264  xAI = xd;
265  Ai yAi(yd);
266  fA = xAI > yAi;
267  A::Gradcomp();
268  if (differ(fA.val(), f)) botch("fA = xAI > yAi", f, fA.val());
269  else if (differ(xAI.adj(), dx)) botch("d xAI > yAi/dx", dx, xAI.adj());
270  else if (differ(yAi.aval, dy)) botch("d xAI > yAi/dy", dy, yAi.aval);
271  }
272  {
273  A::aval_reset();
274  cAI xcAI(xd);
275  Ai yAi(yd);
276  fA = xcAI > yAi;
277  A::Gradcomp();
278  if (differ(fA.val(), f)) botch("fA = xcAI > yAi", f, fA.val());
279  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yAi/dx", dx, xcAI.adj());
280  else if (differ(yAi.aval, dy)) botch("d xcAI > yAi/dy", dy, yAi.aval);
281  }
282  {
283  A::aval_reset();
284  xAI = xd;
285  cAi ycAi(yd);
286  fA = xAI > ycAi;
287  A::Gradcomp();
288  if (differ(fA.val(), f)) botch("fA = xAI > ycAi", f, fA.val());
289  else if (differ(xAI.adj(), dx)) botch("d xAI > ycAi/dx", dx, xAI.adj());
290  else if (differ(ycAi.aval, dy)) botch("d xAI > ycAi/dy", dy, ycAi.aval);
291  }
292  {
293  A::aval_reset();
294  cAI xcAI(xd);
295  cAi ycAi(yd);
296  fA = xcAI > ycAi;
297  A::Gradcomp();
298  if (differ(fA.val(), f)) botch("fA = xcAI > ycAi", f, fA.val());
299  else if (differ(xcAI.adj(), dx)) botch("d xcAI > ycAi/dx", dx, xcAI.adj());
300  else if (differ(ycAi.aval, dy)) botch("d xcAI > ycAi/dy", dy, ycAi.aval);
301  }
302  xAI = xd;
303  fA = xAI > yd;
304  A::Gradcomp();
305  if (differ(fA.val(), f)) botch("fA = xAI > yd", f, fA.val());
306  else if (differ(xAI.adj(), dx)) botch("d xAI > yd/dx", dx, xAI.adj());
307  {
308  A::aval_reset();
309  cAI xcAI(xd);
310  fA = xcAI > yd;
311  A::Gradcomp();
312  if (differ(fA.val(), f)) botch("fA = xcAI > yd", f, fA.val());
313  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yd/dx", dx, xcAI.adj());
314  }
315  xAI = xd;
316  yL = (long)yd;
317  fA = xAI > yL;
318  A::Gradcomp();
319  if (differ(fA.val(), f)) botch("fA = xAI > yL", f, fA.val());
320  else if (differ(xAI.adj(), dx)) botch("d xAI > yL/dx", dx, xAI.adj());
321  {
322  A::aval_reset();
323  cAI xcAI(xd);
324  yL = (long)yd;
325  fA = xcAI > yL;
326  A::Gradcomp();
327  if (differ(fA.val(), f)) botch("fA = xcAI > yL", f, fA.val());
328  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yL/dx", dx, xcAI.adj());
329  }
330  xAI = xd;
331  yi = (int)yd;
332  fA = xAI > yi;
333  A::Gradcomp();
334  if (differ(fA.val(), f)) botch("fA = xAI > yi", f, fA.val());
335  else if (differ(xAI.adj(), dx)) botch("d xAI > yi/dx", dx, xAI.adj());
336  {
337  A::aval_reset();
338  cAI xcAI(xd);
339  yi = (int)yd;
340  fA = xcAI > yi;
341  A::Gradcomp();
342  if (differ(fA.val(), f)) botch("fA = xcAI > yi", f, fA.val());
343  else if (differ(xcAI.adj(), dx)) botch("d xcAI > yi/dx", dx, xcAI.adj());
344  }
345  xA = xd;
346  yAI = yd;
347  fA = xA > yAI;
348  A::Gradcomp();
349  if (differ(fA.val(), f)) botch("fA = xA > yAI", f, fA.val());
350  else if (differ(xA.adj(), dx)) botch("d xA > yAI/dx", dx, xA.adj());
351  else if (differ(yAI.adj(), dy)) botch("d xA > yAI/dy", dy, yAI.adj());
352  {
353  A::aval_reset();
354  cA xcA(xd);
355  yAI = yd;
356  fA = xcA > yAI;
357  A::Gradcomp();
358  if (differ(fA.val(), f)) botch("fA = xcA > yAI", f, fA.val());
359  else if (differ(xcA.adj(), dx)) botch("d xcA > yAI/dx", dx, xcA.adj());
360  else if (differ(yAI.adj(), dy)) botch("d xcA > yAI/dy", dy, yAI.adj());
361  }
362  {
363  A::aval_reset();
364  xA = xd;
365  cAI ycAI(yd);
366  fA = xA > ycAI;
367  A::Gradcomp();
368  if (differ(fA.val(), f)) botch("fA = xA > ycAI", f, fA.val());
369  else if (differ(xA.adj(), dx)) botch("d xA > ycAI/dx", dx, xA.adj());
370  else if (differ(ycAI.adj(), dy)) botch("d xA > ycAI/dy", dy, ycAI.adj());
371  }
372  {
373  A::aval_reset();
374  cA xcA(xd);
375  cAI ycAI(yd);
376  fA = xcA > ycAI;
377  A::Gradcomp();
378  if (differ(fA.val(), f)) botch("fA = xcA > ycAI", f, fA.val());
379  else if (differ(xcA.adj(), dx)) botch("d xcA > ycAI/dx", dx, xcA.adj());
380  else if (differ(ycAI.adj(), dy)) botch("d xcA > ycAI/dy", dy, ycAI.adj());
381  }
382  xA = xd;
383  yA = yd;
384  fA = xA > yA;
385  A::Gradcomp();
386  if (differ(fA.val(), f)) botch("fA = xA > yA", f, fA.val());
387  else if (differ(xA.adj(), dx)) botch("d xA > yA/dx", dx, xA.adj());
388  else if (differ(yA.adj(), dy)) botch("d xA > yA/dy", dy, yA.adj());
389  {
390  A::aval_reset();
391  cA xcA(xd);
392  yA = yd;
393  fA = xcA > yA;
394  A::Gradcomp();
395  if (differ(fA.val(), f)) botch("fA = xcA > yA", f, fA.val());
396  else if (differ(xcA.adj(), dx)) botch("d xcA > yA/dx", dx, xcA.adj());
397  else if (differ(yA.adj(), dy)) botch("d xcA > yA/dy", dy, yA.adj());
398  }
399  {
400  A::aval_reset();
401  xA = xd;
402  cA ycA(yd);
403  fA = xA > ycA;
404  A::Gradcomp();
405  if (differ(fA.val(), f)) botch("fA = xA > ycA", f, fA.val());
406  else if (differ(xA.adj(), dx)) botch("d xA > ycA/dx", dx, xA.adj());
407  else if (differ(ycA.adj(), dy)) botch("d xA > ycA/dy", dy, ycA.adj());
408  }
409  {
410  A::aval_reset();
411  cA xcA(xd);
412  cA ycA(yd);
413  fA = xcA > ycA;
414  A::Gradcomp();
415  if (differ(fA.val(), f)) botch("fA = xcA > ycA", f, fA.val());
416  else if (differ(xcA.adj(), dx)) botch("d xcA > ycA/dx", dx, xcA.adj());
417  else if (differ(ycA.adj(), dy)) botch("d xcA > ycA/dy", dy, ycA.adj());
418  }
419  xA = xd;
420  yC = yd;
421  fA = xA > yC;
422  A::Gradcomp();
423  if (differ(fA.val(), f)) botch("fA = xA > yC", f, fA.val());
424  else if (differ(xA.adj(), dx)) botch("d xA > yC/dx", dx, xA.adj());
425  else if (differ(yC.adj(), dy)) botch("d xA > yC/dy", dy, yC.adj());
426  {
427  A::aval_reset();
428  cA xcA(xd);
429  yC = yd;
430  fA = xcA > yC;
431  A::Gradcomp();
432  if (differ(fA.val(), f)) botch("fA = xcA > yC", f, fA.val());
433  else if (differ(xcA.adj(), dx)) botch("d xcA > yC/dx", dx, xcA.adj());
434  else if (differ(yC.adj(), dy)) botch("d xcA > yC/dy", dy, yC.adj());
435  }
436  {
437  A::aval_reset();
438  xA = xd;
439  cC ycC(yd);
440  fA = xA > ycC;
441  A::Gradcomp();
442  if (differ(fA.val(), f)) botch("fA = xA > ycC", f, fA.val());
443  else if (differ(xA.adj(), dx)) botch("d xA > ycC/dx", dx, xA.adj());
444  else if (differ(ycC.adj(), dy)) botch("d xA > ycC/dy", dy, ycC.adj());
445  }
446  {
447  A::aval_reset();
448  cA xcA(xd);
449  cC ycC(yd);
450  fA = xcA > ycC;
451  A::Gradcomp();
452  if (differ(fA.val(), f)) botch("fA = xcA > ycC", f, fA.val());
453  else if (differ(xcA.adj(), dx)) botch("d xcA > ycC/dx", dx, xcA.adj());
454  else if (differ(ycC.adj(), dy)) botch("d xcA > ycC/dy", dy, ycC.adj());
455  }
456  {
457  xA = xd;
458  Ai yAi(yd);
459  fA = xA > yAi;
460  A::Gradcomp();
461  if (differ(fA.val(), f)) botch("fA = xA > yAi", f, fA.val());
462  else if (differ(xA.adj(), dx)) botch("d xA > yAi/dx", dx, xA.adj());
463  else if (differ(yAi.aval, dy)) botch("d xA > yAi/dy", dy, yAi.aval);
464  }
465  {
466  A::aval_reset();
467  cA xcA(xd);
468  Ai yAi(yd);
469  fA = xcA > yAi;
470  A::Gradcomp();
471  if (differ(fA.val(), f)) botch("fA = xcA > yAi", f, fA.val());
472  else if (differ(xcA.adj(), dx)) botch("d xcA > yAi/dx", dx, xcA.adj());
473  else if (differ(yAi.aval, dy)) botch("d xcA > yAi/dy", dy, yAi.aval);
474  }
475  {
476  A::aval_reset();
477  xA = xd;
478  cAi ycAi(yd);
479  fA = xA > ycAi;
480  A::Gradcomp();
481  if (differ(fA.val(), f)) botch("fA = xA > ycAi", f, fA.val());
482  else if (differ(xA.adj(), dx)) botch("d xA > ycAi/dx", dx, xA.adj());
483  else if (differ(ycAi.aval, dy)) botch("d xA > ycAi/dy", dy, ycAi.aval);
484  }
485  {
486  A::aval_reset();
487  cA xcA(xd);
488  cAi ycAi(yd);
489  fA = xcA > ycAi;
490  A::Gradcomp();
491  if (differ(fA.val(), f)) botch("fA = xcA > ycAi", f, fA.val());
492  else if (differ(xcA.adj(), dx)) botch("d xcA > ycAi/dx", dx, xcA.adj());
493  else if (differ(ycAi.aval, dy)) botch("d xcA > ycAi/dy", dy, ycAi.aval);
494  }
495  xA = xd;
496  fA = xA > yd;
497  A::Gradcomp();
498  if (differ(fA.val(), f)) botch("fA = xA > yd", f, fA.val());
499  else if (differ(xA.adj(), dx)) botch("d xA > yd/dx", dx, xA.adj());
500  {
501  A::aval_reset();
502  cA xcA(xd);
503  fA = xcA > yd;
504  A::Gradcomp();
505  if (differ(fA.val(), f)) botch("fA = xcA > yd", f, fA.val());
506  else if (differ(xcA.adj(), dx)) botch("d xcA > yd/dx", dx, xcA.adj());
507  }
508  xA = xd;
509  yL = (long)yd;
510  fA = xA > yL;
511  A::Gradcomp();
512  if (differ(fA.val(), f)) botch("fA = xA > yL", f, fA.val());
513  else if (differ(xA.adj(), dx)) botch("d xA > yL/dx", dx, xA.adj());
514  {
515  A::aval_reset();
516  cA xcA(xd);
517  yL = (long)yd;
518  fA = xcA > yL;
519  A::Gradcomp();
520  if (differ(fA.val(), f)) botch("fA = xcA > yL", f, fA.val());
521  else if (differ(xcA.adj(), dx)) botch("d xcA > yL/dx", dx, xcA.adj());
522  }
523  xA = xd;
524  yi = (int)yd;
525  fA = xA > yi;
526  A::Gradcomp();
527  if (differ(fA.val(), f)) botch("fA = xA > yi", f, fA.val());
528  else if (differ(xA.adj(), dx)) botch("d xA > yi/dx", dx, xA.adj());
529  {
530  A::aval_reset();
531  cA xcA(xd);
532  yi = (int)yd;
533  fA = xcA > yi;
534  A::Gradcomp();
535  if (differ(fA.val(), f)) botch("fA = xcA > yi", f, fA.val());
536  else if (differ(xcA.adj(), dx)) botch("d xcA > yi/dx", dx, xcA.adj());
537  }
538  xC = xd;
539  yAI = yd;
540  fA = xC > yAI;
541  A::Gradcomp();
542  if (differ(fA.val(), f)) botch("fA = xC > yAI", f, fA.val());
543  else if (differ(xC.adj(), dx)) botch("d xC > yAI/dx", dx, xC.adj());
544  else if (differ(yAI.adj(), dy)) botch("d xC > yAI/dy", dy, yAI.adj());
545  {
546  A::aval_reset();
547  cC xcC(xd);
548  yAI = yd;
549  fA = xcC > yAI;
550  A::Gradcomp();
551  if (differ(fA.val(), f)) botch("fA = xcC > yAI", f, fA.val());
552  else if (differ(xcC.adj(), dx)) botch("d xcC > yAI/dx", dx, xcC.adj());
553  else if (differ(yAI.adj(), dy)) botch("d xcC > yAI/dy", dy, yAI.adj());
554  }
555  {
556  A::aval_reset();
557  xC = xd;
558  cAI ycAI(yd);
559  fA = xC > ycAI;
560  A::Gradcomp();
561  if (differ(fA.val(), f)) botch("fA = xC > ycAI", f, fA.val());
562  else if (differ(xC.adj(), dx)) botch("d xC > ycAI/dx", dx, xC.adj());
563  else if (differ(ycAI.adj(), dy)) botch("d xC > ycAI/dy", dy, ycAI.adj());
564  }
565  {
566  A::aval_reset();
567  cC xcC(xd);
568  cAI ycAI(yd);
569  fA = xcC > ycAI;
570  A::Gradcomp();
571  if (differ(fA.val(), f)) botch("fA = xcC > ycAI", f, fA.val());
572  else if (differ(xcC.adj(), dx)) botch("d xcC > ycAI/dx", dx, xcC.adj());
573  else if (differ(ycAI.adj(), dy)) botch("d xcC > ycAI/dy", dy, ycAI.adj());
574  }
575  xC = xd;
576  yA = yd;
577  fA = xC > yA;
578  A::Gradcomp();
579  if (differ(fA.val(), f)) botch("fA = xC > yA", f, fA.val());
580  else if (differ(xC.adj(), dx)) botch("d xC > yA/dx", dx, xC.adj());
581  else if (differ(yA.adj(), dy)) botch("d xC > yA/dy", dy, yA.adj());
582  {
583  A::aval_reset();
584  cC xcC(xd);
585  yA = yd;
586  fA = xcC > yA;
587  A::Gradcomp();
588  if (differ(fA.val(), f)) botch("fA = xcC > yA", f, fA.val());
589  else if (differ(xcC.adj(), dx)) botch("d xcC > yA/dx", dx, xcC.adj());
590  else if (differ(yA.adj(), dy)) botch("d xcC > yA/dy", dy, yA.adj());
591  }
592  {
593  A::aval_reset();
594  xC = xd;
595  cA ycA(yd);
596  fA = xC > ycA;
597  A::Gradcomp();
598  if (differ(fA.val(), f)) botch("fA = xC > ycA", f, fA.val());
599  else if (differ(xC.adj(), dx)) botch("d xC > ycA/dx", dx, xC.adj());
600  else if (differ(ycA.adj(), dy)) botch("d xC > ycA/dy", dy, ycA.adj());
601  }
602  {
603  A::aval_reset();
604  cC xcC(xd);
605  cA ycA(yd);
606  fA = xcC > ycA;
607  A::Gradcomp();
608  if (differ(fA.val(), f)) botch("fA = xcC > ycA", f, fA.val());
609  else if (differ(xcC.adj(), dx)) botch("d xcC > ycA/dx", dx, xcC.adj());
610  else if (differ(ycA.adj(), dy)) botch("d xcC > ycA/dy", dy, ycA.adj());
611  }
612  xC = xd;
613  yC = yd;
614  fA = xC > yC;
615  A::Gradcomp();
616  if (differ(fA.val(), f)) botch("fA = xC > yC", f, fA.val());
617  else if (differ(xC.adj(), dx)) botch("d xC > yC/dx", dx, xC.adj());
618  else if (differ(yC.adj(), dy)) botch("d xC > yC/dy", dy, yC.adj());
619  {
620  A::aval_reset();
621  cC xcC(xd);
622  yC = yd;
623  fA = xcC > yC;
624  A::Gradcomp();
625  if (differ(fA.val(), f)) botch("fA = xcC > yC", f, fA.val());
626  else if (differ(xcC.adj(), dx)) botch("d xcC > yC/dx", dx, xcC.adj());
627  else if (differ(yC.adj(), dy)) botch("d xcC > yC/dy", dy, yC.adj());
628  }
629  {
630  A::aval_reset();
631  xC = xd;
632  cC ycC(yd);
633  fA = xC > ycC;
634  A::Gradcomp();
635  if (differ(fA.val(), f)) botch("fA = xC > ycC", f, fA.val());
636  else if (differ(xC.adj(), dx)) botch("d xC > ycC/dx", dx, xC.adj());
637  else if (differ(ycC.adj(), dy)) botch("d xC > ycC/dy", dy, ycC.adj());
638  }
639  {
640  A::aval_reset();
641  cC xcC(xd);
642  cC ycC(yd);
643  fA = xcC > ycC;
644  A::Gradcomp();
645  if (differ(fA.val(), f)) botch("fA = xcC > ycC", f, fA.val());
646  else if (differ(xcC.adj(), dx)) botch("d xcC > ycC/dx", dx, xcC.adj());
647  else if (differ(ycC.adj(), dy)) botch("d xcC > ycC/dy", dy, ycC.adj());
648  }
649  {
650  xC = xd;
651  Ai yAi(yd);
652  fA = xC > yAi;
653  A::Gradcomp();
654  if (differ(fA.val(), f)) botch("fA = xC > yAi", f, fA.val());
655  else if (differ(xC.adj(), dx)) botch("d xC > yAi/dx", dx, xC.adj());
656  else if (differ(yAi.aval, dy)) botch("d xC > yAi/dy", dy, yAi.aval);
657  }
658  {
659  A::aval_reset();
660  cC xcC(xd);
661  Ai yAi(yd);
662  fA = xcC > yAi;
663  A::Gradcomp();
664  if (differ(fA.val(), f)) botch("fA = xcC > yAi", f, fA.val());
665  else if (differ(xcC.adj(), dx)) botch("d xcC > yAi/dx", dx, xcC.adj());
666  else if (differ(yAi.aval, dy)) botch("d xcC > yAi/dy", dy, yAi.aval);
667  }
668  {
669  A::aval_reset();
670  xC = xd;
671  cAi ycAi(yd);
672  fA = xC > ycAi;
673  A::Gradcomp();
674  if (differ(fA.val(), f)) botch("fA = xC > ycAi", f, fA.val());
675  else if (differ(xC.adj(), dx)) botch("d xC > ycAi/dx", dx, xC.adj());
676  else if (differ(ycAi.aval, dy)) botch("d xC > ycAi/dy", dy, ycAi.aval);
677  }
678  {
679  A::aval_reset();
680  cC xcC(xd);
681  cAi ycAi(yd);
682  fA = xcC > ycAi;
683  A::Gradcomp();
684  if (differ(fA.val(), f)) botch("fA = xcC > ycAi", f, fA.val());
685  else if (differ(xcC.adj(), dx)) botch("d xcC > ycAi/dx", dx, xcC.adj());
686  else if (differ(ycAi.aval, dy)) botch("d xcC > ycAi/dy", dy, ycAi.aval);
687  }
688  xC = xd;
689  fA = xC > yd;
690  A::Gradcomp();
691  if (differ(fA.val(), f)) botch("fA = xC > yd", f, fA.val());
692  else if (differ(xC.adj(), dx)) botch("d xC > yd/dx", dx, xC.adj());
693  {
694  A::aval_reset();
695  cC xcC(xd);
696  fA = xcC > yd;
697  A::Gradcomp();
698  if (differ(fA.val(), f)) botch("fA = xcC > yd", f, fA.val());
699  else if (differ(xcC.adj(), dx)) botch("d xcC > yd/dx", dx, xcC.adj());
700  }
701  xC = xd;
702  yL = (long)yd;
703  fA = xC > yL;
704  A::Gradcomp();
705  if (differ(fA.val(), f)) botch("fA = xC > yL", f, fA.val());
706  else if (differ(xC.adj(), dx)) botch("d xC > yL/dx", dx, xC.adj());
707  {
708  A::aval_reset();
709  cC xcC(xd);
710  yL = (long)yd;
711  fA = xcC > yL;
712  A::Gradcomp();
713  if (differ(fA.val(), f)) botch("fA = xcC > yL", f, fA.val());
714  else if (differ(xcC.adj(), dx)) botch("d xcC > yL/dx", dx, xcC.adj());
715  }
716  xC = xd;
717  yi = (int)yd;
718  fA = xC > yi;
719  A::Gradcomp();
720  if (differ(fA.val(), f)) botch("fA = xC > yi", f, fA.val());
721  else if (differ(xC.adj(), dx)) botch("d xC > yi/dx", dx, xC.adj());
722  {
723  A::aval_reset();
724  cC xcC(xd);
725  yi = (int)yd;
726  fA = xcC > yi;
727  A::Gradcomp();
728  if (differ(fA.val(), f)) botch("fA = xcC > yi", f, fA.val());
729  else if (differ(xcC.adj(), dx)) botch("d xcC > yi/dx", dx, xcC.adj());
730  }
731  {
732  Ai xAi(xd);
733  yAI = yd;
734  fA = xAi > yAI;
735  A::Gradcomp();
736  if (differ(fA.val(), f)) botch("fA = xAi > yAI", f, fA.val());
737  else if (differ(xAi.aval, dx)) botch("d xAi > yAI/dx", dx, xAi.aval);
738  else if (differ(yAI.adj(), dy)) botch("d xAi > yAI/dy", dy, yAI.adj());
739  }
740  {
741  A::aval_reset();
742  cAi xcAi(xd);
743  yAI = yd;
744  fA = xcAi > yAI;
745  A::Gradcomp();
746  if (differ(fA.val(), f)) botch("fA = xcAi > yAI", f, fA.val());
747  else if (differ(xcAi.aval, dx)) botch("d xcAi > yAI/dx", dx, xcAi.aval);
748  else if (differ(yAI.adj(), dy)) botch("d xcAi > yAI/dy", dy, yAI.adj());
749  }
750  {
751  A::aval_reset();
752  Ai xAi(xd);
753  cAI ycAI(yd);
754  fA = xAi > ycAI;
755  A::Gradcomp();
756  if (differ(fA.val(), f)) botch("fA = xAi > ycAI", f, fA.val());
757  else if (differ(xAi.aval, dx)) botch("d xAi > ycAI/dx", dx, xAi.aval);
758  else if (differ(ycAI.adj(), dy)) botch("d xAi > ycAI/dy", dy, ycAI.adj());
759  }
760  {
761  Ai xAi(xd);
762  yA = yd;
763  fA = xAi > yA;
764  A::Gradcomp();
765  if (differ(fA.val(), f)) botch("fA = xAi > yA", f, fA.val());
766  else if (differ(xAi.aval, dx)) botch("d xAi > yA/dx", dx, xAi.aval);
767  else if (differ(yA.adj(), dy)) botch("d xAi > yA/dy", dy, yA.adj());
768  }
769  {
770  A::aval_reset();
771  cAi xcAi(xd);
772  yA = yd;
773  fA = xcAi > yA;
774  A::Gradcomp();
775  if (differ(fA.val(), f)) botch("fA = xcAi > yA", f, fA.val());
776  else if (differ(xcAi.aval, dx)) botch("d xcAi > yA/dx", dx, xcAi.aval);
777  else if (differ(yA.adj(), dy)) botch("d xcAi > yA/dy", dy, yA.adj());
778  }
779  {
780  A::aval_reset();
781  Ai xAi(xd);
782  cA ycA(yd);
783  fA = xAi > ycA;
784  A::Gradcomp();
785  if (differ(fA.val(), f)) botch("fA = xAi > ycA", f, fA.val());
786  else if (differ(xAi.aval, dx)) botch("d xAi > ycA/dx", dx, xAi.aval);
787  else if (differ(ycA.adj(), dy)) botch("d xAi > ycA/dy", dy, ycA.adj());
788  }
789  {
790  Ai xAi(xd);
791  yC = yd;
792  fA = xAi > yC;
793  A::Gradcomp();
794  if (differ(fA.val(), f)) botch("fA = xAi > yC", f, fA.val());
795  else if (differ(xAi.aval, dx)) botch("d xAi > yC/dx", dx, xAi.aval);
796  else if (differ(yC.adj(), dy)) botch("d xAi > yC/dy", dy, yC.adj());
797  }
798  {
799  A::aval_reset();
800  cAi xcAi(xd);
801  yC = yd;
802  fA = xcAi > yC;
803  A::Gradcomp();
804  if (differ(fA.val(), f)) botch("fA = xcAi > yC", f, fA.val());
805  else if (differ(xcAi.aval, dx)) botch("d xcAi > yC/dx", dx, xcAi.aval);
806  else if (differ(yC.adj(), dy)) botch("d xcAi > yC/dy", dy, yC.adj());
807  }
808  {
809  A::aval_reset();
810  Ai xAi(xd);
811  cC ycC(yd);
812  fA = xAi > ycC;
813  A::Gradcomp();
814  if (differ(fA.val(), f)) botch("fA = xAi > ycC", f, fA.val());
815  else if (differ(xAi.aval, dx)) botch("d xAi > ycC/dx", dx, xAi.aval);
816  else if (differ(ycC.adj(), dy)) botch("d xAi > ycC/dy", dy, ycC.adj());
817  }
818  {
819  Ai xAi(xd);
820  Ai yAi(yd);
821  fA = xAi > yAi;
822  A::Gradcomp();
823  if (differ(fA.val(), f)) botch("fA = xAi > yAi", f, fA.val());
824  else if (differ(xAi.aval, dx)) botch("d xAi > yAi/dx", dx, xAi.aval);
825  else if (differ(yAi.aval, dy)) botch("d xAi > yAi/dy", dy, yAi.aval);
826  }
827  {
828  A::aval_reset();
829  cAi xcAi(xd);
830  Ai yAi(yd);
831  fA = xcAi > yAi;
832  A::Gradcomp();
833  if (differ(fA.val(), f)) botch("fA = xcAi > yAi", f, fA.val());
834  else if (differ(xcAi.aval, dx)) botch("d xcAi > yAi/dx", dx, xcAi.aval);
835  else if (differ(yAi.aval, dy)) botch("d xcAi > yAi/dy", dy, yAi.aval);
836  }
837  {
838  A::aval_reset();
839  Ai xAi(xd);
840  cAi ycAi(yd);
841  fA = xAi > ycAi;
842  A::Gradcomp();
843  if (differ(fA.val(), f)) botch("fA = xAi > ycAi", f, fA.val());
844  else if (differ(xAi.aval, dx)) botch("d xAi > ycAi/dx", dx, xAi.aval);
845  else if (differ(ycAi.aval, dy)) botch("d xAi > ycAi/dy", dy, ycAi.aval);
846  }
847  {
848  Ai xAi(xd);
849  fA = xAi > yd;
850  A::Gradcomp();
851  if (differ(fA.val(), f)) botch("fA = xAi > yd", f, fA.val());
852  else if (differ(xAi.aval, dx)) botch("d xAi > yd/dx", dx, xAi.aval);
853  }
854  {
855  A::aval_reset();
856  cAi xcAi(xd);
857  fA = xcAi > yd;
858  A::Gradcomp();
859  if (differ(fA.val(), f)) botch("fA = xcAi > yd", f, fA.val());
860  else if (differ(xcAi.aval, dx)) botch("d xcAi > yd/dx", dx, xcAi.aval);
861  }
862  {
863  Ai xAi(xd);
864  yL = (long)yd;
865  fA = xAi > yL;
866  A::Gradcomp();
867  if (differ(fA.val(), f)) botch("fA = xAi > yL", f, fA.val());
868  else if (differ(xAi.aval, dx)) botch("d xAi > yL/dx", dx, xAi.aval);
869  }
870  {
871  A::aval_reset();
872  cAi xcAi(xd);
873  yL = (long)yd;
874  fA = xcAi > yL;
875  A::Gradcomp();
876  if (differ(fA.val(), f)) botch("fA = xcAi > yL", f, fA.val());
877  else if (differ(xcAi.aval, dx)) botch("d xcAi > yL/dx", dx, xcAi.aval);
878  }
879  {
880  Ai xAi(xd);
881  yi = (int)yd;
882  fA = xAi > yi;
883  A::Gradcomp();
884  if (differ(fA.val(), f)) botch("fA = xAi > yi", f, fA.val());
885  else if (differ(xAi.aval, dx)) botch("d xAi > yi/dx", dx, xAi.aval);
886  }
887  {
888  A::aval_reset();
889  cAi xcAi(xd);
890  yi = (int)yd;
891  fA = xcAi > yi;
892  A::Gradcomp();
893  if (differ(fA.val(), f)) botch("fA = xcAi > yi", f, fA.val());
894  else if (differ(xcAi.aval, dx)) botch("d xcAi > yi/dx", dx, xcAi.aval);
895  }
896  yAI = yd;
897  fA = xd > yAI;
898  A::Gradcomp();
899  if (differ(fA.val(), f)) botch("fA = xd > yAI", f, fA.val());
900  else if (differ(yAI.adj(), dy)) botch("d xd > yAI/dy", dy, yAI.adj());
901  {
902  A::aval_reset();
903  cAI ycAI(yd);
904  fA = xd > ycAI;
905  A::Gradcomp();
906  if (differ(fA.val(), f)) botch("fA = xd > ycAI", f, fA.val());
907  else if (differ(ycAI.adj(), dy)) botch("d xd > ycAI/dy", dy, ycAI.adj());
908  }
909  yA = yd;
910  fA = xd > yA;
911  A::Gradcomp();
912  if (differ(fA.val(), f)) botch("fA = xd > yA", f, fA.val());
913  else if (differ(yA.adj(), dy)) botch("d xd > yA/dy", dy, yA.adj());
914  {
915  A::aval_reset();
916  cA ycA(yd);
917  fA = xd > ycA;
918  A::Gradcomp();
919  if (differ(fA.val(), f)) botch("fA = xd > ycA", f, fA.val());
920  else if (differ(ycA.adj(), dy)) botch("d xd > ycA/dy", dy, ycA.adj());
921  }
922  yC = yd;
923  fA = xd > yC;
924  A::Gradcomp();
925  if (differ(fA.val(), f)) botch("fA = xd > yC", f, fA.val());
926  else if (differ(yC.adj(), dy)) botch("d xd > yC/dy", dy, yC.adj());
927  {
928  A::aval_reset();
929  cC ycC(yd);
930  fA = xd > ycC;
931  A::Gradcomp();
932  if (differ(fA.val(), f)) botch("fA = xd > ycC", f, fA.val());
933  else if (differ(ycC.adj(), dy)) botch("d xd > ycC/dy", dy, ycC.adj());
934  }
935  {
936  Ai yAi(yd);
937  fA = xd > yAi;
938  A::Gradcomp();
939  if (differ(fA.val(), f)) botch("fA = xd > yAi", f, fA.val());
940  else if (differ(yAi.aval, dy)) botch("d xd > yAi/dy", dy, yAi.aval);
941  }
942  {
943  A::aval_reset();
944  cAi ycAi(yd);
945  fA = xd > ycAi;
946  A::Gradcomp();
947  if (differ(fA.val(), f)) botch("fA = xd > ycAi", f, fA.val());
948  else if (differ(ycAi.aval, dy)) botch("d xd > ycAi/dy", dy, ycAi.aval);
949  }
950  xL = (long)xd;
951  yAI = yd;
952  fA = xL > yAI;
953  A::Gradcomp();
954  if (differ(fA.val(), f)) botch("fA = xL > yAI", f, fA.val());
955  else if (differ(yAI.adj(), dy)) botch("d xL > yAI/dy", dy, yAI.adj());
956  {
957  A::aval_reset();
958  xL = (long)xd;
959  cAI ycAI(yd);
960  fA = xL > ycAI;
961  A::Gradcomp();
962  if (differ(fA.val(), f)) botch("fA = xL > ycAI", f, fA.val());
963  else if (differ(ycAI.adj(), dy)) botch("d xL > ycAI/dy", dy, ycAI.adj());
964  }
965  xL = (long)xd;
966  yA = yd;
967  fA = xL > yA;
968  A::Gradcomp();
969  if (differ(fA.val(), f)) botch("fA = xL > yA", f, fA.val());
970  else if (differ(yA.adj(), dy)) botch("d xL > yA/dy", dy, yA.adj());
971  {
972  A::aval_reset();
973  xL = (long)xd;
974  cA ycA(yd);
975  fA = xL > ycA;
976  A::Gradcomp();
977  if (differ(fA.val(), f)) botch("fA = xL > ycA", f, fA.val());
978  else if (differ(ycA.adj(), dy)) botch("d xL > ycA/dy", dy, ycA.adj());
979  }
980  xL = (long)xd;
981  yC = yd;
982  fA = xL > yC;
983  A::Gradcomp();
984  if (differ(fA.val(), f)) botch("fA = xL > yC", f, fA.val());
985  else if (differ(yC.adj(), dy)) botch("d xL > yC/dy", dy, yC.adj());
986  {
987  A::aval_reset();
988  xL = (long)xd;
989  cC ycC(yd);
990  fA = xL > ycC;
991  A::Gradcomp();
992  if (differ(fA.val(), f)) botch("fA = xL > ycC", f, fA.val());
993  else if (differ(ycC.adj(), dy)) botch("d xL > ycC/dy", dy, ycC.adj());
994  }
995  {
996  xL = (long)xd;
997  Ai yAi(yd);
998  fA = xL > yAi;
999  A::Gradcomp();
1000  if (differ(fA.val(), f)) botch("fA = xL > yAi", f, fA.val());
1001  else if (differ(yAi.aval, dy)) botch("d xL > yAi/dy", dy, yAi.aval);
1002  }
1003  {
1004  A::aval_reset();
1005  xL = (long)xd;
1006  cAi ycAi(yd);
1007  fA = xL > ycAi;
1008  A::Gradcomp();
1009  if (differ(fA.val(), f)) botch("fA = xL > ycAi", f, fA.val());
1010  else if (differ(ycAi.aval, dy)) botch("d xL > ycAi/dy", dy, ycAi.aval);
1011  }
1012  xi = (int)xd;
1013  yAI = yd;
1014  fA = xi > yAI;
1015  A::Gradcomp();
1016  if (differ(fA.val(), f)) botch("fA = xi > yAI", f, fA.val());
1017  else if (differ(yAI.adj(), dy)) botch("d xi > yAI/dy", dy, yAI.adj());
1018  {
1019  A::aval_reset();
1020  xi = (int)xd;
1021  cAI ycAI(yd);
1022  fA = xi > ycAI;
1023  A::Gradcomp();
1024  if (differ(fA.val(), f)) botch("fA = xi > ycAI", f, fA.val());
1025  else if (differ(ycAI.adj(), dy)) botch("d xi > ycAI/dy", dy, ycAI.adj());
1026  }
1027  xi = (int)xd;
1028  yA = yd;
1029  fA = xi > yA;
1030  A::Gradcomp();
1031  if (differ(fA.val(), f)) botch("fA = xi > yA", f, fA.val());
1032  else if (differ(yA.adj(), dy)) botch("d xi > yA/dy", dy, yA.adj());
1033  {
1034  A::aval_reset();
1035  xi = (int)xd;
1036  cA ycA(yd);
1037  fA = xi > ycA;
1038  A::Gradcomp();
1039  if (differ(fA.val(), f)) botch("fA = xi > ycA", f, fA.val());
1040  else if (differ(ycA.adj(), dy)) botch("d xi > ycA/dy", dy, ycA.adj());
1041  }
1042  xi = (int)xd;
1043  yC = yd;
1044  fA = xi > yC;
1045  A::Gradcomp();
1046  if (differ(fA.val(), f)) botch("fA = xi > yC", f, fA.val());
1047  else if (differ(yC.adj(), dy)) botch("d xi > yC/dy", dy, yC.adj());
1048  {
1049  A::aval_reset();
1050  xi = (int)xd;
1051  cC ycC(yd);
1052  fA = xi > ycC;
1053  A::Gradcomp();
1054  if (differ(fA.val(), f)) botch("fA = xi > ycC", f, fA.val());
1055  else if (differ(ycC.adj(), dy)) botch("d xi > ycC/dy", dy, ycC.adj());
1056  }
1057  {
1058  xi = (int)xd;
1059  Ai yAi(yd);
1060  fA = xi > yAi;
1061  A::Gradcomp();
1062  if (differ(fA.val(), f)) botch("fA = xi > yAi", f, fA.val());
1063  else if (differ(yAi.aval, dy)) botch("d xi > yAi/dy", dy, yAi.aval);
1064  }
1065  {
1066  A::aval_reset();
1067  xi = (int)xd;
1068  cAi ycAi(yd);
1069  fA = xi > ycAi;
1070  A::Gradcomp();
1071  if (differ(fA.val(), f)) botch("fA = xi > ycAi", f, fA.val());
1072  else if (differ(ycAi.aval, dy)) botch("d xi > ycAi/dy", dy, ycAi.aval);
1073  }
1074 
1075 
1076  if (!rc) // chatter for cppunit test, which cannot tolerate silence
1077 
1078  printf("OK\n");
1079 
1080  return rc;
1081 
1082  }
ADT_RAD ADvari< double > Ai
int botch(ExpectedAnswer *e, const char *partial, double got, double wanted)
void f()
expr expr dx(i)
ADT_RAD IndepADvar< double > AI
const ADT_RAD IndepADvar< double > cAI
#define ADT_RAD
#define Ai
Definition: Sacado_rad.hpp:555
static int rc
#define C(x)
#define A
Definition: Sacado_rad.hpp:552
int main()
Definition: ad_example.cpp:171
const ADT_RAD ADvari< double > cAi
static int differ(double a, double b)
Definition: hesopcheck.cpp:127
const ADT_RAD ConstADvar< double > cC
const double tol
#define AI
Definition: Sacado_rad.hpp:556
const ADT_RAD ADvar< double > cA