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 4387


Ignore:
Timestamp:
2016-06-07T09:24:32-07:00 (8 years ago)
Author:
Marek Rychlik
Message:
 
Location:
branches/f4grobner
Files:
3 edited

Legend:

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

    r4325 r4387  
    102102    (&body)))
    103103   
     104#+nil
     105(test buchberger-advanced-preliminary
     106  (with-fixture buchberger-advanced-context ()
     107    (print (poly->string (elt gb 0)))
     108    (print (poly->string (elt gb 6)))))
     109   
     110
     111#+nil
     112(test buchberger-advanced-partial
     113  (with-fixture buchberger-advanced-context ()
     114    (loop
     115       for i from 0 below (length gb)
     116       do
     117         (loop
     118            for j from (1+ i) below (length gb)
     119            do
     120              (is (universal-zerop (second (multiple-value-list (poly-pseudo-divide (s-polynomial (elt gb i) (elt gb j)) gb))))
     121                  "Failed with I=~S, J=~S~%" I J)))))
     122
     123#-nil
    104124(test buchberger-advanced
    105125  "Buchberger algorithm - advanced case"
    106126  (with-fixture buchberger-advanced-context ()
    107     (is-true (grobner-test gb fl))
    108     ;;(is (every #'universal-equalp (buchberger fl) gb))
     127    ;;(is-true (grobner-test gb fl))
     128    (is (every #'universal-equalp (buchberger fl) gb))
    109129    ;;(is (every #'universal-equalp (parallel-buchberger fl) gb))
    110130    ))
  • branches/f4grobner/5am-division.lisp

    r4325 r4387  
    3939
    4040(defpackage #:5am-division
    41   (:use :cl :it.bese.fiveam :monom :polynomial :infix :symbolic-polynomial :division :ring))
     41  (:use :cl :it.bese.fiveam :copy :monom :polynomial :infix :symbolic-polynomial :division :ring))
    4242
    4343(in-package :5am-division)
     
    6262         (fl (cdr (string->poly "[x+y,x-2*y]" '(x y))))
    6363         (quotients (cdr (string->poly "[x-y,0]" '(x y))))
    64          (one (make-instance 'integer-ring :value 1)))
     64         (one (make-instance 'rational-field :value 1)))
    6565    (&body)))
    6666
     
    7373    )
    7474  )
     75
     76;; Maxima
     77;;poly_normal_form(3*x^3*y+2*z, [x^2*y+x,x-y^2-z^3],[x,y,z]);
     78;;Result: (-3*z^6)-6*y^2*z^3+2*z-3*y^4
     79(test normal-form-simple
     80  (let ((vars '(x y z)))
     81    (is (universal-equalp (normal-form (string->poly "3*x^3*y+2*z" vars)
     82                                       (cdr (string->poly "[x^2*y+x,x-y^2-z^3]" vars)))
     83                          (string->poly "(-3*z^6)-6*y^2*z^3+2*z-3*y^4" vars)))))
    7584
    7685(test normal-form-easy
     
    98107
    99108
     109;; Check if a set of generators satisfies the Buchberger criterion
     110;; The example is the Enneper surface ideal. Run this in Maxima to
     111;; obtain the Grobner basis:
     112;;   poly_grobner([x-3*u-3*u*v^2+u^3,y-3*v-3*u^2*v+v^3,z-3*u^2+3*v^2],[u,v,x,y,z]);
     113(def-fixture buchberger-criterion-context ()
     114  (let ((fl (cdr (string->poly "[x-3*u-3*u*v^2+u^3,y-3*v-3*u^2*v+v^3,z-3*u^2+3*v^2]" '(u v x y z))))
     115        (gb (cdr (string->poly "[x-3*u*v^2+u^3-3*u,y+v^3-3*u^2*v-3*v,z+3*v^2-3*u^2,
     116       (-u*z)-3*x+6*u*v^2+9*u,(-v*z)+y-2*v^3-3*v,z^2+6*v^2*z-9*z-9*v*y+9*u*x,
     117       4*u*v*z-3*u*y+3*v*x,2*u*z^2+6*x*z-18*u*z-9*u*v*y+9*v^2*x,
     118       (-8*u*z^3)-24*x*z^2+72*u*z^2-36*v^2*x*z+27*u*y^2-27*v*x*y,
     119       z^3+18*v^2*z^2-18*z^2-54*v*y*z+54*v^2*z+81*z+27*y^2-27*x^2,
     120       (-4*z^4)+48*z^3-108*v*y*z^2+108*z^2+135*y^2*z+324*v*y*z+108*x^2*z
     121               -1296*v^2*z-1944*z-243*v^2*y^2-648*y^2+243*v^2*x^2+648*x^2,
     122       8*v*z^3-9*y*z^2+72*v*z^2+54*v^2*y*z-27*y*z-27*v*y^2+27*v*x^2,
     123       (-8*v*z^4)+12*y*z^3-96*v*z^3-216*v*z^2-135*v*y^2*z+324*y*z-27*v*x^2*z
     124                 +81*y^3+81*v*y^2-81*x^2*y-81*v*x^2,
     125       (-64*v*z^6)+120*y*z^5-1152*v*z^5+288*y*z^4-5184*v*z^4-648*v*y^2*z^3
     126                  -216*y*z^3+6912*v*z^3+81*y^3*z^2-9720*v*y^2*z^2
     127                  -1539*x^2*y*z^2+31104*y*z^2+62208*v*z^2+8505*y^3*z
     128                  +46656*v*y^2*z-8505*x^2*y*z-93312*y*z+729*v*y^4-23328*y^3
     129                  -1458*v*x^2*y^2-23328*v*y^2+23328*x^2*y+729*v*x^4
     130                  +23328*v*x^2,
     131       8*z^6-72*z^5+648*v*y*z^4-648*z^4-945*y^2*z^3+5184*v*y*z^3-189*x^2*z^3
     132            +5832*z^3+972*y^2*z^2+17496*v*y*z^2-2430*x^2*z^2+8748*v*y^3*z
     133            -19683*y^2*z+2187*x^2*z-5103*y^4-4374*v*y^3+5832*x^2*y^2
     134            +4374*v*x^2*y-729*x^4,
     135       8*z^7-48*z^6+648*v*y*z^5-864*z^5-945*y^2*z^4+5832*v*y*z^4-189*x^2*z^4
     136            +3888*z^4+81*y^2*z^3+17496*v*y*z^3-2997*x^2*z^3+17496*z^3
     137            +8748*v*y^3*z^2-16767*y^2*z^2+17496*v*y*z^2-5103*x^2*z^2
     138            -5103*y^4*z+5832*x^2*y^2*z-6561*y^2*z-729*x^4*z+6561*x^2*z
     139            -2187*y^4+4374*x^2*y^2-2187*x^4,
     140       64*z^9-10368*z^7+1296*y^2*z^6-1296*x^2*z^6-34992*y^2*z^5-34992*x^2*z^5
     141             +419904*z^5+174960*y^2*z^4-174960*x^2*z^4-10935*y^4*z^3
     142             -56862*x^2*y^2*z^3+314928*y^2*z^3-10935*x^4*z^3+314928*x^2*z^3
     143             +118098*y^4*z^2-118098*x^4*z^2+59049*y^4*z-118098*x^2*y^2*z
     144             +59049*x^4*z+19683*y^6-59049*x^2*y^4+59049*x^4*y^2-19683*x^6]" '(u v x y z)))))
     145    (&body)))
     146   
     147#+nil
     148(test buchberger-criterion-preliminary
     149  (with-fixture buchberger-criterion-context ()
     150    (print (poly->string (elt gb 0)))
     151    (print (poly->string (elt gb 6)))))
     152   
     153
     154#+nil
     155(test buchberger-containment
     156  "Check ideal containment"
     157  (with-fixture buchberger-criterion-context
     158      ()
     159    (let ((fl-copy (mapcar #'copy-instance fl))
     160          (gb-copy (mapcar #'copy-instance gb)))
     161      (loop
     162         for i from 0 below (length fl)
     163         do
     164           (is (universal-zerop (normal-form (elt fl i) gb))
     165               "Failed with I=~S~%" I))
     166      ;; GB should not change in the process
     167      (is (universal-equalp gb gb-copy))
     168      (is (universal-equalp fl fl-copy)))))
     169
     170#+nil
     171(test buchberger-criterion-full
     172  (with-fixture buchberger-criterion-context
     173      ()
     174    (loop
     175       for i from 0 below (length gb)
     176       do
     177         (loop
     178            for j from (1+ i) below (length gb)
     179            do
     180              (is (universal-zerop (normal-form (s-polynomial (elt gb i) (elt gb j)) gb))
     181                  "Failed with I=~S, J=~S~%" I J)))))
     182
     183#+nil
     184(test buchberger-criterion
     185  "Buchberger criterion"
     186  (with-fixture buchberger-advanced-context ()
     187    (is-true (grobner-test gb fl))
     188    )
     189  )
     190
     191
    100192(run! 'division-suite)
    101193(format t "All tests done!~%")
  • branches/f4grobner/rational-field.lisp

    r4362 r4387  
    105105  (copy-instance *rational-field-unit*))
    106106
    107 
    108 (defmethod universal-ezgcd ((object rational-field) (other rational-field))
    109   (values (copy-instance *rational-field-unit*)
    110           (copy-instance object)
    111           (copy-instance other)))
Note: See TracChangeset for help on using the changeset viewer.