<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Numeric Limits For an AD and Base Types</title>
<meta name="description" id="description" content="Numeric Limits For an AD and Base Types"/>
<meta name="keywords" id="keywords" content=" limits Ad epsilon limit max min "/>
<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='_limits_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="pow.cpp.xml" target="_top">Prev</a>
</td><td><a href="limits.cpp.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>ADValued</option>
<option>MathOther</option>
<option>limits</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>ADValued-&gt;</option>
<option>Arithmetic</option>
<option>std_math_ad</option>
<option>MathOther</option>
<option>CondExp</option>
<option>Discrete</option>
<option>atomic</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>MathOther-&gt;</option>
<option>abs</option>
<option>sign</option>
<option>atan2</option>
<option>erf</option>
<option>pow</option>
<option>limits</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>limits-&gt;</option>
<option>limits.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Purpose</option>
<option>Float</option>
<option>eps</option>
<option>min</option>
<option>max</option>
<option>Example</option>
</select>
</td>
</tr></table><br/>









<center><b><big><big>Numeric Limits For an AD and Base Types</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<br/>

<code><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;numeric_limits&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;::epsilon()<br/>
</span></font></code>

<code><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;numeric_limits&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;::min()<br/>
</span></font></code>

<code><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;numeric_limits&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;::max()<br/>
</span></font></code>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
Obtain the value of some of the C++ standard numeric limits
using the CppAD namespace version of <code><font color="blue">numeric_limits</font></code>.
These are all functions and have the prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;numeric_limits&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;::</span></font><i><font color="black"><span style='white-space: nowrap'>fun</span></font></i><font color="blue"><span style='white-space: nowrap'>(</span></font><i><font color="black"><span style='white-space: nowrap'>void</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
where 
<code><i><font color="black"><span style='white-space: nowrap'>fun</span></font></i></code>
 is <code><font color="blue">epsilon</font></code>, <code><font color="blue">min</font></code>, or <code><font color="blue">max</font></code>.
<code><span style='white-space: nowrap'><br/>
<br/>
</span></code>Note that C++ standard specifies that Non-fundamental standard
types, such as 
<code><font color="blue"><span style='white-space: nowrap'>std::complex&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>T</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;</span></font></code>
 shall not have specializations
of <code><font color="blue">std::numeric_limits</font></code>; see Section 18.2 of
ISO/IEC 14882:1998(E).

<br/>
<br/>
<b><big><a name="Float" id="Float">Float</a></big></b>
<br/>
These functions are defined for all 
<code><font color="blue"><span style='white-space: nowrap'>AD&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;</span></font></code>
,
and for all corresponding 
<code><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i></code>
 types;
see 
<code><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i></code>
 type <a href="base_std_math.xml#limits" target="_top"><span style='white-space: nowrap'>limits</span></a>
.

<br/>
<br/>
<b><big><a name="eps" id="eps">eps</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i></code>
 is equal to machine epsilon and has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
CppAD tests the value 
<code><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i></code>
 by checking that the following are true

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;1&#xA0;!=&#xA0;1&#xA0;+&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;1&#xA0;==&#xA0;1&#xA0;+&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;/&#xA0;2<br/>
</span></font></code>
where all the values, and calculations, are done with the precision
corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i></code>
.
	

<br/>
<br/>
<b><big><a name="min" id="min">min</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>min</span></font></i></code>
 is equal to 
the minimum positive normalized value and has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
CppAD tests the value 
<code><i><font color="black"><span style='white-space: nowrap'>min</span></font></i></code>
 by checking that the following are true

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;abs(&#xA0;((</span></font><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;/&#xA0;100)&#xA0;*&#xA0;100)&#xA0;/&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;-&#xA0;1&#xA0;)&#xA0;&gt;&#xA0;3&#xA0;*&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;abs(&#xA0;((</span></font><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;*&#xA0;100)&#xA0;/&#xA0;(100&#xA0;*&#xA0;(1&#xA0;-&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'>))&#xA0;/&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>min</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;-&#xA0;1&#xA0;)&#xA0;&lt;&#xA0;3&#xA0;*&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
where all the values, and calculations, are done with the precision
corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i></code>
.

<br/>
<br/>
<b><big><a name="max" id="max">max</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>max</span></font></i></code>
 is equal to 
the maximum finite value and has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
CppAD tests the value 
<code><i><font color="black"><span style='white-space: nowrap'>max</span></font></i></code>
 by checking that the following are true

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;abs(&#xA0;((</span></font><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;*&#xA0;100)&#xA0;/&#xA0;100)&#xA0;/&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;-&#xA0;1&#xA0;)&#xA0;&gt;&#xA0;3&#xA0;*&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;abs(&#xA0;((</span></font><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;/&#xA0;100)&#xA0;*&#xA0;(100&#xA0;*&#xA0;(1&#xA0;-&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'>))&#xA0;/&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>max</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;-&#xA0;1&#xA0;)&#xA0;&lt;&#xA0;3&#xA0;*&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>eps</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
where all the values, and calculations, are done with the precision
corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>Float</span></font></i></code>
.

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

<br/>
The file
<a href="limits.cpp.xml" target="_top"><span style='white-space: nowrap'>limits.cpp</span></a>

contains an example and test of these functions.


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

</body>
</html>
