- Timestamp:
- 2016-06-03T02:01:04-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/monom.lisp
r4130 r4168 625 625 (cons (coerce (monom-exponents self) 'list) (term-coeff self)))) 626 626 627 (defgeneric ->sexp ( self&optional vars)628 (:documentation "Convert a polynomial SELFto an S-expression, using variables VARS.")629 (:method :before (( selfmonom) &optional vars)630 "Check the length of variables VARS against the length of exponents in SELF."627 (defgeneric ->sexp (object &optional vars) 628 (:documentation "Convert a polynomial OBJECT to an S-expression, using variables VARS.") 629 (:method :before ((object monom) &optional vars) 630 "Check the length of variables VARS against the length of exponents in OBJECT." 631 631 (with-slots (exponents) 632 self632 object 633 633 (assert (= (length vars) (length exponents)) 634 634 nil 635 635 "Variables ~A and exponents ~A must have the same length." vars exponents))) 636 (:method (( selfmonom) &optional vars)637 "Convert a monomial SELFto infix form, using variable VARS to build the representation."636 (:method ((object monom) &optional vars) 637 "Convert a monomial OBJECT to infix form, using variable VARS to build the representation." 638 638 (with-slots (exponents) 639 self639 object 640 640 (let ((m (mapcan #'(lambda (var power) 641 641 (cond ((= power 0) nil) … … 647 647 (t 648 648 (cons '* m)))))) 649 (:method ((selfterm) &optional vars)650 "Convert a term SELFto infix form, using variable VARS to build the representation."649 (:method :around ((object term) &optional vars) 650 "Convert a term OBJECT to infix form, using variable VARS to build the representation." 651 651 (declare (ignore vars)) 652 (with-slots ( exponentscoeff)653 self654 (let (( m(call-next-method)))655 (cond ((eql coeff 1) m)656 ((atom m)657 (cond ((eql m1) coeff)658 (t (list '* coeff m))))659 ((eql (car m) '*)660 (list* '* coeff (cdr m)))652 (with-slots (coeff) 653 object 654 (let ((sexp (call-next-method))) 655 (cond ((eql coeff 1) sexp) 656 ((atom sexp) 657 (cond ((eql sexp 1) coeff) 658 (t (list '* coeff sexp)))) 659 ((eql (car sexp) '*) 660 (list* '* coeff (cdr sexp))) 661 661 (t 662 (list '* coeff m)))))))662 (list '* coeff sexp)))))))
Note:
See TracChangeset
for help on using the changeset viewer.