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.

Changeset 2913 for branches


Ignore:
Timestamp:
2015-06-21T12:39:51-07:00 (9 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r2912 r2913  
    155155                                   uminus-method-name
    156156                                   &optional
    157                                     (doc-string nil doc-string-supplied-p))
     157                                     (doc-string nil doc-string-supplied-p))
    158158  "This macro avoids code duplication for two similar operations: ADD-TO and SUBTRACT-FROM."
    159159  `(defmethod ,add/subtract-method-name ((self poly) (other poly))
     
    184184no consing, entirely reusing the sells of SELF and OTHER.")
    185185
    186 )
     186  )
    187187
    188188(defmethod unary-minus ((self poly))
     
    220220    ((endp (cdr p))
    221221     (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      (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))))))))
     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))))))))
    230230
    231231
     
    389389  (declare (type ring-and-order ring-and-order) (type poly f g))
    390390  (let* ((lcm (monom-lcm (poly-lm f) (poly-lm g)))
    391           (mf (monom-div lcm (poly-lm f)))
    392           (mg (monom-div lcm (poly-lm g))))
     391         (mf (monom-div lcm (poly-lm f)))
     392         (mg (monom-div lcm (poly-lm g))))
    393393    (declare (type monom mf mg))
    394394    (multiple-value-bind (c cf cg)
     
    407407  (if (poly-zerop p)
    408408      (values p 1)
    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))))
     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))))
    418418
    419419(defun poly-content (ring p)
     
    447447  (read-from-string
    448448   (concatenate 'string
    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        
     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
    458458(defun read-poly (vars &key
    459459                         (stream t)
     
    487487
    488488(defun string->alist (str vars
    489                      &optional
    490                        (ring +ring-of-integers+)
    491                        (order #'lex>))
     489                      &optional
     490                        (ring +ring-of-integers+)
     491                        (order #'lex>))
    492492  "Convert a string STR representing a polynomial or polynomial list to
    493493an association list (... (MONOM . COEFF) ...)."
Note: See TracChangeset for help on using the changeset viewer.