source: trunk/test_more/near_equal_ext.cpp @ 2506

Last change on this file since 2506 was 2506, checked in by bradbell, 8 years ago

Change Licenses: CPL-1.0 -> EPL-1.0, GPL-2.0->GPL-3.0

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/* $Id: near_equal_ext.cpp 2506 2012-10-24 19:36:49Z bradbell $ */
2/* --------------------------------------------------------------------------
3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell
4
5CppAD is distributed under multiple licenses. This distribution is under
6the terms of the
7                    Eclipse Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
10Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11-------------------------------------------------------------------------- */
12
13/*
14Old example now just used for validation testing
15*/
16
17# include <cppad/cppad.hpp>
18# include <complex>
19
20bool NearEqualExt(void)
21{       bool ok = true;
22        using CppAD::AD;
23        using CppAD::NearEqual;
24
25        // double
26        double x    = 1.00000;
27        double y    = 1.00001;
28        double a    =  .00005;
29        double r    =  .00005;
30        double zero = 0.; 
31        double inf  = 1. / zero;
32        double nan  = 0. / zero;
33
34        // AD<double>
35        AD<double> X(x);
36        AD<double> Y(y);
37        AD<double> Inf(inf);
38        AD<double> Nan(nan);
39
40        ok &= NearEqual(X, Y, zero, a);
41        ok &= NearEqual(X, y, zero, a);
42        ok &= NearEqual(x, Y, zero, a);
43
44        ok &= ! NearEqual(X, Y, zero, a/25.);
45        ok &= ! NearEqual(X, y, zero, a/25.);
46        ok &= ! NearEqual(x, Y, zero, a/25.);
47
48        ok &= NearEqual(X, Y, r, zero);
49        ok &= NearEqual(X, y, r, zero);
50        ok &= NearEqual(x, Y, r, zero);
51
52        ok &= ! NearEqual(X, Y, r/25., zero);
53        ok &= ! NearEqual(X, y, r/25., zero);
54        ok &= ! NearEqual(x, Y, r/25., zero);
55
56        ok &= ! NearEqual(Inf, Inf, r, a);
57        ok &= ! NearEqual(Inf, inf, r, a);
58        ok &= ! NearEqual(inf, Inf, r, a);
59
60        ok &= ! NearEqual(-Inf, -Inf, r, a);
61        ok &= ! NearEqual(-Inf, -inf, r, a);
62        ok &= ! NearEqual(-inf, -Inf, r, a);
63
64        ok &= ! NearEqual(Nan, Nan, r, a);
65        ok &= ! NearEqual(Nan, nan, r, a);
66        ok &= ! NearEqual(nan, Nan, r, a);
67
68        return ok;
69}
Note: See TracBrowser for help on using the repository browser.