- Timestamp:
- 2016-06-18T17:15:00-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r4536 r4540 394 394 )))))))) 395 395 396 (defun s-add (p q order-fn add-fn &aux result) 397 "Non-recursive version of SLOW-ADD. This version uses auxillary variable 398 RESULT which serves as a stack for the terms of the sum of P and Q. This version 399 is 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 396 430 (defun fast-add (p q order-fn add-fn) 397 431 "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) 399 433 ;;(fast-and-risky-add p q order-fn add-fn) 400 434 ;;(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) 402 436 ) 403 437
Note:
See TracChangeset
for help on using the changeset viewer.