<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Determinant of a Minor: Example and Test</title>
<meta name="description" id="description" content="Determinant of a Minor: Example and Test"/>
<meta name="keywords" id="keywords" content=" det_of_minor example 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='_det_of_minor.cpp_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="det_of_minor.xml" target="_top">Prev</a>
</td><td><a href="det_of_minor.hpp.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>speed</option>
<option>speed_utility</option>
<option>det_of_minor</option>
<option>det_of_minor.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(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_down2(this)'>
<option>speed_utility-&gt;</option>
<option>det_by_lu</option>
<option>det_of_minor</option>
<option>det_by_minor</option>
<option>det_33</option>
<option>det_grad_33</option>
<option>mat_sum_sq</option>
<option>ode_evaluate</option>
<option>sparse_jac_fun</option>
<option>sparse_hes_fun</option>
<option>uniform_01</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>det_of_minor-&gt;</option>
<option>det_of_minor.cpp</option>
<option>det_of_minor.hpp</option>
</select>
</td>
<td>det_of_minor.cpp</td>
<td>Headings</td>
</tr></table><br/>



<center><b><big><big>Determinant of a Minor: Example and Test</big></big></b></center>
<code><font color="blue"><pre style='display:inline'> 
# include &lt;vector&gt;
# include &lt;cstddef&gt;
# include &lt;cppad/speed/det_of_minor.hpp&gt;

bool det_of_minor()
{	bool   ok = true;
	size_t i;

	// dimension of the matrix A
	size_t m = 3;
	// index vectors set so minor is the entire matrix A
	std::vector&lt;size_t&gt; r(m + 1);
	std::vector&lt;size_t&gt; c(m + 1);
	for(i= 0; i &lt; m; i++)
	{	r[i] = i+1;
		c[i] = i+1;
	}	
	r[m] = 0;
	c[m] = 0;
	// values in the matrix A
	double  data[] = {
		1., 2., 3., 
		3., 2., 1., 
		2., 1., 2.
	};
	// construct vector a with the values of the matrix A
	std::vector&lt;double&gt; a(data, data + 9);

	// evaluate the determinant of A
	size_t n   = m; // minor has same dimension as A
	double det = CppAD::det_of_minor(a, m, n, r, c);

	// check the value of the determinant of A
	ok &amp;= (det == (double) (1*(2*2-1*1) - 2*(3*2-1*2) + 3*(3*1-2*2)) );

	// minor where row 0 and column 1 are removed
	r[m] = 1;  // skip row index 0 by starting at row index 1
	c[0] = 2;  // skip column index 1 by pointing from index 0 to index 2
	// evaluate determinant of the minor 
	n   = m - 1; // dimension of the minor
	det = CppAD::det_of_minor(a, m, m-1, r, c);

	// check the value of the determinant of the minor
	ok &amp;= (det == (double) (3*2-1*2) );

	return ok;
}
</pre>

</font></code>


<hr/>Input File: speed/example/det_of_minor.cpp

</body>
</html>
