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.

source: branches/f4grobner/order.lisp@ 412

Last change on this file since 412 was 412, checked in by Marek Rychlik, 9 years ago

* empty log message *

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