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 2528


Ignore:
Timestamp:
2015-06-19T14:20:52-07:00 (9 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r2527 r2528  
    106106  self)
    107107
    108 (defmethod add-to ((self poly) (other poly)))
     108(defmethod add-to ((self poly) (other poly))
     109  (with-slots ((p termlist))
     110      self
     111    (with-slots ((q termlist))
     112        other
     113      (do (r)
     114          ((cond
     115             ((endp p)
     116              (setf r (revappend r q)) t)
     117             ((endp q)
     118              (setf r (revappend r p)) t)
     119             (t
     120              (multiple-value-bind
     121                    (lm-greater lm-equal)
     122                  (funcall order (termlist-lm p) (termlist-lm q))
     123                (cond
     124                  (lm-equal
     125                   (let ((s (funcall (ring-add ring) (termlist-lc p) (termlist-lc q))))
     126                     (unless (funcall (ring-zerop ring) s) ;check for cancellation
     127                       (setf r (cons (make-term :monom (termlist-lm p) :coeff s) r)))
     128                     (setf p (cdr p) q (cdr q))))
     129                  (lm-greater
     130                   (setf r (cons (car p) r)
     131                         p (cdr p)))
     132                  (t (setf r (cons (car q) r)
     133                           q (cdr q)))))
     134              nil))
     135           r))))
     136  self)
    109137
    110138(defmethod subtract-from ((self poly) (other poly)))
Note: See TracChangeset for help on using the changeset viewer.