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 | ;; Coefficient ring operations
|
---|
25 | ;;
|
---|
26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
27 | ;;
|
---|
28 | ;; These are ALL operations that are performed on the coefficients by
|
---|
29 | ;; the package, and thus the coefficient ring can be changed by merely
|
---|
30 | ;; redefining these operations.
|
---|
31 | ;;
|
---|
32 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
33 |
|
---|
34 | (defpackage "RING"
|
---|
35 | (:use :cl)
|
---|
36 | (:export "MAKE-RING"
|
---|
37 | "*RING-OF-INTEGERS*"
|
---|
38 | "*EXPRESSION-RING*"
|
---|
39 | ))
|
---|
40 |
|
---|
41 | (in-package :ring)
|
---|
42 |
|
---|
43 | (defstruct (ring)
|
---|
44 | "Defines a RING structure, whose fields
|
---|
45 | are common ring operations necessary to implement
|
---|
46 | Groebner bases."
|
---|
47 | (parse #'identity :type function)
|
---|
48 | (unit #'identity :type function)
|
---|
49 | (zerop #'identity :type function)
|
---|
50 | (add #'identity :type function)
|
---|
51 | (sub #'identity :type function)
|
---|
52 | (uminus #'identity :type function)
|
---|
53 | (mul #'identity :type function)
|
---|
54 | (div #'identity :type function)
|
---|
55 | (lcm #'identity :type function)
|
---|
56 | (ezgcd #'identity :type function)
|
---|
57 | (gcd #'identity :type function))
|
---|
58 |
|
---|
59 | (defparameter *ring-of-integers*
|
---|
60 | (make-ring
|
---|
61 | :parse #'identity
|
---|
62 | :unit #'(lambda () 1)
|
---|
63 | :zerop #'zerop
|
---|
64 | :add #'+
|
---|
65 | :sub #'-
|
---|
66 | :uminus #'-
|
---|
67 | :mul #'*
|
---|
68 | :div #'/
|
---|
69 | :lcm #'lcm
|
---|
70 | :ezgcd #'(lambda (x y &aux (c (gcd x y))) (values c (/ x c) (/ y c)))
|
---|
71 | :gcd #'gcd)
|
---|
72 | "The ring of integers.")
|
---|
73 |
|
---|
74 | (defvar *expression-ring* *ring-of-integers*
|
---|
75 | "The ring of coefficients, over which all polynomials are assumed to
|
---|
76 | be defined.")
|
---|