Basic number definitions, coefficient rings and fields for PHCv2. The definition of floating-point numbers is such that it is independent of the pre-defined type "float". New in the second version of PHC are the multi-precision numbers. This new feature is motivated by the demand for robustness in semi-numerical computations, where we have to deal with either badly-scaled input or singularities at the end of the computations. The precision limits of the standard machine number do not always suffice. However, software-driven arithmetic leads to a considerable loss in efficiency, especially if we rely on the grammar school algorithms as the ones used here. The library is divided in three parts: 1) encapsulation of standard machine types, packages group definitions 2) implementation of the multi-precision arithmetic 3) embedding : generics + instantiation, no implementation! In addition we have random number generators and numbers_io, besides the usual testing facilities. -------------------------------------------------------------------------------- file name : short description -------------------------------------------------------------------------------- standard_natural_numbers : defines the standard naturals standard_natural_numbers_io : input/output of standard naturals standard_integer_numbers : defines the standard integers standard_integer_numbers_io : input/output of standard integers standard_floating_numbers : defines single_float and double_float standard_floating_numbers_io : input/output of standard floating-point standard_mathematical_functions : defines math functions for standard floats -------------------------------------------------------------------------------- characters_and_numbers : utilities to input/output of numbers multprec_natural_numbers : natural numbers of arbitrary length multprec_natural_numbers_io : input/output routines of natural numbers multprec_integer_numbers : integer numbers of arbitrary length multprec_integer_numbers_io : input/output routines of integer numbers multprec_floating_numbers : multi-precision floating-point numbers multprec_floating_numbers_io : input/output routines of floating numbers multprec_mathematical_functions : defines math functions for multprec floats generic_complex_numbers : complex numbers over any real field standard_complex_numbers : implementation of complex numbers standard_complex_numbers_io : input/output of standard complex numbers standard_complex_numbers_polar : polar view on standard complex numbers multprec_complex_numbers : multi-precision complex numbers multprec_complex_numbers_io : input/output for multi-precision complex multprec_complex_number_tools : conversion/set_size operators -------------------------------------------------------------------------------- abstract_ring : a ring has the operations +,- and * abstract_ring_io : definition of input/output for a ring abstract_ring-domain : extension with order and division/remainder abstract_ring-field : extension with order and division standard_natural_ring : ring of standard natural numbers standard_natural_ring_io : abstract_ring_io(standard natural) standard_integer_ring : ring of standard integer numbers standard_integer_ring_io : abstract_ring_io(standard integer) standard_integer_ring-domain : domain of standard integer numbers standard_floating_ring : ring of standard floating-point numbers standard_floating_ring_io : abstract_ring_io(standard floating) standard_floating_ring-ffield : field of standard floating numbers standard_complex_ring : ring of standard complex numbers standard_complex_ring_io : abstract_ring_io(standard complex) multprec_natural_ring : ring of multi-precision natural numbers multprec_natural_ring_io : abstract_ring_io(multprec natural) multprec_integer_ring : ring of multi-precision integer numbers multprec_integer_ring_io : abstract_ring_io(multprec integer) multprec_integer_ring-ddomain : domain of multi-precision integer numbers multprec_floating_ring : ring of multi-precision floating numbers multprec_floating_ring_io : abstract_ring_io(multprec floating) multprec_floating_ring-ffield : field of multi-precision floating numbers multprec_complex_ring : ring of multi-precision complex numbers multprec_complex_ring_io : abstract_ring_io(multprec complex) -------------------------------------------------------------------------------- numbers_io : user-friendly way of asking a number standard_random_numbers : generates random standard numbers multprec_random_numbers : generates random multi-precision numbers -------------------------------------------------------------------------------- ts_natnum : test multi-precision natural numbers ts_intnum : test multi-precision integer numbers ts_fltnum : test multi-precision floating numbers ts_cmpnum : test multi-precision complex numbers ts_random : test random number generators -------------------------------------------------------------------------------- Natural numbers are seen as unsigned integer numbers and are also provided with a "-" operation, although these operations do not always make sense. The correct mathematically way is to define a monoid, but this would have led to the definition of more vector packages. Moreover, due to memory memory limitations, rings do not exists in a computer, since it is always possible to find two huge numbers for which the memory is insufficient to contain their sum or product. An Euclidean domain is defined as an extension of the ring with order and division/remainder operations. A field is a similar extension of the ring with order and division operations. The multi-precision packages are at the next-lowest level. We first focus on how to implement the operations. Afterwards and independently, the interpretations/encapsulations are set up. Single precision floating-point numbers are defined, but not elaborated since they are not used anyway. I recall that on an IBM RS/6000, adding single precision floating-point numbers took longer than adding double precision floating-point numbers. The encapsulation of standard numerical types into packages seems a lot of overkill, especially with the dummy procedures. However, PHC has a now a uniform and clear treatment of numbers. The standard complex numbers are somewhat hybrid: software-driven but still constant cost. Somehow this is an encouragement to use multi-precision, but in a restricted fashion: with an extended, but limited fractional part. In this new implementation, complex numbers are implemented by a generic package, where the real number type has to be instantiated. The complex numbers are first only presented in their Cartesian view and adapted so that they fit in the generic_ring.field framework. The test facilities include interactive little programs that allow to test for special cases and tests on randomly generated numbers. The "little" is only relative: we have 2000 lines of testing software. The "abstract"-packages are new in Ada 95. At a technical level, they are used as formal parameters to shorten the list of generics to packages. In the object-oriented methodology, they are abstract classes. This library contains 86 files: 1 READ_ME file 55 specifications (ads), 4 abstract classes, 3 generic packages 30 implementations (adb), including 6 test programs wc *adb counts 8274 lines of Ada code