46 {
return sqrt(a*a + 2*b*b); }
54 for(i = 1; i < n; i++)
67 printf(
"Fad_demo...\n\n");
78 printf(
"func2(%g,%g) = %g\n", a.val(), b.val(), y.val());
80 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
86 if (y.hasFastAccess())
87 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
88 y.fastAccessDx(0), y.fastAccessDx(1));
92 for(i = 0; i < n; i++) {
97 printf(
"\nfunc(5,x) for x = (0,1,2,3,4) = %g\n", y.val());
98 for(i = 0; i < n; i++)
99 printf(
"d func / d x[%d] = %g == %g\n", i, y.dx(i), y.fastAccessDx(i));
110 printf(
"\n\nFad2_demo...\n\n");
120 printf(
"func2(%g,%g) = %g\n", a.val(), b.val(), y.val());
122 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
124 if (y.hasFastAccess())
125 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
126 y.fastAccessDx(0), y.fastAccessDx(1));
136 F2 a(2,0,1.), b(2,1,2.), y;
138 printf(
"\n\nFad3_demo...\n\n");
142 printf(
"func2(%g,%g) = %g\n",
a.val(), b.val(), y.val());
144 printf(
"partials of func2 = %g, %g\n", y.dx(0), y.dx(1));
146 if (y.hasFastAccess())
147 printf(
"Repeat with fastAccess: partials of func2 = %g, %g\n",
148 y.fastAccessDx(0), y.fastAccessDx(1));
160 printf(
"\n\nRad_demo...\n\n");
170 printf(
"func2(%g,%g) = %g\n", a.
val(), b.
val(), y.
val());
172 printf(
"partials of func2 = %g, %g\n", a.
adj(), b.
adj());
176 for(i = 0; i < n; i++)
179 printf(
"\nfunc(5,x) for x = (0,1,2,3,4) = %g\n", y.
val());
186 for(i = 0; i < n; i++)
187 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)