|
Prev | Next |
# include <cppad/nan.hpp>
s = nan(z)
b = isnan(s)
b = hasnan(v)
nan.
The IEEE standard specifies that a floating point value
a
is nan if and only if the following returns true
a != a
Some systems do not get this correct, so we also use the fact that
zero divided by zero should result in a nan.
To be specific, if a value is not equal to itself or
if it is equal to zero divided by zero, it is considered to be a nan.
cppad/nan.hpp is included by cppad/cppad.hpp
but it can also be included separately with out the rest of
the CppAD routines.
nan
and isnan.
These preprocessor symbols will no longer be defined after
this file is included.
nan with the same type as
z
.
z
has prototype
const Scalar &z
and its value is zero
(see Scalar
for the definition of
Scalar
).
s
has prototype
Scalar s
It is the value nan for this floating point type.
nan.
s
has prototype
const Scalar s
b
has prototype
bool b
It is true if the value
s
is nan.
nan.
v
has prototype
const Vector &v
(see Vector
for the definition of
Vector
).
b
has prototype
bool b
It is true if the vector
v
has a nan.
Scalar
must support the following operations;
| Operation | Description |
a / b
|
division operator (returns a
Scalar
object)
|
a == b
|
equality operator (returns a bool object)
|
a != b
|
not equality operator (returns a bool object)
|
a
and b
equal to zero. For some types (e.g. int) this may generate
an exception. No attempt is made to catch any such exception.
Vector
must be a SimpleVector
class with
elements of type
Scalar
.
Scalar
,
the first call to
b = isnan(s)
must not be parallel
execution mode;
see isnan in parallel_ad
.