;;; RING (+ - * / gcd lcm zerop unit length signum numerator [STRUCTURE] ;;; denominator) ;;; The structure whose slots are bound to functions ;;; performing usual ring operations. In addition to usual arithmetical ;;; operations, bindings for other common operations ;;; which increase efficiency of Grobner basis calculations are also ;;; included. They are as follows: ;;; GCD - greatest common divisor; ;;; LCM - least common multiple; ;;; ZEROP - test whether an element is zero; ;;; SIGNUM - the sign of a ring element (+1, -1 or zero); ;;; UNIT - the unit of the ring; ;;; NUMERATOR - the numerator, if a ring of fractions ;;; DENOMINATOR - the denominator, if a ring of fractions ;;; LENGTH - an integer giving the approximate length ;;; of the representation; for example, for integers ;;; its default binding is #'integer-length; ;;; ;;; *RING-OF-INTEGERS* ((make-ring :+ #'+ :- #'- :* #'* :/ #'floor [VARIABLE] ;;; :gcd #'gcd :lcm #'lcm :zerop #'zerop :signum ;;; #'signum :unit 1 :length #'integer-length ;;; :numerator #'numerator :denominator ;;; #'denominator)) ;;; Operations in the ring of integers. ;;; ;;; *FIELD-OF-RATIONALS* ((make-ring :+ #'+ :- #'- :* #'* :/ #'/ [VARIABLE] ;;; :gcd #' ;;; (lambda (&rest r) (declare (ignore r)) 1) ;;; :lcm #'(lambda (&rest r) (apply #'* r)) ;;; :zerop #'zerop :signum #'signum :unit 1 ;;; :length #' ;;; (lambda (x) ;;; (+ (integer-length (numerator x)) ;;; (integer-length (denominator x)))) ;;; :numerator #'numerator :denominator ;;; #'denominator)) ;;; Operations on the field of rational numbers. ;;; ;;; FIELD-MODULO-PRIME (modulus) [FUNCTION] ;;; Return a RING structure with operations bound ;;; to the arithmetical operations modulo MODULUS, which ;;; should be a prime. ;;; ;;; *COEFFICIENT-RING* (*ring-of-integers*) [VARIABLE] ;;; The default RING structure, used in most operations ;;; on the coefficients of polynomials. It should be carefully ;;; set if rings other than the default ring is used. ;;;