<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/ntl-10.5.0test/doc/xdouble.cpp.html</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="macvim">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; }
body { font-family: monospace; color: #000000; background-color: #ffffff; }
* { font-size: 1em; }
.String { color: #4a708b; }
.PreProc { color: #1874cd; }
.Statement { color: #b03060; font-weight: bold; }
.Comment { color: #0000ee; font-style: italic; }
.Type { color: #008b00; font-weight: bold; }
-->
</style>
<script type='text/javascript'>
<!--
-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment">MODULE: xdouble </span>
<span class="Comment">SUMMARY:</span>
<span class="Comment">The class xdouble is used to represent floating point numbers with the</span>
<span class="Comment">same precision as a 'double', but with extended exponent range</span>
<span class="Comment">(offering a few more bits than that of a 'long' for the exponent).</span>
<span class="Comment">The programming interface for xdoubles is almost identical to that of</span>
<span class="Comment">ordinary doubles.</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="PreProc">#include </span><span class="String"><NTL/ZZ.h></span>
<span class="Type">class</span> xdouble {
<span class="Statement">public</span>:
xdouble(); <span class="Comment">// = 0</span>
xdouble(<span class="Type">const</span> xdouble& a); <span class="Comment">// copy constructor</span>
<span class="Type">explicit</span> xdouble(<span class="Type">double</span> a); <span class="Comment">// promotion constructor</span>
xdouble& <span class="Statement">operator</span>=(<span class="Type">const</span> xdouble& a); <span class="Comment">// assignment operator</span>
xdouble& <span class="Statement">operator</span>=(<span class="Type">double</span> a);
~xdouble();
<span class="Type">double</span> mantissa() <span class="Type">const</span>; <span class="Comment">// read-only access to mantissa</span>
<span class="Type">long</span> exponent() <span class="Type">const</span>; <span class="Comment">// read-only access to exponenent</span>
<span class="Type">static</span> <span class="Type">void</span> SetOutputPrecision(<span class="Type">long</span> p);
<span class="Comment">// This sets the number of decimal digits to be output. Default is</span>
<span class="Comment">// 10.</span>
<span class="Type">static</span> <span class="Type">long</span> OutputPrecision();
<span class="Comment">// returns current output precision.</span>
};
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Arithmetic Operations</span>
<span class="Comment">The following are the standard arithmetic operators, whose meaning should </span>
<span class="Comment">be clear.</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
xdouble <span class="Statement">operator</span>+(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble <span class="Statement">operator</span>-(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble <span class="Statement">operator</span>*(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble <span class="Statement">operator</span>/(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Comment">// PROMOTIONS: +, -, *, / promote double to xdouble on (a, b).</span>
xdouble <span class="Statement">operator</span>-(<span class="Type">const</span> xdouble& a);
xdouble& <span class="Statement">operator</span>+=(xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble& <span class="Statement">operator</span>+=(xdouble& a, <span class="Type">double</span> b);
xdouble& <span class="Statement">operator</span>-=(xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble& <span class="Statement">operator</span>-=(xdouble& a, <span class="Type">double</span> b);
xdouble& <span class="Statement">operator</span>*=(xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble& <span class="Statement">operator</span>*=(xdouble& a, <span class="Type">double</span> b);
xdouble& <span class="Statement">operator</span>/=(xdouble& a, <span class="Type">const</span> xdouble& b);
xdouble& <span class="Statement">operator</span>/=(xdouble& a, xdouble b);
xdouble& <span class="Statement">operator</span>++(xdouble& a); <span class="Comment">// prefix</span>
<span class="Type">void</span> <span class="Statement">operator</span>++(xdouble& a, <span class="Type">int</span>); <span class="Comment">// postfix</span>
xdouble& <span class="Statement">operator</span>--(xdouble& a); <span class="Comment">// prefix</span>
<span class="Type">void</span> <span class="Statement">operator</span>--(xdouble& a, <span class="Type">int</span>); <span class="Comment">// postfix</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Comparison</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Type">long</span> sign(<span class="Type">const</span> xdouble& a);
<span class="Comment">// returns sign (+1, -1, 0) of a</span>
<span class="Type">long</span> compare(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Comment">// returns sign of a - b</span>
<span class="Type">long</span> <span class="Statement">operator</span>==(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Type">long</span> <span class="Statement">operator</span>!=(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Type">long</span> <span class="Statement">operator</span><=(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Type">long</span> <span class="Statement">operator</span>>=(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Type">long</span> <span class="Statement">operator</span> <(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Type">long</span> <span class="Statement">operator</span> >(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b);
<span class="Comment">// PROMOTIONS: compare and operators ==, ..., > promote double to xdouble</span>
<span class="Comment">// on (a, b).</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Input/Output</span>
<span class="Comment">Input Syntax:</span>
<span class="Comment"><number>: [ "-" ] <unsigned-number></span>
<span class="Comment"><unsigned-number>: <dotted-number> [ <e-part> ] | <e-part></span>
<span class="Comment"><dotted-number>: <digits> | <digits> "." <digits> | "." <digits> | <digits> "."</span>
<span class="Comment"><digits>: <digit> <digits> | <digit></span>
<span class="Comment"><digit>: "0" | ... | "9"</span>
<span class="Comment"><e-part>: ( "E" | "e" ) [ "+" | "-" ] <digits></span>
<span class="Comment">Examples of valid input:</span>
<span class="Comment">17 1.5 0.5 .5 5. -.5 e10 e-10 e+10 1.5e10 .5e10 .5E10</span>
<span class="Comment">Note that the number of decimal digits of precision that are used</span>
<span class="Comment">for output can be set to any number p >= 1 by calling</span>
<span class="Comment">the routine xdouble::SetOutputPrecision(p). </span>
<span class="Comment">The default value of p is 10.</span>
<span class="Comment">The current value of p is returned by a call to xdouble::OutputPrecision().</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
ostream& <span class="Statement">operator</span><<(ostream& s, <span class="Type">const</span> xdouble& a);
istream& <span class="Statement">operator</span>>>(istream& s, xdouble& x);
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Miscellaneous</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
xdouble trunc(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns integer obtained by truncating</span>
xdouble floor(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns greatest integer <= a</span>
xdouble ceil(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns smallest integer >= a</span>
xdouble fabs(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns |a|</span>
xdouble sqrt(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns a^{1/2}; error is raised if a < 0</span>
<span class="Type">double</span> log(<span class="Type">const</span> xdouble& a); <span class="Comment">// returns log(a) (note return val is double!)</span>
xdouble xexp(<span class="Type">double</span> a); <span class="Comment">// returns exp(a) (note argument is double!)</span>
xdouble exp(<span class="Type">const</span> <span class="Type">double</span>& a); <span class="Comment">// equivalent to xexp(to_double(a))</span>
<span class="Type">void</span> power(xdouble& z, <span class="Type">const</span> xdouble& a, <span class="Type">const</span> ZZ& e);
xdouble power(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> ZZ& e);
<span class="Type">void</span> power(xdouble& z, <span class="Type">const</span> xdouble& a, <span class="Type">long</span> e);
xdouble power(<span class="Type">const</span> xdouble& a, <span class="Type">long</span> e);
<span class="Comment">// z = a^e, e may be negative</span>
<span class="Type">void</span> power2(xdouble& z, <span class="Type">long</span> e);
xdouble power2_xdouble(<span class="Type">long</span> e);
<span class="Comment">// z = 2^e, e may be negative</span>
<span class="Type">void</span> MulAdd(xdouble& z, <span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b, <span class="Type">const</span> xdouble& c);
xdouble MulAdd(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b, <span class="Type">const</span> xdouble& c);
<span class="Comment">// z = a + b*c, but faster</span>
<span class="Type">void</span> MulSub(xdouble& z, <span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b, <span class="Type">const</span> xdouble& c);
xdouble MulSub(<span class="Type">const</span> xdouble& a, <span class="Type">const</span> xdouble& b, <span class="Type">const</span> xdouble& c);
<span class="Comment">// z = a - b*c, but faster</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment">Implementation details:</span>
<span class="Comment">An xdouble is represented as a mantissa/exponent pair (x, e), where x</span>
<span class="Comment">is a double and e is a long. The real number represented by (x, e) is</span>
<span class="Comment">x * NTL_XD_BOUND^e, where</span>
<span class="Comment"> NTL_XD_BOUND = NTL_XD_HBOUND^2, and</span>
<span class="Comment"> NTL_XD_HBOUND = 2^{(max(NTL_DOUBLE_PRECISION,NTL_BITS_PER_LONG)+4)}.</span>
<span class="Comment">Also, the mantissa x satisfies 1/NTL_XD_HBOUND <= |x| <= NTL_XD_HBOUND, except</span>
<span class="Comment">that the number 0 is always represented as (0, 0). </span>
<span class="Comment">Both NTL_XD_BOUND and NTL_XD_HBOUND are macros defined in <NTL/xdouble.h>.</span>
<span class="Comment">SIZE INVARIANT: |e| < 2^(NTL_BITS_PER_LONG-4).</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->