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 2585


Ignore:
Timestamp:
2015-06-20T00:18:54-07:00 (10 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r2584 r2585  
    8686  self)
    8787
     88;; Fast destructive addition of termlists
     89(defun fast-add-to (p q)
     90  (macrolet ((lt (x) `(cadr ,x))
     91             (lc (x) `(r-coeff (cadr ,x))))
     92    (do ((p p)
     93         (q q))
     94        ((or (endp (cdr p)) (endp (cdr q)))
     95         p)
     96      (multiple-value-bind
     97            (greater-p equal-p)
     98          (lex> (lm q) (lm p))
     99        (cond
     100          (greater-p
     101           (rotatef (cdr p) (cdr q)))
     102          (equal-p
     103           (let ((s (add-to (lc p) (lc q))))
     104             (if (r-zerop s)
     105                 (setf (cdr p) (cddr p))
     106                 (setf (lc p) s
     107                       q (cdr q)))))))
     108      (setf p (cdr p)))))
     109
    88110(defmethod add-to ((self poly) (other poly))
    89111  "Adds to polynomial SELF another polynomial OTHER.
     
    91113The result is stored in SELF. This implementation does
    92114no consing, entirely reusing the sells of SELF and OTHER."
    93   (macrolet ((lt (termlist) `(car ,termlist))
    94              (lc (termlist) `(r-coeff (car ,termlist))))
    95115    (with-slots ((termlist1 termlist))
    96116        self
Note: See TracChangeset for help on using the changeset viewer.