27 template <
typename ScalarT>
28 ScalarT
func(
const ScalarT&
a,
const ScalarT& b,
const ScalarT&
c) {
35 void func_deriv(
double a,
double b,
double c,
double& drda,
double& drdb)
41 int main(
int argc,
char **argv)
60 double r =
func(a, b, c);
67 rfad =
func(afad, bfad, cfad);
70 double r_ad = rfad.val();
71 double drda_ad = rfad.dx(0);
72 double drdb_ad = rfad.dx(1);
77 std::cout.setf(std::ios::scientific);
78 std::cout.precision(p);
79 std::cout <<
" r = " << r <<
" (original) == " << std::setw(w) << r_ad
80 <<
" (AD) Error = " << std::setw(w) << r - r_ad << std::endl
81 <<
"dr/da = " << std::setw(w) << drda <<
" (analytic) == "
82 << std::setw(w) << drda_ad <<
" (AD) Error = " << std::setw(w)
83 << drda - drda_ad << std::endl
84 <<
"dr/db = " << std::setw(w) << drdb <<
" (analytic) == "
85 << std::setw(w) << drdb_ad <<
" (AD) Error = " << std::setw(w)
86 << drdb - drdb_ad << std::endl;
92 std::cout <<
"\nExample passed!" << std::endl;
96 std::cout <<
"\nSomething is wrong, example failed!" << std::endl;
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
void func_deriv(double a, double b, double c, double &drda, double &drdb)
const T func(int n, T *x)
SACADO_INLINE_FUNCTION mpl::enable_if_c< ExprLevel< Expr< T1 > >::value==ExprLevel< Expr< T2 > >::value, Expr< PowerOp< Expr< T1 >, Expr< T2 > > > >::type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)