This chapter describes the multiple precision arithmetic which is
embedded in the PROFIL/BIAS distribution but currently not contained in it.
Contact knueppel@tu-harburg.d400.de
for details.
Because some subroutines in PROFIL are different when using the multiple precision arithmetic, the whole library must be rebuilt to work correctly. Every rebuild must start with a
dmake CLEAN
in the PROFIL subdirectory. To build the library without multiple precision arithmetic, use
dmake architecture
as described in the installation section of PROFIL. See section Common Installation Steps, for details.
If you want to use the multiple precision arithmetic, use
dmake LR=x architecture
On a RS/6000 architecture using gcc, the command would be
dmake LR=x ibmgcc
Before rebuilding PROFIL, the multiple precision arithmetic libraries must have been built. Change to the appropriate directory with
cd lr
After that, use
dmake architecture
as you have used it to build BIAS, e.g.
dmake ibmgcc
Note that using the multiple precision arithmetic in your programs requires an additional include path as well as 2 additional libraries. The basic multiple precision include files are contained in the subdirectory lr. This subdirectory also contains the two new libraries Lr and Li. If you want to move your include files and your libraries to a different place, see section Common Installation Steps for further information and do not forget to move the include files and libraries from the subdirectory lr, too.
REAL
numbers, the first denotes the lower and the latter the
upper bound. On output, the lower and upper bound are separated by a comma
and surrounded by square brackets. Because the interval bounds are treated
as floating point numbers, the conversion routine of the C library which uses
a rounding to nearest is used. Therefore, an interval that is read in as
0.1 0.1
does not contain the real value 0.1 but is a point interval whose bounds are equal to a floating point approximation of 0.1.
This is no longer true when using the multiple precision arithmetic. With the multiple precision arithmetic, the interval input and output routines use the multiple precision interval I/O routines, all bounds on input and output are correctly rounded and the input format is the same as the output format. Additionally, there are some nice improvements when using intervals with a small relative diameter. For example, the interval [12.345,12.346] can be typed as:
[12.345,12.346] 12.34[5,6] 1.234[5,6]E+1 [1.2345,1.2346]E+1 [1.2345E+1,1.2346E+1]
For intervals like [1.999,2.002] the special notation
1.99[9,12]
can be used, where the 1 in the upper bound denotes a carry to be added to the least significant common digit. Point intervals can be read as one number, e.g. 0.1 and [0.1,0.1] are the same interval, both containing the real number 0.1.
The output format for intervals is controlled by the same commands used for the multiple precision reals/intervals. See section Long Real Numbers --- LongReal.h and section Long Intervals --- LongInterval.h, for details.
Due to the same reasons discussed above, the function Hull
cannot be used
to get an enclosure of a real constant, e.g. by Hull(0.1).
This is because Hull(0.1) returns a point interval whose bounds are equal
to a floating point approximation of 0.1. If you need an enclosure of 0.1,
use either DivBounds(1.0,10.0) or Enclosure("1.0").
The latter is using the multiple precision package, where the first is independent
of it.
LONGREAL
.
LONGREAL variable [(char * string [, INT precision])]
LONGREAL a("1.234", 20);
Defines a, initializes a with the decimal constant 1.234 and sets the current precision of a to 20 decimal digits.
The current working precision (i.e. the initial precision of new declared variables and the precision of any calculated results) is controlled by the following routines:
void SetDigits (INT n)
void SetBaseDigits (INT n)
INT GetDigits ()
INT GetBaseDigits ()
The basic operations +, -, *, and /, the unary operators
+ and - as well as +=, -=, *=, and /= are
defined for long real numbers. The operand type REAL
is also allowed as long
as at least one operand is of type LONGREAL
.
The predecessor and successor of a long real expression can be obtained by -- and ++.
Comparisons of long real numbers are possible with ==, !=, <, <=, >, and >=.
Additionally, the following functions are provided:
void MakeTemporary (LONGREAL a)
See section Vector Operations --- Vector.h, function MakeTemporary
for more information.
void MakePermanent (LONGREAL a)
See section Configuration, for details.
REAL RoundToReal (LONGREAL a [, INT rounding mode])
REAL
value.
The following values are possible for rounding mode, where the rounding
to nearest is the default:
LR_RND_NEAR
REAL
value.
LR_RND_DOWN
REAL
value.
LR_RND_UP
REAL
value.
void Accumulate (LONGREAL a, VECTOR v, VECTOR w)
Important: The precision of a is unchanged!
LONGREAL StringToLongReal (char * s)
The input and output of long real numbers is written as for all other data types. Currently, long real numbers are always output using an exponential format. Only the number of digits and the output rounding mode can be controlled. The following functions are used to control the output format for long real numbers and for the long intervals described in the next section:
void SetOutFracDigits (INT n)
void SetOutIntDigits (INT n)
This function affects only the output of long intervals.
void SetOutRndMode (INT n)
0
1
2
3
INT GetOutFracDigits ()
INT GetOutIntDigits ()
INT GetOutRndMode ()
LONGINTERVAL
.
LONGINTERVAL variable [(char * string [, INT precision])]
LONGINTERVAL a("[1.2,1.3]", 20);
Defines a, initialized a with the decimal constant interval [1.2,1.3] and sets the current precision of a to 20 decimal digits.
The basic operations +, -, *, and /, the unary operators
+ and - as well as +=, -=, *=, and /= are
defined for long intervals. The operand types REAL
, INTERVAL
, and
LONGREAL
are also allowed as long as at least one operand is of type LONGINTERVAL
.
The current working precision is controlled by the same commands used for the long real numbers. See section Long Real Numbers --- LongReal.h, for details.
Additionally, the following functions are provided:
void MakeTemporary (LONGINTERVAL a)
See section Vector Operations --- Vector.h, function MakeTemporary
for more information.
void MakePermanent (LONGINTERVAL a)
See section Configuration, for details.
LONGREAL Inf (LONGINTERVAL a)
LONGREAL Sup (LONGINTERVAL a)
LONGINTERVAL Hull (LONGREAL a)
See section Changes in Interval Input/Output, for more information about Hull
.
LONGINTERVAL Hull (LONGREAL a, LONGREAL b)
LONGREAL Diam (LONGINTERVAL a)
LONGREAL Mid (LONGINTERVAL a)
INTERVAL RoundToInterval (LONGINTERVAL a)
INTERVAL
value.
void Accumulate (LONGINTERVAL a, v, w)
VECTOR
and INTERVAL_VECTOR
are possible either)
and adds the result to a.
Important: The precision of a is unchanged!
INTERVAL Enclosure (char * s)
LONGINTERVAL LongIntervalEnclosure (char * s)
Enclosure
, but returns a long interval.
The output format of long intervals is controlled by the same commands used for the long real numbers. Additionally, the appearance of the output can be changed by the following command:
void SetOutOptions (INT n)
LI_FSTR_INT
GetIntDigits
, the bounds are written
to output without any fractional digits.
Otherwise, the next format is tried.
LI_FSTR_FRACCOM
Otherwise, the next format is tried.
LI_FSTR_FRACSEP
GetIntDigits
integer
digits), they are displayed as two floating point numbers.
Otherwise, the exponential format is used.
If LI_STR_SINGLE
is added to any of the above values, all spaces used
for indentation are removed.
The default output format is
(LI_FSTR_INT | LI_STR_SINGLE)
REAL HighPrecMul (VECTOR v, VECTOR w)
REAL
value.
VECTOR HighPrecMul (MATRIX A, VECTOR w)
REAL
value.
MATRIX HighPrecMul (MATRIX A, MATRIX A)
REAL
value.
INTERVAL HighPrecMulBounds (VECTOR v, VECTOR w)
INTERVAL_VECTOR HighPrecMulBounds (MATRIX A, VECTOR w)
INTERVAL_MATRIX HighPrecMulBounds (MATRIX A, MATRIX B)
INTERVAL HighPrecMul (v, w)
VECTOR
or INTERVAL_VECTOR
but not both VECTOR
.
INTERVAL_VECTOR HighPrecMul (A, w)
MATRIX
or INTERVAL_MATRIX
and the parameter w may either be VECTOR
or INTERVAL_VECTOR
.
The type combination MATRIX
and VECTOR
is not allowed.
INTERVAL_MATRIX HighPrecMul (A, B)
MATRIX
or INTERVAL_MATRIX
but not both MATRIX
.
INTERVAL_MATRIX IdMinusHighPrecMul (A, B)
MATRIX
or INTERVAL_MATRIX
.
Thomas Simenec wrote the test matrices contained in the PROFIL/BIAS extension package. He frequently tested many nearly similar revisions of all packages and gave many helpful hints for the DOS and OS/2 versions.
Many thanks go to Dirk Husung, whose long real package
is the basis of all multiple precision routines.