<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Speed Testing Sparse Jacobian</title>
<meta name="description" id="description" content="Speed Testing Sparse Jacobian"/>
<meta name="keywords" id="keywords" content=" link_sparse_jacobian sparse speed test "/>
<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='_link_sparse_jacobian_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="link_sparse_hessian.xml" target="_top">Prev</a>
</td><td><a href="microsoft_timer.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>Appendix</option>
<option>speed</option>
<option>speed_main</option>
<option>link_sparse_jacobian</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>Appendix-&gt;</option>
<option>Faq</option>
<option>speed</option>
<option>Theory</option>
<option>glossary</option>
<option>Bib</option>
<option>Bugs</option>
<option>WishList</option>
<option>whats_new</option>
<option>deprecated</option>
<option>License</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>speed-&gt;</option>
<option>speed_main</option>
<option>speed_utility</option>
<option>speed_double</option>
<option>speed_adolc</option>
<option>speed_cppad</option>
<option>speed_fadbad</option>
<option>speed_sacado</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>speed_main-&gt;</option>
<option>link_det_lu</option>
<option>link_det_minor</option>
<option>link_mat_mul</option>
<option>link_ode</option>
<option>link_poly</option>
<option>link_sparse_hessian</option>
<option>link_sparse_jacobian</option>
<option>microsoft_timer</option>
</select>
</td>
<td>link_sparse_jacobian</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Prototype</option>
<option>f</option>
<option>repeat</option>
<option>x</option>
<option>i</option>
<option>j</option>
<option>jacobian</option>
<option>---..double</option>
</select>
</td>
</tr></table><br/>








<center><b><big><big>Speed Testing Sparse Jacobian</big></big></b></center>
<br/>
<b><big><a name="Prototype" id="Prototype">Prototype</a></big></b>

<br/>

<code><font color="blue"><span style='white-space: nowrap'>extern&#xA0;bool&#xA0;link_sparse_jacobian(<br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;size_t&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>repeat</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;&#xA0;&#xA0;,<br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;CppAD::vector&lt;double&gt;&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;,<br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;CppAD::vector&lt;size_t&gt;&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;,<br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;CppAD::vector&lt;size_t&gt;&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;,&#xA0;<br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;CppAD::vector&lt;double&gt;&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>jacobian</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
);<br/>
</span></font></code>
<br/>
<b><big><a name="f" id="f">f</a></big></b>
<br/>
Given a first index vector 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
</mrow></math>

 and a second index vector 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
</mrow></math>

,
the corresponding function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">:</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>n</mi>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mo stretchy="false">&#x02113;</mo>
</msup>
</mrow></math>

 is defined by <a href="sparse_evaluate.xml" target="_top"><span style='white-space: nowrap'>sparse_evaluate</span></a>

and the index vectors 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 and 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
.
The function 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 is defined by

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>g</mi>
<mi mathvariant='italic'>k</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>f</mi>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>x</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
</mrow>
</msub>
</mrow>
</mfrac>
</mrow></math>

The non-zero entries in the Jacobian of this function have the form

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>g</mi>
<mi mathvariant='italic'>k</mi>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
<mo stretchy="false">]</mo>
</mrow>
</mfrac>
</mrow></math>

or

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>g</mi>
<mi mathvariant='italic'>k</mi>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
<mo stretchy="false">]</mo>
</mrow>
</mfrac>
</mrow></math>

for some 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
</mrow></math>

 between zero and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mn>-1</mn>
</mrow></math>

.
All the other terms of the Jacobian are zero.

<br/>
<br/>
<b><big><a name="repeat" id="repeat">repeat</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>repeat</span></font></i></code>
 is the number of different functions

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 that the Jacobian is computed for.
Each function corresponds to a randomly chosen index vectors, i.e.,
for each repetition a random choice is made for

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
</mrow></math>

 and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">]</mo>
</mrow></math>

 for 
<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">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02113;</mo>
<mn>-1</mn>
</mrow></math>

.

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

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;CppAD::vector&lt;double&gt;&#xA0;&amp;</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>
The size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 determines 
and is equal to the value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
</mrow></math>

.
The input value of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 does not matter.
On output, it has been set to the
argument value for which the function,
or its derivative, is being evaluated.
The value of this vector need not change with each repetition.

<br/>
<br/>
<b><big><a name="i" id="i">i</a></big></b>
<br/>
The size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 determines and is equal to
the value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
</mrow></math>

.
The input value of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 does not matter.
On output, it has been set the first index vector
for the last repetition.
All the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 must are between zero and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="j" id="j">j</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
 is a vector with size 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
</mrow></math>

.
The input value of its elements does not matter.
On output, it has been set the second index vector
for the last repetition.
All the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 must are between zero and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="jacobian" id="jacobian">jacobian</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>jacobian</span></font></i></code>
 is a vector with 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">&#x000D7;</mo>
<mi mathvariant='italic'>n</mi>
</mrow></math>

 elements.
The input value of its elements does not matter. 
The output value of its elements is the Jacobian of the function 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>


that corresponds to output values of 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
, 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
, and 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
.
To be more specific, for

<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">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">-</mo>
<mn>1</mn>
</mrow></math>

,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>m</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>

,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>g</mi>
<mi mathvariant='italic'>k</mi>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>m</mi>
<mo stretchy="false">]</mo>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>jacobian</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">*</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>m</mi>
<mo stretchy="false">]</mo>
</mrow></math>

<br/>
<b><a name="jacobian.double" id="jacobian.double">double</a></b>
<br/>
In the case where 
<code><i><font color="black"><span style='white-space: nowrap'>package</span></font></i></code>
 is <code><font color="blue">double</font></code>,
only the first 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
</mrow></math>

 
elements of 
<code><i><font color="black"><span style='white-space: nowrap'>jacobian</span></font></i></code>
 are used and they are set to
the value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 (
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>g</mi>
<mo stretchy="false">'</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 is not computed).


<hr/>Input File: speed/src/link_sparse_jacobian.cpp

</body>
</html>

