<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>The NumericType: Example and Test</title>
<meta name="description" id="description" content="The NumericType: Example and Test"/>
<meta name="keywords" id="keywords" content=" Numerictype 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='_numeric_type.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="numerictype.xml" target="_top">Prev</a>
</td><td><a href="checknumerictype.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>library</option>
<option>NumericType</option>
<option>numeric_type.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>index_sort</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>NumericType-&gt;</option>
<option>numeric_type.cpp</option>
</select>
</td>
<td>numeric_type.cpp</td>
<td>Headings</td>
</tr></table><br/>


<center><b><big><big>The NumericType: Example and Test</big></big></b></center>
<code><font color="blue"><pre style='display:inline'> 

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

namespace { // Empty namespace

	// -------------------------------------------------------------------
	class MyType {
	private:
		double d;
	public:
		// constructor from void 
		MyType(void) : d(0.)
		{ }
		// constructor from an int 
		MyType(int d_) : d(d_)
		{ }
		// copy constructor
		MyType(const MyType &amp;x) 
		{	d = x.d; }
		// assignment operator
		void operator = (const MyType &amp;x)
		{	d = x.d; }
		// member function that converts to double
		double Double(void) const
		{	return d; }
		// unary plus
		MyType operator + (void) const
		{	MyType x;
			x.d =  d;
			return x; 
		}
		// unary plus
		MyType operator - (void) const
		{	MyType x;
			x.d = - d;
			return x; 
		}
		// binary addition
		MyType operator + (const MyType &amp;x) const
		{	MyType y;
			y.d = d + x.d ;
			return y; 
		}
		// binary subtraction
		MyType operator - (const MyType &amp;x) const
		{	MyType y;
			y.d = d - x.d ;
			return y; 
		}
		// binary multiplication
		MyType operator * (const MyType &amp;x) const
		{	MyType y;
			y.d = d * x.d ;
			return y; 
		}
		// binary division
		MyType operator / (const MyType &amp;x) const
		{	MyType y;
			y.d = d / x.d ;
			return y; 
		}
		// computed assignment addition
		void operator += (const MyType &amp;x)
		{	d += x.d; }
		// computed assignment subtraction
		void operator -= (const MyType &amp;x)
		{	d -= x.d; }
		// computed assignment multiplication
		void operator *= (const MyType &amp;x)
		{	d *= x.d; }
		// computed assignment division
		void operator /= (const MyType &amp;x)
		{	d /= x.d; }
	};
}
bool NumericType(void)
{	bool ok  = true;
	using CppAD::AD;
	using CppAD::CheckNumericType;

	CheckNumericType&lt;MyType&gt;            ();

	CheckNumericType&lt;int&gt;               ();
	CheckNumericType&lt;double&gt;            ();
	CheckNumericType&lt; <a href="ad.xml" target="_top">AD</a>&lt;double&gt; &gt;      ();
	CheckNumericType&lt; <a href="ad.xml" target="_top">AD</a>&lt; <a href="ad.xml" target="_top">AD</a>&lt;double&gt; &gt; &gt;();

	return ok;
}

</pre>

</font></code>


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

</body>
</html>
