1 # ifndef CPPAD_UTILITY_NEAR_EQUAL_HPP
2 # define CPPAD_UTILITY_NEAR_EQUAL_HPP
152 template <
class Type>
154 { Type infinity = Type( std::numeric_limits<double>::infinity() );
161 bool xInf = (x == infinity || x == - infinity);
162 bool yInf = (x == infinity || x == - infinity);
164 return ! (xNan | yNan | xInf | yInf);
167 template <
class Type>
168 bool NearEqual(
const Type &x,
const Type &y,
const Type &r,
const Type &a)
170 CheckNumericType<Type>();
175 "Error in NearEqual: relative error is less than zero"
179 "Error in NearEqual: absolute error is less than zero"
201 if( ad <= r * (ax + ay) )
207 template <
class Type>
209 const std::complex<Type> &x ,
210 const std::complex<Type> &y ,
214 CheckNumericType<Type>();
221 "Error in NearEqual: relative error is less than zero"
225 "Error in NearEqual: absolute error is less than zero"
234 std::complex<Type> d = x - y;
242 if( ad <= r * (ax + ay) )
248 template <
class Type>
250 const std::complex<Type> &x ,
255 return NearEqual(x, std::complex<Type>(y, Type(0)), r, a);
258 template <
class Type>
261 const std::complex<Type> &y ,
265 return NearEqual(std::complex<Type>(x, Type(0)), y, r, a);
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
AD< Base > abs(const AD< Base > &x)
bool near_equal_isfinite(const Type &x, const Type &y)
bool NearEqual(const Type &x, const Type &y, const Type &r, const Type &a)