Changeset 3918
- Timestamp:
- 2016-05-29T21:24:00-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/pair-queue.lisp
r3912 r3918 20 20 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 21 22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23 ;;24 ;; Critical pair queue implementation25 ;;26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;27 28 22 (defpackage "PAIR-QUEUE" 29 23 (:use :cl :priority-queue :monom :polynomial :utils) 30 (:export "SUGAR-PAIR-KEY" 31 "PAIR" 24 (:export "PAIR" 32 25 "MAKE-PAIR" 33 26 "PAIR-FIRST" … … 35 28 "PAIR-SUGAR" 36 29 "PAIR-DIVISION-DATA" 37 "SUGAR-ORDER"38 30 "*PAIR-KEY-FUNCTION*" 39 31 "*PAIR-ORDER*" … … 45 37 "PAIR-QUEUE-EMPTY-P" 46 38 "SET-PAIR-HEURISTIC" 47 )) 39 ) 40 (:documentation "Critical pair queue implementation. The pair queue is a list of critical 41 pairs, ordered by some partial order. Pair queue is a kind of priority queue.") 42 ) 48 43 49 44 50 45 (in-package :pair-queue) 51 46 52 (defun sugar-pair-key (p q &aux (lcm (universal-lcm (leading-monomial p) (leading-monomial q)))53 (d (sugar lcm)))54 "Returns list (S LCM-TOTAL-DEGREE) where S is the sugar of the S-polynomial of55 polynomials P and Q, and LCM-TOTAL-DEGREE is the degree of LCM(LM(P),LM(Q))."56 (declare (type poly p q) (type monom lcm) (type fixnum d))57 (cons (max58 (+ (- d (sugar (leading-monomial p))) (sugar p))59 (+ (- d (sugar (leading-monomial q))) (sugar q)))60 lcm))61 62 47 (defstruct (pair 63 48 (:constructor make-pair (first second 64 49 &aux 65 (sugar (car (sugar-pair-key first second)))66 50 (division-data nil)))) 67 51 (first nil :type poly) 68 52 (second nil :type poly) 69 (sugar 0 :type fixnum)70 53 (division-data nil :type list)) 71 54 72 ;;(defun pair-sugar (pair &aux (p (pair-first pair)) (q (pair-second pair))) 73 ;; (car (sugar-pair-key p q))) 74 75 (defun sugar-order (x y) 76 "Pair order based on sugar, ties broken by normal strategy." 77 (declare (type cons x y)) 78 (or (< (car x) (car y)) 79 (and (= (car x) (car y)) 80 (< (total-degree (cdr x)) 81 (total-degree (cdr y)))))) 82 83 (defvar *pair-key-function* #'sugar-pair-key 55 (defvar *pair-key-function* nil 84 56 "Function that, given two polynomials as argument, computed the key 85 57 in the pair queue.") 86 58 87 (defvar *pair-order* #'sugar-order59 (defvar *pair-order* nil 88 60 "Function that orders the keys of pairs.") 89 61 … … 125 97 to determine the priority of critical pairs in the priority queue." 126 98 (ecase method 127 ((sugar :sugar $sugar)128 (setf *pair-key-function* #'sugar-pair-key129 *pair-order* #'sugar-order))130 ; ((minimal-mock-spoly :minimal-mock-spoly $minimal_mock_spoly)131 ; (setf *pair-key-function* #'mock-spoly132 ; *pair-order* #'mock-spoly-order))133 99 ((minimal-lcm :minimal-lcm $minimal_lcm) 134 100 (setf *pair-key-function* #'(lambda (p q)
Note:
See TracChangeset
for help on using the changeset viewer.