<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Atomic Reverse Mode</title>
<meta http-equiv='Content-Type' content='text/html' charset='utf-8'/>
<meta name="description" id="description" content="Atomic Reverse Mode"/>
<meta name="keywords" id="keywords" content=" atomic reverse mode callback virtual syntax purpose implementation q tx ty f g h py px ok examples define use "/>
<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='_atomic_reverse_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="atomic_forward.xml" target="_top">Prev</a>
</td><td><a href="atomic_for_sparse_jac.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-></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-></option>
<option>CppAD</option>
<option>AD</option>
<option>ADValued</option>
<option>atomic</option>
<option>atomic_base</option>
<option>atomic_reverse</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>ADValued-></option>
<option>Arithmetic</option>
<option>std_math_ad</option>
<option>MathOther</option>
<option>CondExp</option>
<option>Discrete</option>
<option>atomic</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>atomic-></option>
<option>checkpoint</option>
<option>atomic_base</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>atomic_base-></option>
<option>atomic_ctor</option>
<option>atomic_option</option>
<option>atomic_afun</option>
<option>atomic_forward</option>
<option>atomic_reverse</option>
<option>atomic_for_sparse_jac</option>
<option>atomic_rev_sparse_jac</option>
<option>atomic_rev_sparse_hes</option>
<option>atomic_base_clear</option>
<option>atomic_get_started.cpp</option>
<option>atomic_norm_sq.cpp</option>
<option>atomic_reciprocal.cpp</option>
<option>atomic_tangent.cpp</option>
<option>atomic_hes_sparse.cpp</option>
<option>atomic_mat_mul.cpp</option>
</select>
</td>
<td>atomic_reverse</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-></option>
<option>Syntax</option>
<option>Purpose</option>
<option>Implementation</option>
<option>q</option>
<option>tx</option>
<option>ty</option>
<option>F, G, H</option>
<option>py</option>
<option>---..px</option>
<option>ok</option>
<option>Examples</option>
<option>---..Define reverse</option>
<option>---..Use reverse</option>
</select>
</td>
</tr></table><br/>
<center><b><big><big>Atomic Reverse 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'>ok</span></font></i><font color="blue"><span style='white-space: nowrap'> = </span></font><i><font color="black"><span style='white-space: nowrap'>afun</span></font></i><font color="blue"><span style='white-space: nowrap'>.reverse(</span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'>, </span></font><i><font color="black"><span style='white-space: nowrap'>tx</span></font></i><font color="blue"><span style='white-space: nowrap'>, </span></font><i><font color="black"><span style='white-space: nowrap'>ty</span></font></i><font color="blue"><span style='white-space: nowrap'>, </span></font><i><font color="black"><span style='white-space: nowrap'>px</span></font></i><font color="blue"><span style='white-space: nowrap'>, </span></font><i><font color="black"><span style='white-space: nowrap'>py</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
<br/>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
This function is used by <a href="reverse.xml" target="_top"><span style='white-space: nowrap'>reverse</span></a>
to compute derivatives.
<br/>
<br/>
<b><big><a name="Implementation" id="Implementation">Implementation</a></big></b>
<br/>
If you are using
<a href="reverse.xml" target="_top"><span style='white-space: nowrap'>reverse</span></a>
mode,
this virtual function must be defined by the
<a href="atomic_ctor.xml#atomic_user" target="_top"><span style='white-space: nowrap'>atomic_user</span></a>
class.
It can just return
<code><i><font color="black"><span style='white-space: nowrap'>ok</span></font></i><font color="blue"><span style='white-space: nowrap'> == false</span></font></code>
(and not compute anything) for values
of
<code><i><font color="black"><span style='white-space: nowrap'>q</span></font></i></code>
that are greater than those used by your
<a href="reverse.xml" target="_top"><span style='white-space: nowrap'>reverse</span></a>
mode calculations.
<br/>
<br/>
<b><big><a name="q" id="q">q</a></big></b>
<br/>
The argument
<code><i><font color="black"><span style='white-space: nowrap'>q</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     size_t </span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
It specifies the highest order Taylor coefficient that
computing the derivative of.
<br/>
<br/>
<b><big><a name="tx" id="tx">tx</a></big></b>
<br/>
The argument
<code><i><font color="black"><span style='white-space: nowrap'>tx</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     const CppAD::vector<</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>>& </span></font><i><font color="black"><span style='white-space: nowrap'>tx</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and
<code><i><font color="black"><span style='white-space: nowrap'>tx</span></font></i><font color="blue"><span style='white-space: nowrap'>.size() == (</span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'>+1)*</span></font><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>
.
For
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>
and
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
</mrow></math>
,
we use the Taylor coefficient notation
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mi mathvariant='italic'>tx</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>X</mi>
<mi mathvariant='italic'>j</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mn>0</mn>
</msubsup>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mn>1</mn>
</msubsup>
<msup><mi mathvariant='italic'>t</mi>
<mn>1</mn>
</msup>
<mo stretchy="false">+</mo>
<mo stretchy="false">⋯</mo>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>q</mi>
</msubsup>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>q</mi>
</msup>
</mtd></mtr></mtable>
</mrow></math>
Note that superscripts represent an index for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
</mrow></math>
and an exponent for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>k</mi>
</msup>
</mrow></math>
.
Also note that the Taylor coefficients for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mrow></math>
correspond
to the derivatives of
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mrow></math>
at
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>
in the following way:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">=</mo>
<mfrac><mrow><mn>1</mn>
</mrow>
<mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">!</mo>
</mrow>
</mfrac>
<msubsup><mi mathvariant='italic'>X</mi>
<mi mathvariant='italic'>j</mi>
<mrow><mo stretchy="false">(</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow></math>
<br/>
<b><big><a name="ty" id="ty">ty</a></big></b>
<br/>
The argument
<code><i><font color="black"><span style='white-space: nowrap'>ty</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     const CppAD::vector<</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>>& </span></font><i><font color="black"><span style='white-space: nowrap'>ty</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and
<code><i><font color="black"><span style='white-space: nowrap'>tx</span></font></i><font color="blue"><span style='white-space: nowrap'>.size() == (</span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'>+1)*</span></font><i><font color="black"><span style='white-space: nowrap'>m</span></font></i></code>
.
For
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>m</mi>
<mn>-1</mn>
</mrow></math>
and
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
</mrow></math>
,
we use the Taylor coefficient notation
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>Y</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>f</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">]</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>Y</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mn>0</mn>
</msubsup>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mn>1</mn>
</msubsup>
<msup><mi mathvariant='italic'>t</mi>
<mn>1</mn>
</msup>
<mo stretchy="false">+</mo>
<mo stretchy="false">⋯</mo>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>q</mi>
</msubsup>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>q</mi>
</msup>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>o</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>q</mi>
</msup>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mi mathvariant='italic'>ty</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
</mtd></mtr></mtable>
</mrow></math>
where
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>o</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>q</mi>
</msup>
<mo stretchy="false">)</mo>
<mo stretchy="false">/</mo>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>q</mi>
</msup>
<mo stretchy="false">→</mo>
<mn>0</mn>
</mrow></math>
as
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">→</mo>
<mn>0</mn>
</mrow></math>
.
Note that superscripts represent an index for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
</mrow></math>
and an exponent for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>k</mi>
</msup>
</mrow></math>
.
Also note that the Taylor coefficients for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>Y</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mrow></math>
correspond
to the derivatives of
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>Y</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mrow></math>
at
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>
in the following way:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">=</mo>
<mfrac><mrow><mn>1</mn>
</mrow>
<mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">!</mo>
</mrow>
</mfrac>
<msubsup><mi mathvariant='italic'>Y</mi>
<mi mathvariant='italic'>j</mi>
<mrow><mo stretchy="false">(</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow></math>
<br/>
<b><big><a name="F, G, H" id="F, G, H">F, G, H</a></big></b>
<br/>
We use the notation
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">∈</mo>
<msup><mi mathvariant='italic'>B</mi>
<mrow><mi mathvariant='italic'>n</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
</mrow></math>
for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mspace width='.3em'/>
<mo stretchy="false">:</mo>
<mspace width='.3em'/>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">}</mo>
</mrow></math>
We use the notation
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">∈</mo>
<msup><mi mathvariant='italic'>B</mi>
<mrow><mi mathvariant='italic'>m</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
</mrow></math>
for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mspace width='.3em'/>
<mo stretchy="false">:</mo>
<mspace width='.3em'/>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>m</mi>
<mn>-1</mn>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">}</mo>
</mrow></math>
We define the function
<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>
<mrow><mi mathvariant='italic'>n</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
<mo stretchy="false">→</mo>
<msup><mi mathvariant='italic'>B</mi>
<mrow><mi mathvariant='italic'>m</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
</mrow></math>
by
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">=</mo>
<msubsup><mi mathvariant='italic'>F</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">[</mo>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">]</mo>
</mrow></math>
We use
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">:</mo>
<msup><mi mathvariant='italic'>B</mi>
<mrow><mi mathvariant='italic'>m</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
<mo stretchy="false">→</mo>
<mi mathvariant='italic'>B</mi>
</mrow></math>
to denote an arbitrary scalar valued function of
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
</mrow></math>
.
We use
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>H</mi>
<mo stretchy="false">:</mo>
<msup><mi mathvariant='italic'>B</mi>
<mrow><mi mathvariant='italic'>n</mi>
<mo stretchy="false">×</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msup>
<mo stretchy="false">→</mo>
<mi mathvariant='italic'>B</mi>
</mrow></math>
defined by
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>H</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">)</mo>
<mo stretchy="false">]</mo>
</mrow></math>
<br/>
<b><big><a name="py" id="py">py</a></big></b>
<br/>
The argument
<code><i><font color="black"><span style='white-space: nowrap'>py</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     const CppAD::vector<</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>>& </span></font><i><font color="black"><span style='white-space: nowrap'>py</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and
<code><i><font color="black"><span style='white-space: nowrap'>py</span></font></i><font color="blue"><span style='white-space: nowrap'>.size() == m * (</span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'>+1)</span></font></code>
.
For
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>m</mi>
<mn>-1</mn>
</mrow></math>
,
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
</mrow></math>
,
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>py</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
<mo stretchy="false">=</mo>
<mo stretchy="false">∂</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
</mrow></math>
<br/>
<b><a name="py.px" id="py.px">px</a></b>
<br/>
The
<code><i><font color="black"><span style='white-space: nowrap'>px</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     CppAD::vector<</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>>& </span></font><i><font color="black"><span style='white-space: nowrap'>px</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and
<code><i><font color="black"><span style='white-space: nowrap'>px</span></font></i><font color="blue"><span style='white-space: nowrap'>.size() == n * (</span></font><i><font color="black"><span style='white-space: nowrap'>q</span></font></i><font color="blue"><span style='white-space: nowrap'>+1)</span></font></code>
.
The input values of the elements of
<code><i><font color="black"><span style='white-space: nowrap'>px</span></font></i></code>
are not specified (must not matter).
Upon return,
for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>
and
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">ℓ</mo>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">…</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>q</mi>
</mrow></math>
,
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mi mathvariant='italic'>px</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mo stretchy="false">ℓ</mo>
<mo stretchy="false">]</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mo stretchy="false">∂</mo>
<mi mathvariant='italic'>H</mi>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">ℓ</mo>
</msubsup>
</mtd></mtr><mtr><mtd columnalign="right" >
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mo stretchy="false">(</mo>
<mo stretchy="false">∂</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<mo stretchy="false">∂</mo>
<mo stretchy="false">{</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">}</mo>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">ℓ</mo>
</msubsup>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<munderover><mo displaystyle='true' largeop='true'>∑</mo>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow>
<mrow><mi mathvariant='italic'>m</mi>
<mn>-1</mn>
</mrow>
</munderover>
<munderover><mo displaystyle='true' largeop='true'>∑</mo>
<mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow>
<mi mathvariant='italic'>q</mi>
</munderover>
<mo stretchy="false">(</mo>
<mo stretchy="false">∂</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">ℓ</mo>
</msubsup>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<munderover><mo displaystyle='true' largeop='true'>∑</mo>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow>
<mrow><mi mathvariant='italic'>m</mi>
<mn>-1</mn>
</mrow>
</munderover>
<munderover><mo displaystyle='true' largeop='true'>∑</mo>
<mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">=</mo>
<mo stretchy="false">ℓ</mo>
</mrow>
<mi mathvariant='italic'>q</mi>
</munderover>
<mi mathvariant='italic'>py</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>q</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
<mo stretchy="false">(</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>F</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">ℓ</mo>
</msubsup>
<mo stretchy="false">)</mo>
</mtd></mtr></mtable>
</mrow></math>
Note that we have used the fact that for
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false"><</mo>
<mo stretchy="false">ℓ</mo>
</mrow></math>
,
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>F</mi>
<mi mathvariant='italic'>i</mi>
<mi mathvariant='italic'>k</mi>
</msubsup>
<mo stretchy="false">/</mo>
<mo stretchy="false">∂</mo>
<msubsup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">ℓ</mo>
</msubsup>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>
.
<br/>
<br/>
<b><big><a name="ok" id="ok">ok</a></big></b>
<br/>
The return value
<code><i><font color="black"><span style='white-space: nowrap'>ok</span></font></i></code>
has prototype
<code><font color="blue"><span style='white-space: nowrap'><br/>
     bool </span></font><i><font color="black"><span style='white-space: nowrap'>ok</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
If it is <code><font color="blue">true</font></code>, the corresponding evaluation succeeded,
otherwise it failed.
<br/>
<br/>
<b><big><a name="Examples" id="Examples">Examples</a></big></b>
<br/>
<br/>
<b><a name="Examples.Define reverse" id="Examples.Define reverse">Define reverse</a></b>
<br/>
The following files contain example atomic <code><font color="blue">reverse</font></code> functions:
<a href="atomic_norm_sq.cpp.xml#reverse" target="_top"><span style='white-space: nowrap'>norm_sq.cpp</span></a>
,
<a href="atomic_reciprocal.cpp.xml#reverse" target="_top"><span style='white-space: nowrap'>reciprocal.cpp</span></a>
,
<a href="atomic_tangent.cpp.xml#reverse" target="_top"><span style='white-space: nowrap'>tangent.cpp</span></a>
,
<a href="atomic_matrix_mul.hpp.xml#reverse" target="_top"><span style='white-space: nowrap'>matrix_mul.hpp</span></a>
.
<br/>
<br/>
<b><a name="Examples.Use reverse" id="Examples.Use reverse">Use reverse</a></b>
<br/>
The following are links to user atomic function constructor uses:
<a href="atomic_norm_sq.cpp.xml#Use Atomic Function.reverse" target="_top"><span style='white-space: nowrap'>norm_sq.cpp</span></a>
,
<a href="atomic_reciprocal.cpp.xml#Use Atomic Function.reverse" target="_top"><span style='white-space: nowrap'>reciprocal.cpp</span></a>
,
<a href="atomic_tangent.cpp.xml#Use Atomic Function.reverse" target="_top"><span style='white-space: nowrap'>tangent.cpp</span></a>
,
<a href="atomic_mat_mul.cpp.xml#Use Atomic Function.reverse" target="_top"><span style='white-space: nowrap'>mat_mul.cpp</span></a>
.
<hr/>Input File: cppad/local/atomic_base.hpp
</body>
</html>