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 4494 for branches


Ignore:
Timestamp:
2016-06-16T20:47:29-07:00 (9 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r4492 r4494  
    334334|#
    335335
    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 terms
    343 of both lists are combined into the result. The operation does not
    344 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 it
    349          ;; 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-bind
    356             (greater-p equal-p)
    357           (funcall order-fn (car p) (car q))
    358         (cond
    359           (greater-p
    360            (rotatef (cdr p) r p)
    361            )
    362           (equal-p
    363            (let ((s (funcall add-fn (lc p) (lc q))))
    364              (cond
    365                ((universal-zerop s)
    366                 (setf p (cdr p))
    367                 )
    368                (t
    369                 (setf (lc p) s)
    370                 (rotatef (cdr p) r p))))
    371            (setf q (cdr q))
    372            )
    373           (t
    374            (rotatef (cdr q) r q)))))))
    375 |#
    376 
    377336;; Shorthand for leading coefficient of a termlist
    378337(defmacro lc (x) `(term-coeff (car ,x)))
     
    453412  (slow-add p q order-fn add-fn)
    454413  ;;(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)
    455416  )
    456417
Note: See TracChangeset for help on using the changeset viewer.