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.
Rev | Line | |
---|
[4431] | 1 | (load "boot")
|
---|
[4430] | 2 |
|
---|
[4431] | 3 | (use-package :polynomial)
|
---|
| 4 | (use-package :monom)
|
---|
| 5 |
|
---|
| 6 | ;;(shadow '(fast-add) "POLYNOMIAL")
|
---|
| 7 |
|
---|
[4430] | 8 | ;; Getter/setter of leading coefficient
|
---|
| 9 | (defun lc (x) (term-coeff (car x)))
|
---|
| 10 | (defun (setf lc) (new-value x) (setf (term-coeff (car x)) new-value))
|
---|
| 11 |
|
---|
[4431] | 12 | (defvar order-fn #'lex>)
|
---|
| 13 | (defvar add-fn #'add-to)
|
---|
| 14 |
|
---|
[4430] | 15 | (defun fast-add-helper (p q)
|
---|
[4431] | 16 | (do ((h p))
|
---|
| 17 | ((endp q) p)
|
---|
| 18 | (multiple-value-bind
|
---|
| 19 | (greater-p equal-p)
|
---|
| 20 | (funcall order-fn (car h) (car q))
|
---|
| 21 | (cond
|
---|
| 22 | (greater-p ; (> (lm h) (lm q))
|
---|
| 23 | (setf h (cdr h))
|
---|
| 24 | )
|
---|
| 25 | (equal-p ; (= (lm h) (lm q))
|
---|
| 26 | (let ((s (funcall add-fn (lc h) (lc q))))
|
---|
| 27 | (cond
|
---|
| 28 | ((universal-zerop s)
|
---|
| 29 | (cond
|
---|
| 30 | (setf h (cdr h)
|
---|
| 31 | q (cdr q))))
|
---|
| 32 | (t
|
---|
| 33 | ;; Adjust the lc of p
|
---|
| 34 | (setf (lc h) s)
|
---|
| 35 | (setf h (cdr h)
|
---|
| 36 | q (cdr q))))))
|
---|
[4430] | 37 |
|
---|
[4431] | 38 | (t ;(< (lm h) (lm q))
|
---|
| 39 |
|
---|
[4430] | 40 |
|
---|
[4431] | 41 |
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.
Download in other formats: