/usr/share/doc/NTL/tour-ex6.html is in libntl-dev 5.4.2-4.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <html>
<head>
<title>
A Tour of NTL: Examples: Floating Point Classes </title>
</head>
<body bgcolor="#fff9e6">
<center>
<a href="tour-ex5.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
<a href="tour-examples.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a>
<img src="arrow3.gif" alt="[Next]" align=bottom>
</center>
<h1>
<p align=center>
A Tour of NTL: Examples: Floating Point Classes
</p>
</h1>
<p> <hr> <p>
NTL also supports arbitrary precision floating point with
the class <tt>RR</tt>.
Additionally, it supports two specialized classes: <tt>quad_float</tt>,
which gives a form of quadruple precision, but without an extended
exponent range,
and <tt>xdouble</tt>,
which gives double precision, but with an extended exponent range.
The advantage of the latter two classes is efficiency.
<p>
Here again is a program that reads a list of numbers from the input,
and outputs the sum of their squares, using the class <tt>RR</tt>.
<p>
<pre>
#include <NTL/RR.h>
int main()
{
RR acc, val;
acc = 0;
while (SkipWhiteSpace(cin)) {
cin >> val;
acc += val*val;
}
cout << acc << "\n";
}
</pre>
<p>
The precision used for the computation can be set by executing
<pre>
RR::SetPrecision(p);
</pre>
which sets the effective precision to <tt>p</tt> bits.
By default, <tt>p=150</tt>.
All of the basic arithmetic operations compute their results
by rounding to the nearest <tt>p</tt>-bit floating point number.
The semantics of this are exactly the same as in the IEEE floating
point standard (except that there are no special values, like
"infinity" and "not a number").
<p>
The number of <i>decimal</i> digits of precision that are used when
printing an <tt>RR</tt> can be set be executing
<pre>
RR::SetOutputPrecision(d);
</pre>
which sets the output precision to <tt>d</tt>.
By default, <tt>d=10</tt>.
<p>
See <a href="RR.txt"><tt>RR.txt</tt></a> for details.
<p>
By replacing the occurences of <tt>RR</tt> by either <tt>quad_float</tt>
or <tt>xdouble</tt>, one gets an equivalent program using one of the
other floating point classes.
The output precision for these two classes can be controlled just
as with <tt>RR</tt>.
See <a href="quad_float.txt"><tt>quad_float.txt</tt></a> and
<a href="xdouble.txt"><tt>xdouble.txt</tt></a>
for details.
<p>
<center>
<a href="tour-ex5.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
<a href="tour-examples.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a>
<img src="arrow3.gif" alt="[Next]" align=bottom>
</center>
</body>
</html>
|