Obviously we need to implement the various usual sets of numbers:
- the ring of INTEGER NUMBERS
,
- the field of RATIONAL NUMBERS
,
- the rings of MODULAR INTEGERS
(and especially those which are prime fields),
- the different sets of FLOATING POINT NUMBERS
(with fixed or arbitrary precision),
- the ordered ring of REAL ALGEBRAIC NUMBERS,
- and many others that we will discover later.
Clearly we need also:
- UNIVARIATE OR MULTIVARIATE
POLYNOMIALS over each of these sets of numbers,
- MATRICES over the same sets,
- and also polynomial or matrix rings over any
ring we can consider, including
polynomial or matrix rings themselves.
So we need infinitely many algebraic types.
Let us call these types RINGS.
Moreover we need ALGEBRAIC STRUCTURES
(ring, commutative ring, Euclidean domain,
field, finite field, prime field, univariate polynomial ring, ...)
for the following reasons.
- Genericity
- We can organize our infinitely many RINGS
in a finite number of RING types.
Then, for instance, we can define the Euclidean algorithm
once for all for every Euclidean domain.
For instance, for any Euclidean domain
we need to say
gcd(a,b) ==
while not zero? b repeat
(a,b):= (b,a rem b)
return a
- Conditional declaration
- A matrix ring (or polynomial ring) may possess
an operation (inverse, gcd, ...) that another does not
and this fact depends on its coefficient ring.
So our MATRIX RINGS and POLYNOMIAL RINGS
should depend on the properties of their coefficient RING.
For instance we need to say:
if
is a field then the ring
of univariate
polynomials over
is an Euclidean domain.
- Conditional implementation
- The implementation of an operation defined
in several univariate polynomial rings like
|
(29) |
may depend on the properties of the coefficient RING.
Let
be a ring and
be a univariate polynomial in
with coefficient
in
.
If
is a non-commutative ring then
|
(30) |
If
is any commutative ring then
|
(31) |
If
is
then
|
(32) |
- Specialization
- Among all RINGS of a given type one
may have a much better algorithm for a given RING.
So for this particular one, we may wish to replace
the generic definition of an operation.
For instance for the Euclidean domain
of the integers we may wish to say (with some
optimizations ...)
gcd(a,b) ==
while a ~= b repeat
if a < b then b := b-a else a := a-b
return a
Marc Moreno Maza
2008-01-07