26 # define snprintf _snprintf
37 {
return d*(x*x + y*
y); }
51 {
"(a + b + c)", 38., 14., 16. }};
61 snprintf(buf,
sizeof(buf),
"d%s/d%s", what, partial);
64 fprintf(stderr,
"Expected %s = %g, but got %g\n", what, wanted, got);
69 acheck(
int k,
double d,
double v,
double dvdx,
double dvdy)
78 nbad +=
botch(e, 0, v, d*e->
v);
79 if (dvdx != d*e->
dvdx)
81 if (dvdy != d*e->
dvdy)
92 static ADVar a, b,
c,
x,
y, *v[3] = {&
a, &b, &c};
93 static ADVar **V[4] = {v, v+1, v+2, v};
94 static size_t np[4] = {1, 1, 1, 3};
95 static double w[3] = { 1., 1., 1. };
96 static double *W[4] = {w, w, w, w};
99 for(d = 1.; d <= 2.; ++d) {
100 printf(
"\nd = %g\n", d);
108 printf(
"a = %g\n", a.
val());
109 printf(
"da/dx = %g\n", x.
adj());
110 printf(
"da/dy = %g\n", y.
adj());
115 printf(
"b = %g\n", b.val());
116 printf(
"db/dx = %g\n", x.
adj());
117 printf(
"db/dy = %g\n", y.
adj());
122 printf(
"c = %g (should be a + b)\n", c.
val());
123 printf(
"dc/dx = %g\n", x.
adj());
124 printf(
"dc/dy = %g\n", y.
adj());
127 z[3] = z[0] + z[1] + z[2];
130 for(i = 0; i < 4; ++
i) {
131 printf(
"w %d:\td/dx = %g\td/dy = %g\n", i, x.
adj(i), y.
adj(i));
136 printf(
"\nExample passed!\n");
138 printf(
"\nSomething is wrong, example failed!\n");
int botch(ExpectedAnswer *e, const char *partial, double got, double wanted)
Sacado::RadVec::ADvar< double > ADVar
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
static void Outvar_Gradcomp(ADvar &v)
ADVar foo(double d, ADVar x, ADVar y)
int acheck(int k, double d, double v, double dvdx, double dvdy)
static void Weighted_GradcompVec(size_t n, size_t *np, ADvar ***v, Double **w)
ADVar goo(double d, ADVar x, ADVar y)
static ExpectedAnswer expected[4]