- Timestamp:
- 2015-06-20T00:18:54-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r2584 r2585 86 86 self) 87 87 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 88 110 (defmethod add-to ((self poly) (other poly)) 89 111 "Adds to polynomial SELF another polynomial OTHER. … … 91 113 The result is stored in SELF. This implementation does 92 114 no consing, entirely reusing the sells of SELF and OTHER." 93 (macrolet ((lt (termlist) `(car ,termlist))94 (lc (termlist) `(r-coeff (car ,termlist))))95 115 (with-slots ((termlist1 termlist)) 96 116 self
Note:
See TracChangeset
for help on using the changeset viewer.