next up previous
Next: Algebraic types Up: Implementing Computer Algebra with ALDOR Previous: Implementing Computer Algebra with ALDOR

Fundamental types

The libaldor library is a general library for programming with ALDOR with no emphasis on symbolics or numerical computations.
$ \bullet$
Numbers: machine integers and floats, long integers and floats (ALDOR and GMP).
$ \bullet$
Input/Output: strings, files, binary I/O-streams, text I/O-streams
$ \bullet$
Data structures: arrays, lists, hash-tables, streams, ...
$ \bullet$
Tools: debugging, profiling, exceptions.
Here are some fundamental types provided by libaldor:
define PrimitiveType: Category == with {
        =: (%, %) -> Boolean;
        ~=: (%, %) -> Boolean;
}

define AdditiveType: Category == with {
        0: %;
        +: (%, %) -> %;
        -: % -> %;
        -: (%, %) -> %;
        add!: (%, %) -> %;
        minus!: % -> %;
        minus!: (%, %) -> %;
        zero?: % -> Boolean;
}

define ArithmeticType: Category == with {
        1: %;
        *: (%, %) -> %;
        ^: (%, MachineInteger) -> %;
        commutative?: Boolean;
        one?: % -> Boolean;
        times!: (%, %) -> %;
}
The categories AdditiveType and ArithmeticType look like the definition of an abelian monoid and a ring. But in fact they only assert the existence of arithmetic operations without asserting algebraic properties such as commutativity, associativity, etc. This is needed for these sets of numbers (machine integers, floats) that do not have algebraic properties. If we look at the definition of MachineInteger in the interprter mode of ALDOR we get
%2 >> MachineInteger
  () @ Join(
PrimitiveType with 
        0: %
        1: %
        bytes: MachineInteger
        coerce: SInt -> %
        coerce: % -> SInt
        integer: Literal -> %
        min: %
        max: %
        odd?: % -> Boolean
        zero?: % -> Boolean
    ==  add ()
, 
Join(CopyableType, IntegerType) with 
        mod+: (%, %, %) -> %
        mod-: (%, %, %) -> %
        mod*: (%, %, %) -> %
        mod/: (%, %, %) -> %
        mod^: (%, %, %) -> %
        modInverse: (%, %) -> %
        export to IntegerSegment(%)
    ==  add ()
Figures 1 and 2 show the hierarchies of types in libaldor. On these pictures, domains are surrounded by dashed lines and domains by plain lines.
Figure 1: The hierarchy of data structures in libaldor.
\begin{figure}\htmlimage
\centering\includegraphics[scale=.5]{sallidata.eps}
\end{figure}
Figure 2: The hierarchy of the other types in libaldor.
\begin{figure}\htmlimage
\centering\includegraphics[scale=.5]{sallicat.eps}
\end{figure}


next up previous
Next: Algebraic types Up: Implementing Computer Algebra with ALDOR Previous: Implementing Computer Algebra with ALDOR
Marc Moreno Maza
2003-06-06