Prev Next Index-> contents reference index search external Up-> CppAD Introduction exp_eps exp_eps_for1 exp_eps_for1.cpp Introduction-> exp_2 exp_eps exp_apx.cpp exp_eps-> exp_eps.hpp exp_eps.cpp exp_eps_for0 exp_eps_for1 exp_eps_rev1 exp_eps_for2 exp_eps_rev2 exp_eps_cppad exp_eps_for1-> exp_eps_for1.cpp exp_eps_for1.cpp Headings

$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$
exp_eps: Verify First Order Forward Sweep
# include <cmath>                     // for fabs function
extern bool exp_eps_for0(double *v0); // computes zero order forward sweep
bool exp_eps_for1(double *v1)         // double v[8]
{     bool ok = true;
double v0[8];

// set the value of v0[j] for j = 1 , ... , 7
ok &= exp_eps_for0(v0);

v1[1] = 1.;                                      // v1 = x
ok    &= std::fabs( v1[1] - 1. ) <= 1e-10;

v1[2] = 1. * v1[1];                              // v2 = 1 * v1
ok    &= std::fabs( v1[2] - 1. ) <= 1e-10;

v1[3] = v1[2] / 1.;                              // v3 = v2 / 1
ok    &= std::fabs( v1[3] - 1. ) <= 1e-10;

v1[4] = v1[3];                                   // v4 = 1 + v3
ok    &= std::fabs( v1[4] - 1. ) <= 1e-10;

v1[5] = v1[3] * v0[1] + v0[3] * v1[1];           // v5 = v3 * v1
ok    &= std::fabs( v1[5] - 1. ) <= 1e-10;

v1[6] = v1[5] / 2.;                              // v6 = v5 / 2
ok    &= std::fabs( v1[6] - 0.5 ) <= 1e-10;

v1[7] = v1[4] + v1[6];                           // v7 = v4 + v6
ok    &= std::fabs( v1[7] - 1.5 ) <= 1e-10;

return ok;
}
bool exp_eps_for1(void)
{     double v1[8];
return exp_eps_for1(v1);
}

Input File: introduction/exp_eps_for1.cpp