[79] | 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 |
|
---|
| 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 24 | ;;
|
---|
| 25 | ;; Order making functions
|
---|
| 26 | ;;
|
---|
| 27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 28 |
|
---|
| 29 | (defvar *monomial-order* #'lex>
|
---|
| 30 | "Default order for monomial comparisons")
|
---|
| 31 |
|
---|
| 32 | (defmacro monomial-order (x y)
|
---|
| 33 | `(funcall *monomial-order* ,x ,y))
|
---|
| 34 |
|
---|
| 35 | (defun reverse-monomial-order (x y)
|
---|
| 36 | (monomial-order y x))
|
---|
| 37 |
|
---|
| 38 | (defvar *primary-elimination-order* #'lex>)
|
---|
| 39 |
|
---|
| 40 | (defvar *secondary-elimination-order* #'lex>)
|
---|
| 41 |
|
---|
| 42 | (defvar *elimination-order* nil
|
---|
| 43 | "Default elimination order used in elimination-based functions.
|
---|
| 44 | If not NIL, it is assumed to be a proper elimination order. If NIL,
|
---|
| 45 | we will construct an elimination order using the values of
|
---|
| 46 | *PRIMARY-ELIMINATION-ORDER* and *SECONDARY-ELIMINATION-ORDER*.")
|
---|
| 47 |
|
---|
| 48 | (defun elimination-order (k)
|
---|
| 49 | "Return a predicate which compares monomials according to the
|
---|
| 50 | K-th elimination order. Two variables *PRIMARY-ELIMINATION-ORDER*
|
---|
| 51 | and *SECONDARY-ELIMINATION-ORDER* control the behavior on the first K
|
---|
| 52 | and the remaining variables, respectively."
|
---|
| 53 | (declare (type fixnum k))
|
---|
| 54 | #'(lambda (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 55 | (declare (type monom p q) (type fixnum start end))
|
---|
| 56 | (multiple-value-bind (primary equal)
|
---|
| 57 | (funcall *primary-elimination-order* p q start k)
|
---|
| 58 | (if equal
|
---|
| 59 | (funcall *secondary-elimination-order* p q k end)
|
---|
| 60 | (values primary nil)))))
|
---|
| 61 |
|
---|
| 62 | (defun elimination-order-1 (p q &optional (start 0) (end (monom-dimension p)))
|
---|
| 63 | "Equivalent to the function returned by the call to (ELIMINATION-ORDER 1)."
|
---|
| 64 | (declare (type monom p q) (type fixnum start end))
|
---|
| 65 | (cond
|
---|
| 66 | ((> (monom-elt p start) (monom-elt q start)) (values t nil))
|
---|
| 67 | ((< (monom-elt p start) (monom-elt q start)) (values nil nil))
|
---|
| 68 | (t (funcall *secondary-elimination-order* p q (1+ start) end))))
|
---|