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}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Check an ADFun Object For Nan Results

Syntax
f.check_for_nan(b)
b = f.check_for_nan()
get_check_for_nan(vecfile)

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

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

b
This argument or result has prototype
    bool 
b
If b is true (false), future calls to f.Forward will (will not) check for nan.

Default
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.

vector_size
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.

file_name
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.

index
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.

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

vec
This argument has prototype
    CppAD::vector<
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 .)

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

Example
The file check_for_nan.cpp contains an example and test of these operations.
Input File: include/cppad/core/check_for_nan.hpp