File: exp_eps_for0.cpp

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (49 lines) | stat: -rw-r--r-- 1,493 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
// SPDX-FileContributor: 2003-22 Bradley M. Bell
// ----------------------------------------------------------------------------
/*
{xrst_begin exp_eps_for0.cpp}

exp_eps: Verify Zero Order Forward Sweep
########################################

{xrst_spell_off}
{xrst_code cpp} */
# include <cmath>                // for fabs function
bool exp_eps_for0(double *v0)    // double v0[8]
{  bool  ok = true;
   double x = .5;

   v0[1] = x;                                  // abs_x = x;
   ok  &= std::fabs( v0[1] - 0.5) < 1e-10;

   v0[2] = 1. * v0[1];                         // temp = term * abs_x;
   ok  &= std::fabs( v0[2] - 0.5) < 1e-10;

   v0[3] = v0[2] / 1.;                         // term = temp / Type(k);
   ok  &= std::fabs( v0[3] - 0.5) < 1e-10;

   v0[4] = 1. + v0[3];                         // sum = sum + term;
   ok  &= std::fabs( v0[4] - 1.5) < 1e-10;

   v0[5] = v0[3] * v0[1];                      // temp = term * abs_x;
   ok  &= std::fabs( v0[5] - 0.25) < 1e-10;

   v0[6] = v0[5] / 2.;                         // term = temp / Type(k);
   ok  &= std::fabs( v0[6] - 0.125) < 1e-10;

   v0[7] = v0[4] + v0[6];                      // sum = sum + term;
   ok  &= std::fabs( v0[7] - 1.625) < 1e-10;

   return ok;
}
bool exp_eps_for0(void)
{  double v0[8];
   return exp_eps_for0(v0);
}
/* {xrst_code}
{xrst_spell_on}

{xrst_end exp_eps_for0.cpp}
*/