close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

source: branches/f4grobner/monom.lisp@ 3662

Last change on this file since 3662 was 3650, checked in by Marek Rychlik, 9 years ago

* empty log message *

File size: 21.0 KB
Line 
1;;; -*- Mode: Lisp -*-
2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3;;;
4;;; Copyright (C) 1999, 2002, 2009, 2015 Marek Rychlik <rychlik@u.arizona.edu>
5;;;
6;;; This program is free software; you can redistribute it and/or modify
7;;; it under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 2 of the License, or
9;;; (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19;;;
20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21
22(defpackage "MONOM"
23 (:use :cl :copy)
24 (:export "MONOM"
25 "TERM"
26 "EXPONENT"
27 "MONOM-DIMENSION"
28 "MONOM-EXPONENTS"
29 "UNIVERSAL-EQUALP"
30 "MONOM-ELT"
31 "TOTAL-DEGREE"
32 "SUGAR"
33 "MULTIPLY-BY"
34 "DIVIDE-BY"
35 "DIVIDE"
36 "MULTIPLY-2"
37 "MULTIPLY"
38 "DIVIDES-P"
39 "DIVIDES-LCM-P"
40 "LCM-DIVIDES-LCM-P"
41 "LCM-EQUAL-LCM-P"
42 "DIVISIBLE-BY-P"
43 "REL-PRIME-P"
44 "UNIVERSAL-LCM"
45 "UNIVERSAL-GCD"
46 "DEPENDS-P"
47 "LEFT-TENSOR-PRODUCT-BY"
48 "RIGHT-TENSOR-PRODUCT-BY"
49 "LEFT-CONTRACT"
50 "MAKE-MONOM-VARIABLE"
51 "->LIST"
52 "LEX>"
53 "GRLEX>"
54 "REVLEX>"
55 "GREVLEX>"
56 "INVLEX>"
57 "REVERSE-MONOMIAL-ORDER"
58 "MAKE-ELIMINATION-ORDER-FACTORY"
59 "TERM-COEFF"
60 "UNARY-MINUS"
61 "UNIVERSAL-ZEROP")
62 (:documentation
63 "This package implements basic operations on monomials, including
64various monomial orders.
65
66DATA STRUCTURES: Conceptually, monomials can be represented as lists:
67
68 monom: (n1 n2 ... nk) where ni are non-negative integers
69
70However, lists may be implemented as other sequence types, so the
71flexibility to change the representation should be maintained in the
72code to use general operations on sequences whenever possible. The
73optimization for the actual representation should be left to
74declarations and the compiler.
75
76EXAMPLES: Suppose that variables are x and y. Then
77
78 Monom x*y^2 ---> (1 2) "))
79
80(in-package :monom)
81
82(proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0)))
83
84(deftype exponent ()
85 "Type of exponent in a monomial."
86 'fixnum)
87
88(defclass monom ()
89 ((exponents :initarg :exponents :accessor monom-exponents
90 :documentation "The powers of the variables."))
91 ;; default-initargs are not needed, they are handled by SHARED-INITIALIZE
92 ;;(:default-initargs :dimension 'foo :exponents 'bar :exponent 'baz)
93 (:documentation
94 "Implements a monomial, i.e. a product of powers
95of variables, like X*Y^2."))
96
97(defmethod print-object ((self monom) stream)
98 (print-unreadable-object (self stream :type t :identity t)
99 (with-accessors ((exponents monom-exponents))
100 self
101 (format stream "EXPONENTS=~A"
102 exponents))))
103
104(defmethod initialize-instance :after ((self monom)
105 &key
106 (dimension 0 dimension-supplied-p)
107 (exponents nil exponents-supplied-p)
108 (exponent 0)
109 &allow-other-keys
110 )
111 "The following INITIALIZE-INSTANCE method allows instance initialization
112of a MONOM in a style similar to MAKE-ARRAY, e.g.:
113
114 (MAKE-INSTANCE :EXPONENTS '(1 2 3)) --> #<MONOM EXPONENTS=#(1 2 3)>
115 (MAKE-INSTANCE :DIMENSION 3) --> #<MONOM EXPONENTS=#(0 0 0)>
116 (MAKE-INSTANCE :DIMENSION 3 :EXPONENT 7) --> #<MONOM EXPONENTS=#(7 7 7)>
117
118If both DIMENSION and EXPONENTS are supplied, they must be compatible,
119i.e. the length of EXPONENTS must be equal DIMENSION. If EXPONENTS
120is not supplied, a monom with repeated value EXPONENT is created.
121By default EXPONENT is 0, which results in a constant monomial.
122"
123 (cond
124 (exponents-supplied-p
125 (when (and dimension-supplied-p
126 (/= dimension (length exponents)))
127 (error "EXPONENTS (~A) must have supplied length DIMENSION (~A)"
128 exponents dimension))
129 (let ((dim (length exponents)))
130 (setf (slot-value self 'exponents) (make-array dim :initial-contents exponents))))
131 (dimension-supplied-p
132 ;; when all exponents are to be identical
133 (setf (slot-value self 'exponents) (make-array (list dimension)
134 :initial-element exponent
135 :element-type 'exponent)))
136 (t
137 (error "Initarg DIMENSION or EXPONENTS must be supplied."))))
138
139(defgeneric monom-dimension (m)
140 (:method ((m monom))
141 (length (monom-exponents m))))
142
143(defgeneric universal-equalp (object1 object2)
144 (:documentation "Returns T iff OBJECT1 and OBJECT2 are equal.")
145 (:method ((object1 cons) (object2 cons)) (every #'universal-equalp object1 object2))
146 (:method ((object1 number) (object2 number)) (= object1 object2))
147 (:method ((m1 monom) (m2 monom))
148 "Returns T iff monomials M1 and M2 have identical EXPONENTS."
149 (equalp (monom-exponents m1) (monom-exponents m2))))
150
151(defgeneric monom-elt (m index)
152 (:documentation "Return the power in the monomial M of variable number INDEX.")
153 (:method ((m monom) index)
154 "Return the power in the monomial M of variable number INDEX."
155 (with-slots (exponents)
156 m
157 (elt exponents index))))
158
159(defgeneric (setf monom-elt) (new-value m index)
160 (:documentation "Set the power in the monomial M of variable number INDEX.")
161 (:method (new-value (m monom) index)
162 (with-slots (exponents)
163 m
164 (setf (elt exponents index) new-value))))
165
166(defgeneric total-degree (m &optional start end)
167 (:documentation "Return the total degree of a monomoal M. Optinally, a range
168of variables may be specified with arguments START and END.")
169 (:method ((m monom) &optional (start 0) (end (monom-dimension m)))
170 (declare (type fixnum start end))
171 (with-slots (exponents)
172 m
173 (reduce #'+ exponents :start start :end end))))
174
175(defgeneric sugar (m &optional start end)
176 (:documentation "Return the sugar of a monomial M. Optinally, a range
177of variables may be specified with arguments START and END.")
178 (:method ((m monom) &optional (start 0) (end (monom-dimension m)))
179 (declare (type fixnum start end))
180 (total-degree m start end)))
181
182(defgeneric multiply-by (self other)
183 (:documentation "Multiply SELF by OTHER, return SELF.")
184 (:method ((self number) (other number)) (* self other))
185 (:method ((self monom) (other monom))
186 (with-slots ((exponents1 exponents))
187 self
188 (with-slots ((exponents2 exponents))
189 other
190 (unless (= (length exponents1) (length exponents2))
191 (error "Incompatible dimensions"))
192 (map-into exponents1 #'+ exponents1 exponents2)))
193 self))
194
195(defgeneric divide-by (self other)
196 (:documentation "Divide SELF by OTHER, return SELF.")
197 (:method ((self number) (other number)) (/ self other))
198 (:method ((self monom) (other monom))
199 (with-slots ((exponents1 exponents))
200 self
201 (with-slots ((exponents2 exponents))
202 other
203 (unless (= (length exponents1) (length exponents2))
204 (error "divide-by: Incompatible dimensions."))
205 (unless (every #'>= exponents1 exponents2)
206 (error "divide-by: Negative power would result."))
207 (map-into exponents1 #'- exponents1 exponents2)))
208 self))
209
210(defmethod copy-instance :around ((object monom) &rest initargs &key &allow-other-keys)
211 "An :AROUND method of COPY-INSTANCE. It replaces
212exponents with a fresh copy of the sequence."
213 (declare (ignore object initargs))
214 (let ((copy (call-next-method)))
215 (setf (monom-exponents copy) (copy-seq (monom-exponents copy)))
216 copy))
217
218(defun multiply-2 (object1 object2)
219 "Multiply OBJECT1 by OBJECT2"
220 (multiply-by (copy-instance object1) (copy-instance object2)))
221
222(defun multiply (&rest factors)
223 "Non-destructively multiply list FACTORS."
224 (reduce #'multiply-2 factors))
225
226(defun divide (numerator &rest denominators)
227 "Non-destructively divide object NUMERATOR by product of DENOMINATORS."
228 (divide-by (copy-instance numerator) (apply #'multiply denominators)))
229
230(defgeneric divides-p (object1 object2)
231 (:documentation "Returns T if OBJECT1 divides OBJECT2.")
232 (:method ((m1 monom) (m2 monom))
233 "Returns T if monomial M1 divides monomial M2, NIL otherwise."
234 (with-slots ((exponents1 exponents))
235 m1
236 (with-slots ((exponents2 exponents))
237 m2
238 (every #'<= exponents1 exponents2)))))
239
240(defgeneric divides-lcm-p (object1 object2 object3)
241 (:documentation "Returns T if OBJECT1 divides LCM(OBJECT2,OBJECT3), NIL otherwise.")
242 (:method ((m1 monom) (m2 monom) (m3 monom))
243 "Returns T if monomial M1 divides LCM(M2,M3), NIL otherwise."
244 (with-slots ((exponents1 exponents))
245 m1
246 (with-slots ((exponents2 exponents))
247 m2
248 (with-slots ((exponents3 exponents))
249 m3
250 (every #'(lambda (x y z) (<= x (max y z)))
251 exponents1 exponents2 exponents3))))))
252
253(defgeneric lcm-divides-lcm-p (object1 object2 object3 object4)
254 (:method ((m1 monom) (m2 monom) (m3 monom) (m4 monom))
255 "Returns T if monomial LCM(M1,M2) divides LCM(M3,M4), NIL otherwise."
256 (with-slots ((exponents1 exponents))
257 m1
258 (with-slots ((exponents2 exponents))
259 m2
260 (with-slots ((exponents3 exponents))
261 m3
262 (with-slots ((exponents4 exponents))
263 m4
264 (every #'(lambda (x y z w) (<= (max x y) (max z w)))
265 exponents1 exponents2 exponents3 exponents4)))))))
266
267(defgeneric monom-lcm-equal-lcm-p (object1 object2 object3 object4)
268 (:method ((m1 monom) (m2 monom) (m3 monom) (m4 monom))
269 "Returns T if monomial LCM(M1,M2) equals LCM(M3,M4), NIL otherwise."
270 (with-slots ((exponents1 exponents))
271 m1
272 (with-slots ((exponents2 exponents))
273 m2
274 (with-slots ((exponents3 exponents))
275 m3
276 (with-slots ((exponents4 exponents))
277 m4
278 (every
279 #'(lambda (x y z w) (= (max x y) (max z w)))
280 exponents1 exponents2 exponents3 exponents4)))))))
281
282(defgeneric divisible-by-p (object1 object2)
283 (:documentation "Return T if OBJECT1 is divisible by OBJECT2.")
284 (:method ((m1 monom) (m2 monom))
285 "Returns T if monomial M1 is divisible by monomial M2, NIL otherwise."
286 (with-slots ((exponents1 exponents))
287 m1
288 (with-slots ((exponents2 exponents))
289 m2
290 (every #'>= exponents1 exponents2)))))
291
292(defgeneric rel-prime-p (object1 object2)
293 (:documentation "Returns T if objects OBJECT1 and OBJECT2 are relatively prime.")
294 (:method ((m1 monom) (m2 monom))
295 "Returns T if two monomials M1 and M2 are relatively prime (disjoint)."
296 (with-slots ((exponents1 exponents))
297 m1
298 (with-slots ((exponents2 exponents))
299 m2
300 (every #'(lambda (x y) (zerop (min x y))) exponents1 exponents2)))))
301
302(defgeneric universal-lcm (object1 object2)
303 (:documentation "Returns the multiple of objects OBJECT1 and OBJECT2.")
304 (:method ((m1 monom) (m2 monom))
305 "Returns least common multiple of monomials M1 and M2."
306 (with-slots ((exponents1 exponents))
307 m1
308 (with-slots ((exponents2 exponents))
309 m2
310 (let* ((exponents (copy-seq exponents1)))
311 (map-into exponents #'max exponents1 exponents2)
312 (make-instance 'monom :exponents exponents))))))
313
314
315(defgeneric universal-gcd (object1 object2)
316 (:documentation "Returns GCD of objects OBJECT1 and OBJECT2")
317 (:method ((m1 monom) (m2 monom))
318 "Returns greatest common divisor of monomials M1 and M2."
319 (with-slots ((exponents1 exponents))
320 m1
321 (with-slots ((exponents2 exponents))
322 m2
323 (let* ((exponents (copy-seq exponents1)))
324 (map-into exponents #'min exponents1 exponents2)
325 (make-instance 'monom :exponents exponents))))))
326
327(defgeneric depends-p (object k)
328 (:documentation "Returns T iff object OBJECT depends on variable K.")
329 (:method ((m monom) k)
330 "Return T if the monomial M depends on variable number K."
331 (declare (type fixnum k))
332 (with-slots (exponents)
333 m
334 (plusp (elt exponents k)))))
335
336(defgeneric left-tensor-product-by (self other)
337 (:documentation "Returns a tensor product SELF by OTHER, stored into
338 SELF. Return SELF.")
339 (:method ((self monom) (other monom))
340 (with-slots ((exponents1 exponents))
341 self
342 (with-slots ((exponents2 exponents))
343 other
344 (setf exponents1 (concatenate 'vector exponents2 exponents1))))
345 self))
346
347(defgeneric right-tensor-product-by (self other)
348 (:documentation "Returns a tensor product of OTHER by SELF, stored
349 into SELF. Returns SELF.")
350 (:method ((self monom) (other monom))
351 (with-slots ((exponents1 exponents))
352 self
353 (with-slots ((exponents2 exponents))
354 other
355 (setf exponents1 (concatenate 'vector exponents1 exponents2))))
356 self))
357
358(defgeneric left-contract (self k)
359 (:documentation "Drop the first K variables in object SELF.")
360 (:method ((self monom) k)
361 "Drop the first K variables in monomial M."
362 (declare (fixnum k))
363 (with-slots (exponents)
364 self
365 (setf exponents (subseq exponents k)))
366 self))
367
368(defun make-monom-variable (nvars pos &optional (power 1)
369 &aux (m (make-instance 'monom :dimension nvars)))
370 "Construct a monomial in the polynomial ring
371RING[X[0],X[1],X[2],...X[NVARS-1]] over the (unspecified) ring RING
372which represents a single variable. It assumes number of variables
373NVARS and the variable is at position POS. Optionally, the variable
374may appear raised to power POWER. "
375 (declare (type fixnum nvars pos power) (type monom m))
376 (with-slots (exponents)
377 m
378 (setf (elt exponents pos) power)
379 m))
380
381(defgeneric ->list (object)
382 (:method ((m monom))
383 "A human-readable representation of a monomial M as a list of exponents."
384 (coerce (monom-exponents m) 'list)))
385
386;; pure lexicographic
387(defgeneric lex> (p q &optional start end)
388 (:documentation "Return T if P>Q with respect to lexicographic
389order, otherwise NIL. The second returned value is T if P=Q,
390otherwise it is NIL.")
391 (:method ((p monom) (q monom) &optional (start 0) (end (monom-dimension p)))
392 (declare (type fixnum start end))
393 (do ((i start (1+ i)))
394 ((>= i end) (values nil t))
395 (cond
396 ((> (monom-elt p i) (monom-elt q i))
397 (return-from lex> (values t nil)))
398 ((< (monom-elt p i) (monom-elt q i))
399 (return-from lex> (values nil nil)))))))
400
401;; total degree order, ties broken by lexicographic
402(defgeneric grlex> (p q &optional start end)
403 (:documentation "Return T if P>Q with respect to graded
404lexicographic order, otherwise NIL. The second returned value is T if
405P=Q, otherwise it is NIL.")
406 (:method ((p monom) (q monom) &optional (start 0) (end (monom-dimension p)))
407 (declare (type monom p q) (type fixnum start end))
408 (let ((d1 (total-degree p start end))
409 (d2 (total-degree q start end)))
410 (declare (type fixnum d1 d2))
411 (cond
412 ((> d1 d2) (values t nil))
413 ((< d1 d2) (values nil nil))
414 (t
415 (lex> p q start end))))))
416
417;; reverse lexicographic
418(defgeneric revlex> (p q &optional start end)
419 (:documentation "Return T if P>Q with respect to reverse
420lexicographic order, NIL otherwise. The second returned value is T if
421P=Q, otherwise it is NIL. This is not and admissible monomial order
422because some sets do not have a minimal element. This order is useful
423in constructing other orders.")
424 (:method ((p monom) (q monom) &optional (start 0) (end (monom-dimension p)))
425 (declare (type fixnum start end))
426 (do ((i (1- end) (1- i)))
427 ((< i start) (values nil t))
428 (declare (type fixnum i))
429 (cond
430 ((< (monom-elt p i) (monom-elt q i))
431 (return-from revlex> (values t nil)))
432 ((> (monom-elt p i) (monom-elt q i))
433 (return-from revlex> (values nil nil)))))))
434
435
436;; total degree, ties broken by reverse lexicographic
437(defgeneric grevlex> (p q &optional start end)
438 (:documentation "Return T if P>Q with respect to graded reverse
439lexicographic order, NIL otherwise. The second returned value is T if
440P=Q, otherwise it is NIL.")
441 (:method ((p monom) (q monom) &optional (start 0) (end (monom-dimension p)))
442 (declare (type fixnum start end))
443 (let ((d1 (total-degree p start end))
444 (d2 (total-degree q start end)))
445 (declare (type fixnum d1 d2))
446 (cond
447 ((> d1 d2) (values t nil))
448 ((< d1 d2) (values nil nil))
449 (t
450 (revlex> p q start end))))))
451
452(defgeneric invlex> (p q &optional start end)
453 (:documentation "Return T if P>Q with respect to inverse
454lexicographic order, NIL otherwise The second returned value is T if
455P=Q, otherwise it is NIL.")
456 (:method ((p monom) (q monom) &optional (start 0) (end (monom-dimension p)))
457 (declare (type fixnum start end))
458 (do ((i (1- end) (1- i)))
459 ((< i start) (values nil t))
460 (declare (type fixnum i))
461 (cond
462 ((> (monom-elt p i) (monom-elt q i))
463 (return-from invlex> (values t nil)))
464 ((< (monom-elt p i) (monom-elt q i))
465 (return-from invlex> (values nil nil)))))))
466
467(defun reverse-monomial-order (order)
468 "Create the inverse monomial order to the given monomial order ORDER."
469 #'(lambda (p q &optional (start 0) (end (monom-dimension q)))
470 (declare (type monom p q) (type fixnum start end))
471 (funcall order q p start end)))
472
473;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
474;;
475;; Order making functions
476;;
477;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
478
479;; This returns a closure with the same signature
480;; as all orders such as #'LEX>.
481(defun make-elimination-order-factory-1 (&optional (secondary-elimination-order #'lex>))
482 "It constructs an elimination order used for the 1-st elimination ideal,
483i.e. for eliminating the first variable. Thus, the order compares the degrees of the
484first variable in P and Q first, with ties broken by SECONDARY-ELIMINATION-ORDER."
485 #'(lambda (p q &optional (start 0) (end (monom-dimension p)))
486 (declare (type monom p q) (type fixnum start end))
487 (cond
488 ((> (monom-elt p start) (monom-elt q start))
489 (values t nil))
490 ((< (monom-elt p start) (monom-elt q start))
491 (values nil nil))
492 (t
493 (funcall secondary-elimination-order p q (1+ start) end)))))
494
495;; This returns a closure which is called with an integer argument.
496;; The result is *another closure* with the same signature as all
497;; orders such as #'LEX>.
498(defun make-elimination-order-factory (&optional
499 (primary-elimination-order #'lex>)
500 (secondary-elimination-order #'lex>))
501 "Return a function with a single integer argument K. This should be
502the number of initial K variables X[0],X[1],...,X[K-1], which precede
503remaining variables. The call to the closure creates a predicate
504which compares monomials according to the K-th elimination order. The
505monomial orders PRIMARY-ELIMINATION-ORDER and
506SECONDARY-ELIMINATION-ORDER are used to compare the first K and the
507remaining variables, respectively, with ties broken by lexicographical
508order. That is, if PRIMARY-ELIMINATION-ORDER yields (VALUES NIL T),
509which indicates that the first K variables appear with identical
510powers, then the result is that of a call to
511SECONDARY-ELIMINATION-ORDER applied to the remaining variables
512X[K],X[K+1],..."
513 #'(lambda (k)
514 (cond
515 ((<= k 0)
516 (error "K must be at least 1"))
517 ((= k 1)
518 (make-elimination-order-factory-1 secondary-elimination-order))
519 (t
520 #'(lambda (p q &optional (start 0) (end (monom-dimension p)))
521 (declare (type monom p q) (type fixnum start end))
522 (multiple-value-bind (primary equal)
523 (funcall primary-elimination-order p q start k)
524 (if equal
525 (funcall secondary-elimination-order p q k end)
526 (values primary nil))))))))
527
528(defclass term (monom)
529 ((coeff :initarg :coeff :accessor term-coeff))
530 (:default-initargs :coeff nil)
531 (:documentation "Implements a term, i.e. a product of a scalar
532and powers of some variables, such as 5*X^2*Y^3."))
533
534(defmethod print-object ((self term) stream)
535 (print-unreadable-object (self stream :type t :identity t)
536 (with-accessors ((exponents monom-exponents)
537 (coeff term-coeff))
538 self
539 (format stream "EXPONENTS=~A COEFF=~A"
540 exponents coeff))))
541
542(defmethod universal-equalp ((term1 term) (term2 term))
543 "Returns T if TERM1 and TERM2 are equal as MONOM, and coefficients
544are UNIVERSAL-EQUALP."
545 (and (call-next-method)
546 (universal-equalp (term-coeff term1) (term-coeff term2))))
547
548(defmethod update-instance-for-different-class :after ((old monom) (new term) &key)
549 (setf (term-coeff new) 1))
550
551(defmethod multiply-by :before ((self term) (other term))
552 "Destructively multiply terms SELF and OTHER and store the result into SELF.
553It returns SELF."
554 (setf (term-coeff self) (multiply-by (term-coeff self) (term-coeff other))))
555
556(defmethod left-tensor-product-by :before ((self term) (other term))
557 (setf (term-coeff self) (multiply-by (term-coeff self) (term-coeff other))))
558
559(defmethod right-tensor-product-by :before ((self term) (other term))
560 (setf (term-coeff self) (multiply-by (term-coeff self) (term-coeff other))))
561
562(defmethod divide-by :before ((self term) (other term))
563 (setf (term-coeff self) (divide-by (term-coeff self) (term-coeff other))))
564
565(defgeneric unary-minus (self)
566 (:documentation "Negate object SELF and return it.")
567 (:method ((self number)) (- self))
568 (:method ((self term))
569 (setf (term-coeff self) (unary-minus (term-coeff self)))
570 self))
571
572(defgeneric universal-zerop (self)
573 (:documentation "Return T iff SELF is zero.")
574 (:method ((self number)) (zerop self))
575 (:method ((self term))
576 (universal-zerop (term-coeff self))))
Note: See TracBrowser for help on using the repository browser.