- Timestamp:
- 2015-06-21T12:39:51-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/polynomial.lisp
r2912 r2913 155 155 uminus-method-name 156 156 &optional 157 (doc-string nil doc-string-supplied-p))157 (doc-string nil doc-string-supplied-p)) 158 158 "This macro avoids code duplication for two similar operations: ADD-TO and SUBTRACT-FROM." 159 159 `(defmethod ,add/subtract-method-name ((self poly) (other poly)) … … 184 184 no consing, entirely reusing the sells of SELF and OTHER.") 185 185 186 )186 ) 187 187 188 188 (defmethod unary-minus ((self poly)) … … 220 220 ((endp (cdr p)) 221 221 (multiply-term-by-termlist-dropping-zeros (car p) q) 222 ((endp (cdr q))223 (multiply-term-by-termlist-dropping-zeros (car q) p t)224 (t225 (nconc (multiply-terms (car p) (car q))226 (tail (add-termlists227 (multiply-term-by-termlist-dropping-zeros (car p) (cdr q))228 (multiply-termlists (cdr p) q)229 order-fn))))))))222 ((endp (cdr q)) 223 (multiply-term-by-termlist-dropping-zeros (car q) p t) 224 (t 225 (nconc (multiply-terms (car p) (car q)) 226 (tail (add-termlists 227 (multiply-term-by-termlist-dropping-zeros (car p) (cdr q)) 228 (multiply-termlists (cdr p) q) 229 order-fn)))))))) 230 230 231 231 … … 389 389 (declare (type ring-and-order ring-and-order) (type poly f g)) 390 390 (let* ((lcm (monom-lcm (poly-lm f) (poly-lm g))) 391 392 391 (mf (monom-div lcm (poly-lm f))) 392 (mg (monom-div lcm (poly-lm g)))) 393 393 (declare (type monom mf mg)) 394 394 (multiple-value-bind (c cf cg) … … 407 407 (if (poly-zerop p) 408 408 (values p 1) 409 (let ((c (poly-content ring p)))410 411 412 #'(lambda (x)413 (make-term :monom (term-monom x)414 415 (poly-termlist p))416 417 409 (let ((c (poly-content ring p))) 410 (values (make-poly-from-termlist 411 (mapcar 412 #'(lambda (x) 413 (make-term :monom (term-monom x) 414 :coeff (funcall (ring-div ring) (term-coeff x) c))) 415 (poly-termlist p)) 416 (poly-sugar p)) 417 c)))) 418 418 419 419 (defun poly-content (ring p) … … 447 447 (read-from-string 448 448 (concatenate 'string 449 450 451 452 (multiple-value-bind (line eof)453 454 (format s "~A" line)455 (when eof (return)))))456 457 449 "#I(" 450 (with-output-to-string (s) 451 (loop 452 (multiple-value-bind (line eof) 453 (read-line stream t) 454 (format s "~A" line) 455 (when eof (return))))) 456 ")"))) 457 458 458 (defun read-poly (vars &key 459 459 (stream t) … … 487 487 488 488 (defun string->alist (str vars 489 &optional490 491 489 &optional 490 (ring +ring-of-integers+) 491 (order #'lex>)) 492 492 "Convert a string STR representing a polynomial or polynomial list to 493 493 an association list (... (MONOM . COEFF) ...)."
Note:
See TracChangeset
for help on using the changeset viewer.