\(\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}} }\)
PrintFor¶
View page sourcePrinting AD Values During Forward Mode¶
Syntax¶
Forward
(0, x )Forward
(0, x , s )PrintFor
( before , value )PrintFor
( notpos , before , value , after )See Also¶
Purpose¶
The zero order forward mode command
f .
Forward
(0, x )
sets 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,
prints value , 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 .
notpos¶
If present, the argument notpos has one of the following prototypes
const AD
< Base >& notposconst VecAD
< Base >:: reference&
notposIn this case the text and value will be printed if and only if notpos is not positive (greater than zero) and a finite number.
before¶
The argument before has prototype
const char
* before
This text is written to std::cout
before value .
value¶
The argument value has one of the following prototypes
const AD
< Base >& valueconst VecAD
< Base >:: reference&
valueThe value , that corresponds to x ,
is written to std::cout
during the execution of
f .
Forward
(0, x )
Note that value may be a Variable or Parameter . If a parameter is Dynamic its value will depend on the previous call to new_dynamic .
after¶
The argument after has prototype
const char
* after
This text is written to std::cout
after value .
s¶
You can redirect this output to any standard output stream using the syntax
f .
Forward
(0, x , s )
see s in the zero order forward mode documentation.
Discussion¶
This is helpful for understanding why tape evaluations have trouble.
For example, if one of the operations in f is
log
( value ) and value < 0 ,
the corresponding result will nan .
Example¶
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.