26 {
return sqrt(a*a + 2*b*b); }
34 for(i = 1; i < n; i++)
47 printf(
"Fad_demo...\n\n");
58 printf(
"func2(%g,%g) = %g\n", a.val(), b.val(), y.val());
60 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
66 if (y.hasFastAccess())
67 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
68 y.fastAccessDx(0), y.fastAccessDx(1));
72 for(i = 0; i < n; i++) {
77 printf(
"\nfunc(5,x) for x = (0,1,2,3,4) = %g\n", y.val());
78 for(i = 0; i < n; i++)
79 printf(
"d func / d x[%d] = %g == %g\n", i, y.dx(i), y.fastAccessDx(i));
90 printf(
"\n\nFad2_demo...\n\n");
100 printf(
"func2(%g,%g) = %g\n", a.val(), b.val(), y.val());
102 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
104 if (y.hasFastAccess())
105 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
106 y.fastAccessDx(0), y.fastAccessDx(1));
116 F2 a(2,0,1.), b(2,1,2.),
y;
118 printf(
"\n\nFad3_demo...\n\n");
122 printf(
"func2(%g,%g) = %g\n",
a.val(), b.val(), y.val());
124 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
126 if (y.hasFastAccess())
127 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
128 y.fastAccessDx(0), y.fastAccessDx(1));
140 printf(
"\n\nRad_demo...\n\n");
150 printf(
"func2(%g,%g) = %g\n", a.
val(), b.
val(), y.
val());
152 printf(
"partials of func2 = %g, %g\n", a.
adj(), b.
adj());
156 for(i = 0; i < n; i++)
159 printf(
"\nfunc(5,x) for x = (0,1,2,3,4) = %g\n", y.
val());
166 for(i = 0; i < n; i++)
167 printf(
"d func / d x[%d] = %g\n", i, x[i].adj());
Sacado::Fad::DFad< double > F
const T func2(T &a, T &b)
Sacado::Rad::ADvar< double > R
Sacado::Fad::SFad< double, 2 > F2
const T func(int n, T *x)