[74] | 1 | ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*-
|
---|
| 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 3 | ;;;
|
---|
| 4 | ;;; Copyright (C) 1999, 2002, 2009, 2015 Marek Rychlik <rychlik@u.arizona.edu>
|
---|
| 5 | ;;;
|
---|
| 6 | ;;; This program is free software; you can redistribute it and/or modify
|
---|
| 7 | ;;; it under the terms of the GNU General Public License as published by
|
---|
| 8 | ;;; the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | ;;; (at your option) any later version.
|
---|
| 10 | ;;;
|
---|
| 11 | ;;; This program is distributed in the hope that it will be useful,
|
---|
| 12 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | ;;; GNU General Public License for more details.
|
---|
| 15 | ;;;
|
---|
| 16 | ;;; You should have received a copy of the GNU General Public License
|
---|
| 17 | ;;; along with this program; if not, write to the Free Software
|
---|
| 18 | ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 19 | ;;;
|
---|
| 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 21 |
|
---|
[146] | 22 | (in-package :grobner)
|
---|
[74] | 23 |
|
---|
[62] | 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 25 | ;;
|
---|
| 26 | ;; Pair selection criteria
|
---|
| 27 | ;;
|
---|
| 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 29 |
|
---|
| 30 | (defun criterion-1 (pair)
|
---|
| 31 | "Returns T if the leading monomials of the two polynomials
|
---|
| 32 | in G pointed to by the integers in PAIR have disjoint (relatively prime)
|
---|
| 33 | monomials. This test is known as the first Buchberger criterion."
|
---|
| 34 | (declare (type pair pair))
|
---|
| 35 | (let ((f (pair-first pair))
|
---|
| 36 | (g (pair-second pair)))
|
---|
| 37 | (when (monom-rel-prime-p (poly-lm f) (poly-lm g))
|
---|
| 38 | (debug-cgb ":1")
|
---|
| 39 | (return-from criterion-1 t))))
|
---|
| 40 |
|
---|
| 41 | (defun criterion-2 (pair b-done partial-basis
|
---|
| 42 | &aux (f (pair-first pair)) (g (pair-second pair))
|
---|
| 43 | (place :before))
|
---|
| 44 | "Returns T if the leading monomial of some element P of
|
---|
| 45 | PARTIAL-BASIS divides the LCM of the leading monomials of the two
|
---|
| 46 | polynomials in the polynomial list PARTIAL-BASIS, and P paired with
|
---|
| 47 | each of the polynomials pointed to by the the PAIR has already been
|
---|
| 48 | treated, as indicated by the absence in the hash table B-done."
|
---|
| 49 | (declare (type pair pair) (type hash-table b-done)
|
---|
| 50 | (type poly f g))
|
---|
| 51 | ;; In the code below we assume that pairs are ordered as follows:
|
---|
| 52 | ;; if PAIR is (I J) then I appears before J in the PARTIAL-BASIS.
|
---|
| 53 | ;; We traverse the list PARTIAL-BASIS and keep track of where we
|
---|
| 54 | ;; are, so that we can produce the pairs in the correct order
|
---|
| 55 | ;; when we check whether they have been processed, i.e they
|
---|
| 56 | ;; appear in the hash table B-done
|
---|
| 57 | (dolist (h partial-basis nil)
|
---|
| 58 | (cond
|
---|
| 59 | ((eq h f)
|
---|
| 60 | #+grobner-check(assert (eq place :before))
|
---|
| 61 | (setf place :in-the-middle))
|
---|
| 62 | ((eq h g)
|
---|
| 63 | #+grobner-check(assert (eq place :in-the-middle))
|
---|
| 64 | (setf place :after))
|
---|
| 65 | ((and (monom-divides-monom-lcm-p (poly-lm h) (poly-lm f) (poly-lm g))
|
---|
| 66 | (gethash (case place
|
---|
| 67 | (:before (list h f))
|
---|
| 68 | ((:in-the-middle :after) (list f h)))
|
---|
| 69 | b-done)
|
---|
| 70 | (gethash (case place
|
---|
| 71 | ((:before :in-the-middle) (list h g))
|
---|
| 72 | (:after (list g h)))
|
---|
| 73 | b-done))
|
---|
| 74 | (debug-cgb ":2")
|
---|
| 75 | (return-from criterion-2 t)))))
|
---|