4.2 Coefficients

The coefficients in SF and SQ are the “numbers” from various algebraic contexts. They are called domain elements and uniformly represented either as integer numbers or pairs where the car part contains an identifier describing the domain and its arithmetic by its properties; the cdr part describes the value.

  1. Integers: integer numbers Z represent integer coefficients directly,
  2. Gaussian integers: complex numbers with integer real and imaginary part (:gi: re . im) with re,im Z,
  3. Rational numbers: quotients of integers (:rn: nu . de) with nu,de Z,
  4. Modular numbers: numbers modulo the current prime (:mod: . j) where 0 j < currentmodulus*11 .
  5. Rounded numbers: floating point numbers extended in precision and magnitude (:rd: . fp) with LISP floating point number fp or (:rd: mant . exp) with integers mant and exp representing an extended floating point value,
  6. Rounded complex numbers: numbers with rounded real and imaginary parts (:gr: fre . fim) with LISP floating point numbers fre and fim or (:gr: (rmant . rexp) . (imant . iexp)) with extended real and imaginary parts.

The neutral elements zero and one for addition and multiplication respectively are identical for all domains: zero is represented as nil and one by the integer number 1.

The list of domains is open ended: if a new coefficient domain is required for an application field, this can be created and linked to the system at any time. The necessary structure is described in the source file for the module dmodeop.

The tag of the currently active domain is stored in the value of the variable dmode*. nil represents the default domain (integers). This variable should not be modified directly - instead use the function setdmode:

     setdmode(DOM:domain,MODE:bool);

where domain is a domain name (e.g. rational) and the Boolean second parameter tells whether to activate (t) or to deactivate (nil) the domain. Note that setdmode does not set on the corresponding switches. You must do that yourself. E.g. for a proper activation and deactivation of complex rounded call

    !*rounded := t;  
    setdmode(’rounded,t);  
    !*complex := t;  
    setdmode(’complex,t);  
    .... % do your computation  
    setdmode(’complex,nil);  
    !*complex := nil;  
    setdmode(’rounded,nil);  
    !*rounded := nil;

In order to convert the domain tag into the domain name use the property dname, e.g.

      get(dmode!*,’dname);

will result in the name of the current domain.