Codebase list cppad / upstream/2015.00.00.7 doc / comparechange.xml
upstream/2015.00.00.7

Tree @upstream/2015.00.00.7 (Download .tar.gz)

comparechange.xml @upstream/2015.00.00.7raw · history · blame

<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Comparison Changes During Zero Order Forward Mode</title>
<meta http-equiv='Content-Type' content='text/html' charset='utf-8'/>
<meta name="description" id="description" content="Comparison Changes During Zero Order Forward Mode"/>
<meta name="keywords" id="keywords" content=" comparison changes during zero order forward mode Adfun Comparechange syntax purpose f c discussion restrictions Ndebug example "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_comparechange_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="size_order.xml" target="_top">Prev</a>
</td><td><a href="compare_change.cpp.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>ADFun</option>
<option>FunEval</option>
<option>Forward</option>
<option>CompareChange</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>ADFun-&gt;</option>
<option>Independent</option>
<option>FunConstruct</option>
<option>Dependent</option>
<option>abort_recording</option>
<option>seq_property</option>
<option>FunEval</option>
<option>Drivers</option>
<option>FunCheck</option>
<option>optimize</option>
<option>check_for_nan</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>FunEval-&gt;</option>
<option>Forward</option>
<option>Reverse</option>
<option>Sparse</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>Forward-&gt;</option>
<option>forward_zero</option>
<option>forward_one</option>
<option>forward_two</option>
<option>forward_order</option>
<option>forward_dir</option>
<option>size_order</option>
<option>CompareChange</option>
<option>capacity_order</option>
<option>number_skip</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>CompareChange-&gt;</option>
<option>compare_change.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Purpose</option>
<option>f</option>
<option>c</option>
<option>Discussion</option>
<option>Restrictions</option>
<option>Example</option>
</select>
</td>
</tr></table><br/>



<center><b><big><big>Comparison Changes During Zero Order Forward Mode</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<br/>

<code><i><font color="black"><span style='white-space: nowrap'>c</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>f</span></font></i><font color="blue"><span style='white-space: nowrap'>.CompareChange()</span></font></code>

<code><span style='white-space: nowrap'><br/>
</span></code><b>See Also</b>
<a href="funcheck.xml" target="_top"><span style='white-space: nowrap'>FunCheck</span></a>



<br/>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
We use 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">:</mo>
<msup><mi mathvariant='italic'>B</mi>
<mi mathvariant='italic'>n</mi>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mi mathvariant='italic'>B</mi>
<mi mathvariant='italic'>m</mi>
</msup>
</mrow></math>

 to denote the
<a href="glossary.xml#AD Function" target="_top"><span style='white-space: nowrap'>AD&#xA0;function</span></a>
 corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
.
This function may be not agree with the algorithm that was used
to create the corresponding
AD of 
<code><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i></code>

<a href="glossary.xml#Operation.Sequence" target="_top"><span style='white-space: nowrap'>operation&#xA0;sequence</span></a>

because of changes in AD
<a href="compare.xml" target="_top"><span style='white-space: nowrap'>comparison</span></a>
 results.
The <code><font color="blue">CompareChange</font></code> function can be used to detect these changes.

<br/>
<br/>
<b><big><a name="f" id="f">f</a></big></b>
<br/>
The object 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;ADFun&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>f</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
<br/>
<b><big><a name="c" id="c">c</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>c</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;size_t&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>c</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
It is the number of 

<code><font color="blue"><span style='white-space: nowrap'>AD&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;</span></font></code>
 <a href="compare.xml" target="_top"><span style='white-space: nowrap'>comparison</span></a>
 
operations,
corresponding to the previous call to <a href="forward.xml" target="_top"><span style='white-space: nowrap'>Forward</span></a>
 

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>f</span></font></i><font color="blue"><span style='white-space: nowrap'>.Forward(0,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
that have a different result from
when 
<code><i><font color="black"><span style='white-space: nowrap'>F</span></font></i></code>
 was created by taping an algorithm.

<br/>
<br/>
<b><big><a name="Discussion" id="Discussion">Discussion</a></big></b>
<br/>
If 
<code><i><font color="black"><span style='white-space: nowrap'>c</span></font></i></code>
 is not zero, 
the boolean values resulting from some of the 
<a href="compare.xml" target="_top"><span style='white-space: nowrap'>comparison&#xA0;operations</span></a>
 corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>

are different from when the 
AD of 
<code><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i></code>

<a href="glossary.xml#Operation.Sequence" target="_top"><span style='white-space: nowrap'>operation&#xA0;sequence</span></a>
 was created.
In this case, you may want to re-tape the algorithm with the
<a href="glossary.xml#Tape.Independent Variable" target="_top"><span style='white-space: nowrap'>independent&#xA0;variables</span></a>
 
equal to the values in 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 
(so AD operation sequence properly represents the algorithm
for this value of independent variables).
On the other hand, re-taping the AD operation sequence usually takes 
significantly more time than evaluation using <a href="forward_zero.xml" target="_top"><span style='white-space: nowrap'>forward_zero</span></a>
.
If the functions values have not changed (see <a href="funcheck.xml" target="_top"><span style='white-space: nowrap'>FunCheck</span></a>
)
it may not be worth re-taping a new AD operation sequence. 

<br/>
<br/>
<b><big><a name="Restrictions" id="Restrictions">Restrictions</a></big></b>

<br/>
Computation of this function requires extra operations in the tape.
If <a href="faq.xml#Speed.NDEBUG" target="_top"><span style='white-space: nowrap'>NDEBUG</span></a>
 is defined,
of if a tape <a href="optimize.xml" target="_top"><span style='white-space: nowrap'>optimization</span></a>
 has been preformed,
these operations are not included in the tape and
the value of 
<code><i><font color="black"><span style='white-space: nowrap'>c</span></font></i></code>
 is always zero (and does not correspond
to the actual number of comparison changes).

<br/>
<br/>
<b><big><a name="Example" id="Example">Example</a></big></b>

<br/>
The file
<a href="compare_change.cpp.xml" target="_top"><span style='white-space: nowrap'>compare_change.cpp</span></a>

contains an example and test of this operation.
They return true if they succeed and false otherwise.


<hr/>Input File: omh/forward/compare_change.omh

</body>
</html>