46 # define snprintf _snprintf
57 {
return d*(x*x + y*y); }
71 {
"(a + b + c)", 38., 14., 16. }};
81 snprintf(buf,
sizeof(buf),
"d%s/d%s", what, partial);
84 fprintf(stderr,
"Expected %s = %g, but got %g\n", what, wanted, got);
89 acheck(
int k,
double d,
double v,
double dvdx,
double dvdy)
98 nbad +=
botch(e, 0, v, d*e->
v);
99 if (dvdx != d*e->
dvdx)
101 if (dvdy != d*e->
dvdy)
112 static ADVar a, b,
c, x, y, *v[3] = {&
a, &b, &c};
113 static ADVar **V[4] = {v, v+1, v+2, v};
114 static size_t np[4] = {1, 1, 1, 3};
115 static double w[3] = { 1., 1., 1. };
116 static double *W[4] = {w, w, w, w};
119 for(d = 1.; d <= 2.; ++d) {
120 printf(
"\nd = %g\n", d);
128 printf(
"a = %g\n", a.
val());
129 printf(
"da/dx = %g\n", x.
adj());
130 printf(
"da/dy = %g\n", y.
adj());
135 printf(
"b = %g\n", b.val());
136 printf(
"db/dx = %g\n", x.
adj());
137 printf(
"db/dy = %g\n", y.
adj());
142 printf(
"c = %g (should be a + b)\n", c.
val());
143 printf(
"dc/dx = %g\n", x.
adj());
144 printf(
"dc/dy = %g\n", y.
adj());
147 z[3] = z[0] + z[1] + z[2];
150 for(i = 0; i < 4; ++i) {
151 printf(
"w %d:\td/dx = %g\td/dy = %g\n", i, x.
adj(i), y.
adj(i));
156 printf(
"\nExample passed!\n");
158 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]