Changeset 4494
- Timestamp:
- 2016-06-16T20:47:29-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r4492 r4494 334 334 |# 335 335 336 337 338 339 #|340 (defun fast-add (p q order-fn add-fn)341 "Add two polynomials, P and Q, represented as lists of terms.342 The operation is destructive to both polynomials, as the terms343 of both lists are combined into the result. The operation does not344 create any new instance of TERM."345 (macrolet ((lc (x) `(term-coeff (car ,x))))346 (do (r)347 ((or (endp p) (endp q))348 ;; NOTE: R contains the result in reverse order. Can it349 ;; be more efficient to produce the terms in correct order?350 (unless (endp q)351 (setf r (nreconc r q)))352 (unless (endp p)353 (setf r (nreconc r p)))354 r)355 (multiple-value-bind356 (greater-p equal-p)357 (funcall order-fn (car p) (car q))358 (cond359 (greater-p360 (rotatef (cdr p) r p)361 )362 (equal-p363 (let ((s (funcall add-fn (lc p) (lc q))))364 (cond365 ((universal-zerop s)366 (setf p (cdr p))367 )368 (t369 (setf (lc p) s)370 (rotatef (cdr p) r p))))371 (setf q (cdr q))372 )373 (t374 (rotatef (cdr q) r q)))))))375 |#376 377 336 ;; Shorthand for leading coefficient of a termlist 378 337 (defmacro lc (x) `(term-coeff (car ,x))) … … 453 412 (slow-add p q order-fn add-fn) 454 413 ;;(fast-and-risky-add p q order-fn add-fn) 414 ;;(f-add p q order-fn add-fn) 415 ;;(s-add p q order-fn add-fn) 455 416 ) 456 417
Note:
See TracChangeset
for help on using the changeset viewer.