Prev Next Index-> contents reference index search external Up-> CppAD utility nan CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix utility-> ErrorHandler NearEqual speed_test SpeedTest time_test test_boolofvoid NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort to_string set_union sparse_rc sparse_rcv nan-> nan.cpp Headings-> Syntax Purpose Include ---..Macros isnan ---..s ---..b hasnan ---..v ---..b nan(zero) ---..Deprecated 2015-10-04 ---..Syntax ---..z ---..s Scalar Vector Example

$\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}} }$
Obtain Nan or Determine if a Value is Nan

Syntax
# include <cppad/utility/nan.hpp>  b = isnan(s)  b = hasnan(v)

Purpose
It obtain and check for the value not a number nan. The IEEE standard specifies that a floating point value a is nan if and only if the following returns true       a != a 
Include
The file cppad/nan.hpp is included by cppad/cppad.hpp but it can also be included separately with out the rest of the CppAD routines.

Macros
Some C++ compilers use preprocessor symbols called nan and isnan. These preprocessor symbols will no longer be defined after this file is included.

isnan
This routine determines if a scalar value is nan.

s
The argument s has prototype       const Scalar s 
b
The return value b has prototype       bool b  It is true if the value s is nan.

hasnan
This routine determines if a SimpleVector has an element that is nan.

v
The argument v has prototype       const Vector &v  (see Vector for the definition of Vector ).

b
The return value b has prototype       bool b  It is true if the vector v has a nan.

nan(zero)

Deprecated 2015-10-04
This routine has been deprecated, use CppAD numeric limits quiet_NaN in its place.

Syntax
s = nan(z) 
z
The argument z has prototype       const Scalar &z  and its value is zero (see Scalar for the definition of Scalar ).

s
The return value s has prototype       Scalar s  It is the value nan for this floating point type.

Scalar
The type 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)
Note that the division operator will be used with 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
The type Vector must be a SimpleVector class with elements of type Scalar .

Example
The file nan.cpp contains an example and test of this routine. It returns true if it succeeds and false otherwise.