<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Enable use of AD&lt;Base&gt; where Base is double</title>
<meta name="description" id="description" content="Enable use of AD&lt;Base&gt; where Base is double"/>
<meta name="keywords" id="keywords" content=" double Base "/>
<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='_base_double.hpp_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="base_float.hpp.xml" target="_top">Prev</a>
</td><td><a href="base_complex.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>AD</option>
<option>base_require</option>
<option>base_example</option>
<option>base_double.hpp</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>base_require-&gt;</option>
<option>base_member</option>
<option>base_cond_exp</option>
<option>base_identical</option>
<option>base_ordered</option>
<option>base_std_math</option>
<option>base_example</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>base_example-&gt;</option>
<option>base_alloc.hpp</option>
<option>base_require.cpp</option>
<option>base_adolc.hpp</option>
<option>base_float.hpp</option>
<option>base_double.hpp</option>
<option>base_complex.hpp</option>
</select>
</td>
<td>base_double.hpp</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>CondExpOp</option>
<option>CondExpRel</option>
<option>EqualOpSeq</option>
<option>Identical</option>
<option>Integer</option>
<option>Ordered</option>
<option>Unary Standard Math</option>
<option>sign</option>
<option>pow</option>
<option>limits</option>
</select>
</td>
</tr></table><br/>







<center><b><big><big>Enable use of AD&lt;Base&gt; where Base is double</big></big></b></center>
<br/>
<b><big><a name="CondExpOp" id="CondExpOp">CondExpOp</a></big></b>
<br/>
The type <code><font color="blue">double</font></code> is a relatively simple type that supports
<code><font color="blue">&lt;</font></code>, <code><font color="blue">&lt;=</font></code>, <code><font color="blue">==</font></code>, <code><font color="blue">&gt;=</font></code>, and <code><font color="blue">&gt;</font></code> operators; see
<a href="base_cond_exp.xml#CondExpTemplate.Ordered Type" target="_top"><span style='white-space: nowrap'>ordered&#xA0;type</span></a>
.
Hence its <code><font color="blue">CondExpOp</font></code> function is defined by
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline double CondExpOp( 
		enum CompareOp     cop          ,
		const double&amp;       left         ,
		const double&amp;       right        , 
		const double&amp;       exp_if_true  , 
		const double&amp;       exp_if_false )
	{	return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false);
	}
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="CondExpRel" id="CondExpRel">CondExpRel</a></big></b>
<br/>
The <a href="base_cond_exp.xml#CondExpRel" target="_top"><span style='white-space: nowrap'>CPPAD_COND_EXP_REL</span></a>
 macro invocation
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	CPPAD_COND_EXP_REL(double)
}
</pre></font></code>

uses <code><font color="blue">CondExpOp</font></code> above to
define 
<code><font color="blue"><span style='white-space: nowrap'>CondExp</span></font><i><font color="black"><span style='white-space: nowrap'>Rel</span></font></i></code>
 for <code><font color="blue">double</font></code> arguments
and 
<code><i><font color="black"><span style='white-space: nowrap'>Rel</span></font></i></code>
 equal to
<code><font color="blue">Lt</font></code>, <code><font color="blue">Le</font></code>, <code><font color="blue">Eq</font></code>, <code><font color="blue">Ge</font></code>, and <code><font color="blue">Gt</font></code>.

<br/>
<br/>
<b><big><a name="EqualOpSeq" id="EqualOpSeq">EqualOpSeq</a></big></b>
<br/>
The type <code><font color="blue">double</font></code> is simple (in this respect) and so we define
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline bool EqualOpSeq(const double&amp; x, const double&amp; y)
	{	return x == y; }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="Identical" id="Identical">Identical</a></big></b>
<br/>
The type <code><font color="blue">double</font></code> is simple (in this respect) and so we define
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline bool IdenticalPar(const double&amp; x)
	{	return true; }
	inline bool IdenticalZero(const double&amp; x)
	{	return (x == 0.); }
	inline bool IdenticalOne(const double&amp; x)
	{	return (x == 1.); }
	inline bool IdenticalEqualPar(const double&amp; x, const double&amp; y)
	{	return (x == y); }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="Integer" id="Integer">Integer</a></big></b>

