Changeset 4442 for branches/f4grobner
- Timestamp:
- 2016-06-10T19:45:42-07:00 (9 years ago)
- Location:
- branches/f4grobner
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/5am-poly.lisp
r4335 r4442 88 88 ) 89 89 90 (test poly-add-more 91 "More polynomial addition" 92 (is (equal (poly->alist (add-to 93 (alist->poly '(((0) . 1))) 94 (alist->poly '(((1) . 2))))) 95 '(((1) . 2) ((0) . 1)))) 96 (is (equal (poly->alist (add-to 97 (alist->poly '(((0) . 1))) 98 (alist->poly '(((0) . 2))))) 99 '(((0) . 3)))) 100 (is (equal (poly->alist (add-to 101 (alist->poly '(((0) . 1) ((2) . 5))) 102 (alist->poly '(((1) . 2) ((3) . 7))))) 103 '(((3) . 7) ((2) . 5) ((1) . 2) ((0) . 1))))) 104 90 105 (def-fixture poly-multiply-context () 91 106 (let ((p (make-instance 'poly)) -
branches/f4grobner/buchberger.lisp
r4390 r4442 64 64 (cond 65 65 ((criterion-1 pair) nil) 66 ((criterion-2 pair b-done f) nil)66 ;;((criterion-2 pair b-done f) nil) 67 67 (t 68 68 (let ((sp (normal-form (s-polynomial -
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 -
branches/f4grobner/symbolic-polynomial.lisp
r4435 r4442 133 133 p-or-plist))))) 134 134 135 (defun poly->alist (p)136 "Convert a polynomial P to an association list. Thus, the format of the137 returned value is ((MONOM[0] . COEFF[0]) (MONOM[1] . COEFF[1]) ...), where138 MONOM[I] is a list of exponents in the monomial and COEFF[I] is the139 corresponding coefficient in the ring."140 (cond141 ((poly-p p)142 (mapcar #'->list (poly-termlist p)))143 ((and (consp p) (eq (car p) :[))144 (cons :[ (mapcar #'poly->alist (cdr p))))))145 146 135 (defun string->alist (str vars 147 136 &optional -
branches/f4grobner/test0.lisp
r4170 r4442 1 1 (in-package :polynomial) 2 3 (proclaim '(special p r)) 4 2 5 (setf p (ADD-TO 3 6 (make-instance 'poly :dimension 1 :termlist (list (make-instance 'term :exponents #(0) :coeff 5)) :order #'lex>)
Note:
See TracChangeset
for help on using the changeset viewer.