<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Compare AD with Base Objects: Example and Test</title>
<meta name="description" id="description" content="Compare AD with Base Objects: Example and Test"/>
<meta name="keywords" id="keywords" content=" Nearequalext 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='_near_equal_ext.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="nearequalext.xml" target="_top">Prev</a>
</td><td><a href="boolfun.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>AD</option>
<option>BoolValued</option>
<option>NearEqualExt</option>
<option>near_equal_ext.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>AD-&gt;</option>
<option>ad_ctor</option>
<option>ad_assign</option>
<option>Convert</option>
<option>ADValued</option>
<option>BoolValued</option>
<option>VecAD</option>
<option>base_require</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>BoolValued-&gt;</option>
<option>Compare</option>
<option>NearEqualExt</option>
<option>BoolFun</option>
<option>ParVar</option>
<option>EqualOpSeq</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>NearEqualExt-&gt;</option>
<option>near_equal_ext.cpp</option>
</select>
</td>
<td>near_equal_ext.cpp</td>
<td>Headings</td>
</tr></table><br/>



<center><b><big><big>Compare AD with Base Objects: Example and Test</big></big></b></center>
<code><font color="blue"><pre style='display:inline'> 

# include &lt;cppad/cppad.hpp&gt;
# include &lt;complex&gt;

bool NearEqualExt(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// double 
	double x    = 1.00000;
	double y    = 1.00001;
	double a    =  .00005;
	double r    =  .00005;
	double zero = 0.; 

	// <a href="ad.xml" target="_top">AD</a>&lt;double&gt; 
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; ax(x);
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; ay(y);

	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(ax, ay, zero, a);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(ax, y,  r, zero);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(x, ay,  r,    a);

	// std::complex&lt;double&gt; 
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; cx(x);
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; cy(y);

	// <a href="ad.xml" target="_top">AD</a>&lt; std::complex&lt;double&gt; &gt; 
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; acx(x);
	<a href="ad.xml" target="_top">AD</a>&lt;double&gt; acy(y);

	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(acx, acy, zero, a);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(acx,  cy, r, zero);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(acx,   y, r,    a);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>( cx, acy, r,    a);
	ok &amp;= <a href="nearequal.xml" target="_top">NearEqual</a>(  x, acy, r,    a);

	return ok;
}

</pre>

</font></code>


<hr/>Input File: example/near_equal_ext.cpp

</body>
</html>
