Changeset 4442 for branches/f4grobner/polynomial.lisp
- Timestamp:
- 2016-06-10T19:45:42-07:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r4436 r4442 46 46 "SATURATION-EXTENSION" 47 47 "ALIST->POLY" 48 "POLY->ALIST" 48 49 "->INFIX" 49 50 "UNIVERSAL-EZGCD" … … 140 141 141 142 can be entered as 142 (ALIST->POLY '(((2 3) . 3) ((0 1) . 2) ((0 0) . 7))). 143 (ALIST->POLY '(((0 0) . 7) ((0 1) . 2) ((2 3) . 3) )). NOTE: the 144 terms are entered in the increasing order. 143 145 144 146 NOTE: The primary use is for low-level debugging of the package." 145 147 (dolist (x alist poly) 146 148 (poly-insert-term poly (make-instance 'term :exponents (car x) :coeff (cdr x))))) 149 150 (defun poly->alist (p) 151 "Convert a polynomial P to an association list. Thus, the format of the 152 returned value is ((MONOM[0] . COEFF[0]) (MONOM[1] . COEFF[1]) ...), where 153 MONOM[I] is a list of exponents in the monomial and COEFF[I] is the 154 corresponding coefficient in the ring." 155 (cond 156 ((poly-p p) 157 (mapcar #'->list (poly-termlist p))) 158 ((and (consp p) (eq (car p) :[)) 159 (cons :[ (mapcar #'poly->alist (cdr p)))))) 160 161 147 162 148 163 (defmethod update-instance-for-different-class :after ((old term) (new poly) &key) … … 346 361 (defun (setf lc) (new-value x) (setf (term-coeff (car x)) new-value)) 347 362 363 348 364 (defun fast-add (p q order-fn add-fn) 349 365 (cond … … 355 371 (funcall order-fn (car p) (car q)) 356 372 (cond 357 (greater-p ; (> (ca dr h) (car q))373 (greater-p ; (> (car p) (car q)) 358 374 (cons (car p) (fast-add (cdr p) q order-fn add-fn)) 359 375 ) 360 (equal-p ; (= (ca dr h)) (car q))376 (equal-p ; (= (car p)) (car q)) 361 377 (let ((s (funcall add-fn (lc p) (lc q)))) 362 378 (cond … … 368 384 (cons (car p) (fast-add (cdr p) (cdr q) order-fn add-fn)) 369 385 )))) 370 (t ;(< (ca dr h) (car q))386 (t ;(< (car p) (car q)) 371 387 (cons (car q) (fast-add p (cdr q) order-fn add-fn)) 372 388 )))))) 373 374 389 375 390
Note:
See TracChangeset
for help on using the changeset viewer.