27 template <
typename Scalar>
28 Scalar
func(
const int m,
const Scalar
x[]) {
31 for (
int i=0;
i<m; ++
i)
49 static type apply(
const int n,
const double x,
const double v[]) {
51 for (
int i=0;
i<n; ++
i)
52 x_fad.fastAccessDx(
i) = v[
i];
66 static type apply(
const int n,
const double x,
const double v[]) {
68 for (
int i=0;
i<n; ++
i)
69 x_fad.fastAccessDx(
i) = v[
i];
76 template <
typename TermIterator>
82 template <
typename T,
typename TermIterator>
97 int main(
int argc,
char **argv)
102 const double x0[m] = { 1.0, 1.0, 1.0 };
103 const double V[m][n] = { {0.1, 0.2},
109 std::vector<int> term = { 0, 0, 0, 1, 1, 1 };
114 NestedFadType x_fad[m];
115 for (
int i=0;
i<m; ++
i)
117 const NestedFadType f_fad =
func(m,x_fad);
122 NestedFadType x_fad2[m];
123 for (
int i=0; i<m; ++
i)
125 const NestedFadType f_fad2 =
func(m,x_fad2);
134 const int r = term.size();
135 std::vector<int> t(r, 0);
136 bool finished =
false;
140 for (
int i=0; i<r; ++
i) {
141 c *= V[t[
i]][term[
i]];
148 while (j<r-1 && t[j] >= m) {
158 std::cout <<
"z (reduced) = " << z1 <<
" z (full) = " << z2
159 <<
" error = " << error << std::endl;
161 const double tol = 1.0e-14;
163 std::cout <<
"\nExample passed!" << std::endl;
167 std::cout <<
"\nSomething is wrong, example failed!" << std::endl;
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
static type apply(const int n, const double x, const double v[])
static type apply(const int n, const int i, const double x)
MakeFad< N-1 >::type nested_type
Sacado::Fad::DFad< double > FadType
F::template apply< A1, A2, A3, A4, A5 >::type type
static type apply(const int n, const double x, const double v[])
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
double extract_derivative(const double &x, TermIterator term, TermIterator term_end)
const T func(int n, T *x)
Sacado::mpl::apply< FadType, nested_type >::type type
static type apply(const int n, const int i, const double x)