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.

Changeset 2609


Ignore:
Timestamp:
2015-06-20T01:38:31-07:00 (10 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r2608 r2609  
    113113      (setf p (cdr p)))))
    114114
    115 (defmethod add-to ((self poly) (other poly))
    116   "Adds to polynomial SELF another polynomial OTHER.
     115(defmacro def-additive-operation-method (method-name)
     116  `(defmethod ,method-name ((self poly) (other poly))
     117     "Adds to polynomial SELF another polynomial OTHER.
    117118This operation destructively modifies both polynomials.
    118119The result is stored in SELF. This implementation does
    119120no consing, entirely reusing the sells of SELF and OTHER."
    120   (with-slots ((termlist1 termlist) (order1 order))
    121       self
    122     (with-slots ((termlist2 termlist) (order2 order))
    123         other
    124       ;; Ensure orders are compatible
    125       (unless (eq order1 order2)
    126         (setf termlist2 (sort termlist2 order1)
    127               order2 order1))
    128       ;; Create dummy head
    129       (push nil termlist1)
    130       (push nil termlist2)
    131       (fast-addition termlist1 termlist2 order1 #'add-to)
    132       ;; Remove dummy head
    133       (pop termlist1)))
    134   self)
     121     (with-slots ((termlist1 termlist) (order1 order))
     122         self
     123       (with-slots ((termlist2 termlist) (order2 order))
     124           other
     125         ;; Ensure orders are compatible
     126         (unless (eq order1 order2)
     127           (setf termlist2 (sort termlist2 order1)
     128                 order2 order1))
     129         ;; Create dummy head
     130         (push nil termlist1)
     131         (push nil termlist2)
     132         (fast-addition termlist1 termlist2 order1 #',method-name)
     133         ;; Remove dummy head
     134         (pop termlist1)))
     135     self))
     136
     137(def-additive-operation-method 'add-to)
     138(def-additive-operation-method 'subtract-from)
    135139
    136140(defmethod unary-uminus ((self poly)))
Note: See TracChangeset for help on using the changeset viewer.