Prev Next

@(@\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}} }@)@
Check an ADFun Object For Nan Results

b = f.check_for_nan()

If NDEBUG is not defined, and the result of a forward or reverse calculation contains a nan , CppAD can halt with an error message.

For the syntax where b is an argument, f has prototype
(see ADFun<Base> constructor ). For the syntax where b is the result, f has prototype
     const ADFun<

This argument or result has prototype
Future calls to f.Forward will (will not) check for nan. depending on if b is true (false).

The value for this setting after construction of f ) is true. The value of this setting is not affected by calling Dependent for this function object.

Error Message
If this error is detected during zero order forward mode, the values of the independent variables that resulted in the nan are written to a temporary binary file. This is so that you can run the original source code with those values to see what is causing the nan.

The error message with contain the text vector_size = vector_size followed the newline character '\n'. The value of vector_size is the number of elements in the independent vector.

The error message with contain the text file_name = file_name followed the newline character '\n'. The value of file_name is the name of the temporary file that contains the dependent variable values.

The error message will contain the text index = index followed by the newline character '\n'. The value of index is the lowest dependent variable index that has the value nan.

This routine can be used to get the independent variable values that result in a nan.

This argument has prototype
Base>& vec
It size must be equal to the corresponding value of vector_size in the corresponding error message. The input value of its elements does not matter. Upon return, it will contain the values for the independent variables, in the corresponding call to Independent , that resulted in the nan. (Note that the call to Independent uses an vector with elements of type AD<Base> and vec has elements of type Base .)

This argument has prototype
     const std::string& 
It must be the value of file_name in the corresponding error message.

The file check_for_nan.cpp contains an example and test of these operations. It returns true if it succeeds and false otherwise.
Input File: cppad/core/check_for_nan.hpp