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


Ignore:
Timestamp:
2016-06-18T17:15:00-07:00 (8 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r4536 r4540  
    394394               ))))))))
    395395
     396(defun s-add (p q order-fn add-fn &aux result)
     397  "Non-recursive version of SLOW-ADD. This version uses auxillary variable
     398RESULT which serves as a stack for the terms of the sum of P and Q. This version
     399is nearly twice as fast on some tests."
     400  (loop
     401     (cond
     402       ((endp p) (return-from s-add (nreconc result q)))
     403       ((endp q) (return-from s-add (nreconc result p)))
     404       (t
     405        (multiple-value-bind
     406              (greater-p equal-p)
     407            (funcall order-fn (car p) (car q))
     408          (cond
     409            (greater-p                  ; (> (car p) (car q))
     410             (push (pop p) result)
     411             )
     412            (equal-p                    ; (= (car p)) (car q))
     413             (let ((s (funcall add-fn (lc p) (lc q))))
     414               (cond
     415                 ((universal-zerop s)
     416                  (pop p))
     417                 (t
     418                  ;; Adjust the lc of p
     419                  (setf (lc p) s)
     420                  (push (pop p) result)
     421                  )
     422                 ))
     423             (pop q)
     424             )
     425            (t      ;(< (car p) (car q))                       
     426             (push (pop q) result)
     427             )
     428            ))))))
     429
    396430(defun fast-add (p q order-fn add-fn)
    397431  "This version calls SLOW-ADD and is bullet-proof."
    398   (slow-add p q order-fn add-fn)
     432  ;;(slow-add p q order-fn add-fn)
    399433  ;;(fast-and-risky-add p q order-fn add-fn)
    400434  ;;(f-add p q order-fn add-fn)
    401   ;;(s-add p q order-fn add-fn)
     435  (s-add p q order-fn add-fn)
    402436  )
    403437
Note: See TracChangeset for help on using the changeset viewer.