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@ 162

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

* empty log message *

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