Changeset 4192
- Timestamp:
- 2016-06-03T19:32:47-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/buchberger.lisp
r4170 r4192 48 48 (grobner-test (subseq f 0 start) (subseq f 0 start))) 49 49 ;;Initialize critical pairs 50 (let ((b (make- critical-pair-queuef start))50 (let ((b (make-instance 'critical-pair-queue *normal-strategy* f start)) 51 51 (b-done (make-hash-table :test #'equal))) 52 (declare (type priority-queue b) (type hash-table b-done))52 (declare (type critical-pair-queue b) (type hash-table b-done)) 53 53 (dotimes (i (1- start)) 54 54 (do ((j (1+ i) (1+ j))) ((>= j start)) 55 55 (setf (gethash (list (elt f i) (elt f j)) b-done) t))) 56 56 (do () 57 (( pair-queue-empty-p b)58 #+grobner-check(grobner-test ring-and-orderf f)57 ((queue-empty-p b) 58 #+grobner-check(grobner-test f f) 59 59 (debug-cgb "~&GROBNER END") 60 60 f) 61 (let ((pair ( pair-queue-remove b)))62 (declare (type pair pair))61 (let ((pair (dequeue b))) 62 (declare (type critical-pair pair)) 63 63 (cond 64 64 ((criterion-1 pair) nil) 65 65 ((criterion-2 pair b-done f) nil) 66 66 (t 67 (let ((sp (normal-form ring-and-order 68 (spoly ring-and-order 69 (pair-first pair) 70 (pair-second pair)) 67 (let ((sp (normal-form (s-polynomial 68 (critical-pair-first pair) 69 (critical-pair-second pair)) 71 70 f top-reduction-only))) 72 71 (declare (type poly sp)) 73 72 (cond 74 (( poly-zerop sp)73 ((universal-zerop sp) 75 74 nil) 76 75 (t … … 79 78 ;; Add new critical pairs 80 79 (dolist (h f) 81 ( pair-queue-insert b (make-pair h sp)))82 (debug-cgb "~& Sugar: ~dPolynomials: ~d; Pairs left: ~d; Pairs done: ~d;"83 ( pair-sugar pair) (length f) (pair-queue-size b)80 (enqueue b (make-instance 'critical-pair h sp))) 81 (debug-cgb "~&Polynomials: ~d; Pairs left: ~d; Pairs done: ~d;" 82 (length f) (queue-size b) 84 83 (hash-table-count b-done))))))) 85 (setf (gethash (list ( pair-first pair) (pair-second pair)) b-done)84 (setf (gethash (list (critical-pair-first pair) (critical-pair-second pair)) b-done) 86 85 t))))) 87 86 … … 103 102 (grobner-test (subseq f 0 start) (subseq f 0 start))) 104 103 ;;Initialize critical pairs 105 (let ((b (pair-queue-initialize (make-pair-queue) f start)) 106 (b-done (make-hash-table :test #'equal))) 104 (let ((b (make-instance 'critical-pair-queue *normal-strategy* f start)) 105 (b-done (make-hash-table :test #'equal)) 106 (coeff-zero (make-zero-for (leading-coefficient (car f)))) 107 (coeff-unit (make-unit-for (leading-coefficient (car f))))) 107 108 (declare (type priority-queue b) 108 109 (type hash-table b-done)) … … 112 113 (setf (gethash (list (elt f i) (elt f j)) b-done) t))) 113 114 (do () 114 (( pair-queue-empty-p b)115 ((queue-empty-p b) 115 116 #+grobner-check(grobner-test f f) 116 117 (debug-cgb "~&GROBNER END") 117 118 f) 118 (let ((pair ( pair-queue-remove b)))119 (when (null ( pair-division-data pair))120 (setf ( pair-division-data pair) (list (s-polynomial121 (pair-first pair)122 (pair-second pair))123 (make-poly-zero)124 (funcall (ring-unit ring))125 0)))119 (let ((pair (dequeue b))) 120 (when (null (critical-pair-data pair)) 121 (setf (critical-pair-data pair) (list (s-polynomial 122 (critical-pair-first pair) 123 (critical-pair-second pair)) 124 coeff-zero 125 coeff-unit 126 0))) 126 127 (cond 127 128 ((criterion-1 pair) nil) 128 129 ((criterion-2 pair b-done f) nil) 129 130 (t 130 (let* ((dd ( pair-division-data pair))131 (let* ((dd (critical-pair-data pair)) 131 132 (p (first dd)) 132 133 (sp (second dd)) … … 134 135 (division-count (fourth dd))) 135 136 (cond 136 (( poly-zerop p);normal form completed137 ((universal-zerop p) ;normal form completed 137 138 (debug-cgb "~&~3T~d reduction~:p" division-count) 138 139 (cond 139 (( poly-zerop sp)140 ((universal-zerop sp) 140 141 (debug-cgb " ---> 0") 141 142 nil) 142 143 (t 143 (setf sp (poly-nreverse sp) 144 sp (poly-primitive-part ring sp) 144 (setf sp (poly-primitive-part sp) 145 145 f (nconc f (list sp))) 146 146 ;; Add new critical pairs 147 147 (dolist (h f) 148 ( pair-queue-insert b (make-pair h sp)))149 (debug-cgb "~& Sugar: ~dPolynomials: ~d; Pairs left: ~d; Pairs done: ~d;"150 ( pair-sugar pair) (length f) (pair-queue-size b)148 (enqueue b (make-instance 'critical-pair h sp))) 149 (debug-cgb "~&Polynomials: ~d; Pairs left: ~d; Pairs done: ~d;" 150 (length f) (queue-size b) 151 151 (hash-table-count b-done)))) 152 (setf (gethash (list ( pair-first pair) (pair-second pair))152 (setf (gethash (list (critical-pair-first pair) (critical-pair-second pair)) 153 153 b-done) t)) 154 154 (t ;normal form not complete 155 155 (do () 156 156 ((cond 157 ((> (poly-sugar sp) (pair-sugar pair)) 158 (debug-cgb "(~a)?" (poly-sugar sp)) 159 t) 160 ((poly-zerop p) 157 ((universal-zerop p) 161 158 (debug-cgb ".") 162 159 t) … … 165 162 (second dd) sp 166 163 (third dd) c 167 (fourth dd) division-count 168 (pair-sugar pair) (poly-sugar sp)) 169 (pair-queue-insert b pair)) 164 (fourth dd) division-count) 165 (enqueue b pair)) 170 166 (multiple-value-setq (p sp c division-count) 171 (normal-form-step ring-and-orderf p sp c division-count))))))))))))167 (normal-form-step f p sp c division-count))))))))))))
Note:
See TracChangeset
for help on using the changeset viewer.