Dynamic Multiple-Precision Arithmetic

** Next:** Input and Output
**Up:** C-XSC
** Previous:** Evaluation of Expressions

Besides the classes *real* and *interval*, the dynamic classes long
real (*l*`_`*real*) and long interval (*l*`_`*interval*)
as well as the corresponding dynamic
vectors and matrices are implemented including all arithmetic and
relational operators and multiple-precision standard functions.
The computing precision may be controlled by the user at
run time. By replacing the *real* and *interval* declarations by *l*`_`*real*
and *l*`_`*interval*, the user's application program turns into a
multiple-precision program. This concept provides the user with a
powerful and easy-to-use tool for error analysis. Furthermore, it
is possible to write programs delivering numerical results with a
user-specified accuracy by internally modifying the
computing precision at run time in response to the error bounds
for intermediate results within the algorithm.

All predefined operators for *real* and *interval* types are also
available for *l*`_`*real* and *l*`_`*interval*. Additionally, all
possible operator combinations between single and multiple-precision
types are included.
The following example shows a single-precision program and its
multiple-precision version:

main()
{
interval a, b; /* Standard intervals */
a = 1.0; /* a = [1.0,1.0] */
b = 3.0; /* b = [3.0,3.0] */
cout << "a/b = " << a/b; /* a/b = [0.333333333333,
0.333333333334] */
}
main()
{
l_interval a, b; /* Multiple-precision intervals */
a = 1.0;
b = 3.0;
stagprec = 2; /* global integer variable */
cout << "a/b = " << a/b;
/* a/b = [0.333333333333333333333333,
0.3333333333333333333333334] */
}

At run time, the predefined global integer variable *stagprec*
(staggered precision) controls the computing precision
of the multiple-precision arithmetic in steps of a single *real*
(64 bit words).
The precision of a multiple-precision number is defined as
the number of *real* s used to store the long number's value.
An object of type *l*`_`*real* or *l*`_`*interval* may change its
precision at run time. Components of a vector or a matrix
may be of different precision. All multiple-precision
arithmetic routines and standard functions compute a numerical
result possessing a precision specified by the actual value of *stagprec*.
Allocation, resize, and subarray access of multiple-precision
vectors and matrices are similar to the corresponding single-precision
data types.

* Andreas Wiethoff *

Wed Mar 29 13:50:24 MET DST 1995