![]() |
Prev | Next |
# include <cppad/near_equal.hpp>
b = NearEqual(
x,
y,
r,
a)
const
Type &
x,
const std::complex<
Type> &
x,
const
Type &
y,
const std::complex<
Type> &
y,
const
Type &
r
It must be greater than or equal to zero.
The relative error condition is defined as:
\[
| x - y | \leq r ( |x| + |y| )
\]
const
Type &
a
It must be greater than or equal to zero.
The absolute error condition is defined as:
\[
| x - y | \leq a
\]
bool
b
If either x or y is infinite or not a number,
the return value is false.
Otherwise, if either the relative or absolute error
condition (defined above) is satisfied, the return value is true.
Otherwise, the return value is false.
Operation | Description |
a <= b |
less that or equal operator (returns a bool object)
|
cppad/near_equal.hpp
is included by cppad/cppad.hpp
but it can also be included separately with out the rest of
the CppAD
routines.
NearEqual
.
It return true if it succeeds and false otherwise.
using std::complex;
using std::cout;
using std::endl;
complex<double> one(1., 0), i(0., 1);
complex<double> x = one / i;
complex<double> y = - i;
double r = 1e-12;
double a = 0;
bool ok = CppAD::NearEqual(x, y, r, a);
if( ok )
cout << "Ok" << endl;
else cout << "Error" << endl;