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}} }@)@
Printing AD Values During Forward Mode

f.Forward(0, x)

The zero order forward mode command
f.Forward(0, x)
assigns the independent variable vector equal to x . It then computes a value for all of the dependent variables in the operation sequence corresponding to f . Putting a PrintFor in the operation sequence will cause the value of var , corresponding to x , to be printed during zero order forward operations.

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

If present, the argument pos has one of the following prototypes
     const AD<
Base>&               pos
     const VecAD<
Base>::reference& pos
In this case the text and var will be printed if and only if pos is not greater than zero and a finite number.

The argument before has prototype
     const char* 
This text is written to std::cout before var .

The argument var has one of the following prototypes
     const AD<
Base>&               var
     const VecAD<
Base>::reference& var
The value of var , that corresponds to x , is written to std::cout during the execution of
f.Forward(0, x)
Note that var may be a variable or parameter . (A parameters value does not depend on the value of the independent variable vector x .)

The argument after has prototype
     const char* 
This text is written to std::cout after var .

Redirecting Output
You can redirect this output to any standard output stream; see the s in the forward mode documentation.

This is helpful for understanding why tape evaluations have trouble. For example, if one of the operations in f is log(var) and var <= 0 , the corresponding result will be nan .

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

The program print_for_cout.cpp is an example and test that prints to standard output. The output of this program states the conditions for passing and failing the test. The function print_for_string.cpp is an example and test that prints to an standard string stream. This function automatically check for correct output.
Input File: cppad/core/print_for.hpp