[80] | 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 |
|
---|
| 22 |
|
---|
[49] | 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 24 | ;;
|
---|
| 25 | ;; Implementations of various admissible monomial orders
|
---|
| 26 | ;;
|
---|
| 27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 28 |
|
---|
| 29 | ;; pure lexicographic
|
---|
| 30 | (defun lex> (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 31 | "Return T if P>Q with respect to lexicographic order, otherwise NIL.
|
---|
| 32 | The second returned value is T if P=Q, otherwise it is NIL."
|
---|
| 33 | (declare (type monom p q) (type fixnum start end))
|
---|
| 34 | (do ((i start (1+ i)))
|
---|
| 35 | ((>= i end) (values nil t))
|
---|
| 36 | (declare (type fixnum i))
|
---|
| 37 | (cond
|
---|
| 38 | ((> (monom-elt p i) (monom-elt q i))
|
---|
| 39 | (return-from lex> (values t nil)))
|
---|
| 40 | ((< (monom-elt p i) (monom-elt q i))
|
---|
| 41 | (return-from lex> (values nil nil))))))
|
---|
| 42 |
|
---|
| 43 | ;; total degree order , ties broken by lexicographic
|
---|
| 44 | (defun grlex> (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 45 | "Return T if P>Q with respect to graded lexicographic order, otherwise NIL.
|
---|
| 46 | The second returned value is T if P=Q, otherwise it is NIL."
|
---|
| 47 | (declare (type monom p q) (type fixnum start end))
|
---|
| 48 | (let ((d1 (monom-total-degree p start end))
|
---|
| 49 | (d2 (monom-total-degree q start end)))
|
---|
| 50 | (cond
|
---|
| 51 | ((> d1 d2) (values t nil))
|
---|
| 52 | ((< d1 d2) (values nil nil))
|
---|
| 53 | (t
|
---|
| 54 | (lex> p q start end)))))
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | ;; total degree, ties broken by reverse lexicographic
|
---|
| 58 | (defun grevlex> (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 59 | "Return T if P>Q with respect to graded reverse lexicographic order,
|
---|
| 60 | NIL otherwise. The second returned value is T if P=Q, otherwise it is NIL."
|
---|
| 61 | (declare (type monom p q) (type fixnum start end))
|
---|
| 62 | (let ((d1 (monom-total-degree p start end))
|
---|
| 63 | (d2 (monom-total-degree q start end)))
|
---|
| 64 | (cond
|
---|
| 65 | ((> d1 d2) (values t nil))
|
---|
| 66 | ((< d1 d2) (values nil nil))
|
---|
| 67 | (t
|
---|
| 68 | (revlex> p q start end)))))
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | ;; reverse lexicographic
|
---|
| 72 | (defun revlex> (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 73 | "Return T if P>Q with respect to reverse lexicographic order, NIL
|
---|
| 74 | otherwise. The second returned value is T if P=Q, otherwise it is
|
---|
| 75 | NIL. This is not and admissible monomial order because some sets do
|
---|
| 76 | not have a minimal element. This order is useful in constructing other
|
---|
| 77 | orders."
|
---|
| 78 | (declare (type monom p q) (type fixnum start end))
|
---|
| 79 | (do ((i (1- end) (1- i)))
|
---|
| 80 | ((< i start) (values nil t))
|
---|
| 81 | (declare (type fixnum i))
|
---|
| 82 | (cond
|
---|
| 83 | ((< (monom-elt p i) (monom-elt q i))
|
---|
| 84 | (return-from revlex> (values t nil)))
|
---|
| 85 | ((> (monom-elt p i) (monom-elt q i))
|
---|
| 86 | (return-from revlex> (values nil nil))))))
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | (defun invlex> (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 90 | "Return T if P>Q with respect to inverse lexicographic order, NIL otherwise
|
---|
| 91 | The second returned value is T if P=Q, otherwise it is NIL."
|
---|
| 92 | (declare (type monom p q) (type fixnum start end))
|
---|
| 93 | (do ((i (1- end) (1- i)))
|
---|
| 94 | ((< i start) (values nil t))
|
---|
| 95 | (declare (type fixnum i))
|
---|
| 96 | (cond
|
---|
| 97 | ((> (monom-elt p i) (monom-elt q i))
|
---|
| 98 | (return-from invlex> (values t nil)))
|
---|
| 99 | ((< (monom-elt p i) (monom-elt q i))
|
---|
| 100 | (return-from invlex> (values nil nil))))))
|
---|