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 4442


Ignore:
Timestamp:
2016-06-10T19:45:42-07:00 (8 years ago)
Author:
Marek Rychlik
Message:
 
Location:
branches/f4grobner
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/5am-poly.lisp

    r4335 r4442  
    8888  )
    8989
     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
    90105(def-fixture poly-multiply-context ()
    91106  (let ((p (make-instance 'poly))
  • branches/f4grobner/buchberger.lisp

    r4390 r4442  
    6464        (cond
    6565          ((criterion-1 pair) nil)
    66           ((criterion-2 pair b-done f) nil)
     66          ;;((criterion-2 pair b-done f) nil)
    6767          (t
    6868           (let ((sp (normal-form (s-polynomial
  • branches/f4grobner/polynomial.lisp

    r4436 r4442  
    4646           "SATURATION-EXTENSION"
    4747           "ALIST->POLY"
     48           "POLY->ALIST"
    4849           "->INFIX"
    4950           "UNIVERSAL-EZGCD"
     
    140141
    141142can 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
     144terms are entered in the increasing order.
    143145
    144146NOTE: The primary use is for low-level debugging of the package."
    145147  (dolist (x alist poly)
    146148    (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
     152returned value is  ((MONOM[0] . COEFF[0]) (MONOM[1] . COEFF[1]) ...), where
     153MONOM[I] is a list of exponents in the monomial and COEFF[I] is the
     154corresponding 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
    147162
    148163(defmethod update-instance-for-different-class :after ((old term) (new poly) &key)
     
    346361(defun (setf lc) (new-value x) (setf (term-coeff (car x)) new-value))
    347362
     363
    348364(defun fast-add (p q order-fn add-fn)
    349365  (cond
     
    355371         (funcall order-fn (car p) (car q))
    356372       (cond
    357          (greater-p                     ; (> (cadr h) (car q))
     373         (greater-p                     ; (> (car p) (car q))
    358374          (cons (car p) (fast-add (cdr p) q order-fn add-fn))
    359375          )
    360          (equal-p                       ; (= (cadr h)) (car q))
     376         (equal-p                       ; (= (car p)) (car q))
    361377          (let ((s (funcall add-fn (lc p) (lc q))))
    362378            (cond
     
    368384               (cons (car p) (fast-add (cdr p) (cdr q) order-fn add-fn))
    369385               ))))
    370          (t                    ;(< (cadr h) (car q))                   
     386         (t                    ;(< (car p) (car q))                     
    371387          (cons (car q) (fast-add p (cdr q) order-fn add-fn))
    372388          ))))))
    373 
    374389
    375390
  • branches/f4grobner/symbolic-polynomial.lisp

    r4435 r4442  
    133133         p-or-plist)))))
    134134
    135 (defun poly->alist (p)
    136   "Convert a polynomial P to an association list. Thus, the format of the
    137 returned value is  ((MONOM[0] . COEFF[0]) (MONOM[1] . COEFF[1]) ...), where
    138 MONOM[I] is a list of exponents in the monomial and COEFF[I] is the
    139 corresponding coefficient in the ring."
    140   (cond
    141     ((poly-p p)
    142      (mapcar #'->list (poly-termlist p)))
    143     ((and (consp p) (eq (car p) :[))
    144      (cons :[ (mapcar #'poly->alist (cdr p))))))
    145 
    146135(defun string->alist (str vars
    147136                      &optional
  • branches/f4grobner/test0.lisp

    r4170 r4442  
    11(in-package :polynomial)
     2
     3(proclaim '(special p r))
     4
    25(setf p (ADD-TO
    36         (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.