Codebase list cppad / upstream/2015.00.00.7 doc / base_float.hpp.xml
upstream/2015.00.00.7

Tree @upstream/2015.00.00.7 (Download .tar.gz)

base_float.hpp.xml @upstream/2015.00.00.7raw · history · blame

<?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 float</title>
<meta http-equiv='Content-Type' content='text/html' charset='utf-8'/>
<meta name="description" id="description" content="Enable use of AD&lt;Base&gt; where Base is float"/>
<meta name="keywords" id="keywords" content=" float Base enable use of ad&lt;base&gt; where base is condexpop condexprel equalopseq identical integer ordered unary standard math sign pow limits "/>
<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_float.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="mul_level_adolc.cpp.xml" target="_top">Prev</a>
</td><td><a href="base_double.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_float.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_float.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 float</big></big></b></center>
<br/>
<b><big><a name="CondExpOp" id="CondExpOp">CondExpOp</a></big></b>
<br/>
The type <code><font color="blue">float</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 float CondExpOp( 
		enum CompareOp     cop          ,
		const float&amp;       left         ,
		const float&amp;       right        , 
		const float&amp;       exp_if_true  , 
		const float&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(float)
}
</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">float</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">float</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 float&amp; x, const float&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">float</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 float&amp; x)
	{	return true; }
	inline bool IdenticalZero(const float&amp; x)
	{	return (x == 0.f); }
	inline bool IdenticalOne(const float&amp; x)
	{	return (x == 1.f); }
	inline bool IdenticalEqualPar(const float&amp; x, const float&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 float&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">float</font></code> type supports ordered comparisons
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline bool GreaterThanZero(const float&amp; x)
	{	return x &gt; 0.f; }
	inline bool GreaterThanOrZero(const float&amp; x)
	{	return x &gt;= 0.f; }
	inline bool LessThanZero(const float&amp; x)
	{	return x &lt; 0.f; }
	inline bool LessThanOrZero(const float&amp; x)
	{	return x &lt;= 0.f; }
	inline bool abs_geq(const float&amp; x, const float&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;float&gt;</font></code>:
(in the CppAD namespace)
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	CPPAD_STANDARD_MATH_UNARY(float, acos)
	CPPAD_STANDARD_MATH_UNARY(float, asin)
	CPPAD_STANDARD_MATH_UNARY(float, atan)
	CPPAD_STANDARD_MATH_UNARY(float, cos)
	CPPAD_STANDARD_MATH_UNARY(float, cosh)
	CPPAD_STANDARD_MATH_UNARY(float, exp)
	CPPAD_STANDARD_MATH_UNARY(float, fabs)
	CPPAD_STANDARD_MATH_UNARY(float, log)
	CPPAD_STANDARD_MATH_UNARY(float, log10)
	CPPAD_STANDARD_MATH_UNARY(float, sin)
	CPPAD_STANDARD_MATH_UNARY(float, sinh)
	CPPAD_STANDARD_MATH_UNARY(float, sqrt)
	CPPAD_STANDARD_MATH_UNARY(float, tan)
	CPPAD_STANDARD_MATH_UNARY(float, tanh)
# if CPPAD_COMPILER_HAS_ERF
	CPPAD_STANDARD_MATH_UNARY(float, erf)
# endif
}
</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 float abs(const float&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;float&gt;</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline float sign(const float&amp; x)
	{	if( x &gt; 0.f )
			return 1.f;
		if( x == 0.f )
			return 0.f;
		return -1.f;
	}
}
</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;float&gt;</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	inline float pow(const float&amp; x, const float&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">float</font></code>:
<code><font color='blue'><pre style='display:inline'> 
namespace CppAD {
	template &lt;&gt;
	class numeric_limits&lt;float&gt; {
	public:
		// machine epsilon
		static float epsilon(void)
		{	return std::numeric_limits&lt;float&gt;::epsilon(); }
		// minimum positive normalized value
		static float min(void)
		{	return std::numeric_limits&lt;float&gt;::min(); }
		// maximum finite value
		static float max(void)
		{	return std::numeric_limits&lt;float&gt;::max(); }
	};
	// deprecated machine epsilon
	template &lt;&gt; 
	inline float epsilon&lt;float&gt;(void)
	{	return numeric_limits&lt;float&gt;::epsilon(); }
}
</pre></font></code>


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

</body>
</html>