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