\(\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}} }\)
near_equal_ext¶
View page sourceCompare AD and Base Objects for Nearly Equal¶
Syntax¶
NearEqual
( x , y , r , a )Purpose¶
The routine NearEqual determines if two objects of
the same type are nearly.
This routine is extended to the case where one object can have type
Type while the other can have type
AD
< Type > or
AD< std::complex<
Type > > .
x¶
The arguments x has one of the following possible prototypes:
const
Type & xconst AD
< Type > & xconst AD< std::complex<
Type > > & xy¶
The arguments y has one of the following possible prototypes:
const
Type & yconst AD
< Type > & yconst AD< std::complex<
Type > > & xr¶
The relative error criteria r has prototype
const
Type & r
It must be greater than or equal to zero. The relative error condition is defined as:
a¶
The absolute error criteria a has prototype
const
Type & a
It must be greater than or equal to zero. The absolute error condition is defined as:
b¶
The return value b has prototype
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.
Type¶
The type Type must be a NumericType . The routine CheckNumericType will generate an error message if this is not the case. If a and b have type Type , the following operation must be defined
Operation |
Description |
a <= b |
less that or equal operator (returns a |
Operation Sequence¶
The result of this operation is not an AD of Base object. Thus it will not be recorded as part of an AD of Base operation sequence .
Example¶
The file near_equal_ext.cpp contains an example and test of this extension of NearEqual . It return true if it succeeds and false otherwise.