Changeset 2189 for branches/f4grobner
- Timestamp:
- 2015-06-18T08:18:01-07:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/term.lisp
r2021 r2189 38 38 (proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0))) 39 39 40 (defclass term () 41 ((monom) 42 (coeff))) 40 (defclass term (monom) 41 ((coeff :init-arg :coeff :accessor term-coeff))) 43 42 44 43 (defun make-term (&key monom coeff) 45 44 (make-instance 'term :monom monom :coeff coeff)) 46 45 47 (defun make-term-variable ( ringnvars pos46 (defun make-term-variable (nvars pos 48 47 &optional 49 48 (power 1) 50 (coeff (funcall (ring-unit ring))))49 (coeff 1)) 51 50 "Construct a term in the polynomial ring RING[X[0],X[1],X[2],...X[NVARS-1]] 52 51 over the ring RING which represents a single variable. It assumes … … 55 54 Optionally, the term may appear with an arbitrary coefficient, which 56 55 defaults to the unit of the RING." 57 (declare (type ring ring) (typefixnum nvars pos))56 (declare (type fixnum nvars pos)) 58 57 (make-term :monom (make-monom-variable nvars pos power) 59 58 :coeff coeff)) 60 59 61 (def un term-mul (ring term1 term2)60 (defmethod ring-mul ((term1 term) (term2 term)) 62 61 "Returns the product of the terms TERM1 and TERM2, 63 62 or NIL when the product is 0. This definition takes care of divisors of 0 64 63 in the coefficient ring." 65 (declare (type ring ring) (type term term1 term2)) 66 (let ((c (funcall (ring-mul ring) (term-coeff term1) (term-coeff term2)))) 67 (unless (funcall (ring-zerop ring) c) 64 (let ((c (ring-mul (term-coeff term1) (term-coeff term2)))) 65 (unless (ring-zerop c) 68 66 (make-term :monom (monom-mul (term-monom term1) (term-monom term2)) 69 67 :coeff c))))
Note:
See TracChangeset
for help on using the changeset viewer.