Prev Next

Printing AD Values During Forward Mode

Syntax
PrintFor(texty)
f.Forward(0, x)

Purpose
The current value of an AD<Base> object y is the result of an AD of Base operation. This operation may be part of the operation sequence that is transferred to an ADFun object f. The ADFun object can be evaluated at different values for the independent variables . This may result in a corresponding value for y that is different from when the operation sequence was recorded. The routine PrintFor requests a printing, when f.Forward(0, x) is executed, of the value for y that corresponds to the independent variable values specified by x.

text
The argument text has prototype
     const char *
text
The corresponding text is written to std::cout before the value of y.

y
The argument y has one of the following prototypes
     const AD<
Base>               &y
     const VecAD<
Base>::reference &y
The value of y that corresponds to x is written to std::cout during the execution of
     
f.Forward(0, x)

f.Forward(0, x)
The objects f, x, and the purpose for this operation, are documented in Forward .

Discussion
This is can be helpful for understanding why tape evaluations have trouble, for example, if the result of a tape calculation is the IEEE code for not a number Nan.

Alternative
The Output section describes the normal printing of values; i.e., printing when the corresponding code is executed.

Example
The program PrintFor.cpp is an example and test of this operation. The output of this program states the conditions for passing and failing the test.
Input File: cppad/local/print_for.hpp