<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline int Integer(const double&amp; x)
	{	return static_cast&lt;int&gt;(x); }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="Ordered" id="Ordered">Ordered</a></big></b>
<br/>
The <code><font color="blue">double</font></code> type supports ordered comparisons
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline bool GreaterThanZero(const double&amp; x)
	{	return x &gt; 0.; }
	inline bool GreaterThanOrZero(const double&amp; x)
	{	return x &gt;= 0.; }
	inline bool LessThanZero(const double&amp; x)
	{	return x &lt; 0.; }
	inline bool LessThanOrZero(const double&amp; x)
	{	return x &lt;= 0.; }
	inline bool abs_geq(const double&amp; x, const double&amp; y)
	{	return std::fabs(x) &gt;= std::fabs(y); }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="Unary Standard Math" id="Unary Standard Math">Unary Standard Math</a></big></b>
<br/>
The following macro invocations define the unary standard math functions
required to use <code><font color="blue">AD&lt;double&gt;</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	CPPAD_STANDARD_MATH_UNARY(double, acos)
	CPPAD_STANDARD_MATH_UNARY(double, asin)
	CPPAD_STANDARD_MATH_UNARY(double, atan)
	CPPAD_STANDARD_MATH_UNARY(double, cos)
	CPPAD_STANDARD_MATH_UNARY(double, cosh)
	CPPAD_STANDARD_MATH_UNARY(double, exp)
	CPPAD_STANDARD_MATH_UNARY(double, fabs)
	CPPAD_STANDARD_MATH_UNARY(double, log)
	CPPAD_STANDARD_MATH_UNARY(double, log10)
	CPPAD_STANDARD_MATH_UNARY(double, sin)
	CPPAD_STANDARD_MATH_UNARY(double, sinh)
	CPPAD_STANDARD_MATH_UNARY(double, sqrt)
	CPPAD_STANDARD_MATH_UNARY(double, tan)
	CPPAD_STANDARD_MATH_UNARY(double, tanh)
}
</pre></font></code>

The absolute value function is special because its <code><font color="blue">std</font></code> name is 
<code><font color="blue">fabs</font></code>
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline double abs(const double&amp; x)
	{	return std::fabs(x); }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="sign" id="sign">sign</a></big></b>
<br/>
The following defines the <code><font color="blue">CppAD::sign</font></code> function that
is required to use <code><font color="blue">AD&lt;double&gt;</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline double sign(const double&amp; x)
	{	if( x &gt; 0. )
			return 1.;
		if( x == 0. )
			return 0.;
		return -1.;
	}
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="pow" id="pow">pow</a></big></b>
<br/>
The following defines a <code><font color="blue">CppAD::pow</font></code> function that
is required to use <code><font color="blue">AD&lt;double&gt;</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline double pow(const double&amp; x, const double&amp; y)
	{ return std::pow(x, y); }
}
</pre></font></code>


<br/>
<br/>
<b><big><a name="limits" id="limits">limits</a></big></b>
<br/>
The following defines the numeric limits functions
<code><font color="blue">epsilon</font></code>, <code><font color="blue">min</font></code>, and <code><font color="blue">max</font></code> for the type
<code><font color="blue">double</font></code>.
It also defines the deprecated <code><font color="blue">epsilon</font></code> function:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	template &lt;&gt;
	class numeric_limits&lt;double&gt; {
	public:
		// machine epsilon
		static double epsilon(void)
		{	return std::numeric_limits&lt;double&gt;::epsilon(); }
		// minimum positive normalized value
		static double min(void)
		{	return std::numeric_limits&lt;double&gt;::min(); }
		// maximum finite value
		static double max(void)
		{	return std::numeric_limits&lt;double&gt;::max(); }
	};
	// deprecated machine epsilon
	template &lt;&gt; 
	inline double epsilon&lt;double&gt;(void)
	{	return numeric_limits&lt;double&gt;::epsilon(); }
}
</pre></font></code>


<hr/>Input File: cppad/local/base_double.hpp

</body>
</html>
