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/ring.lisp@ 4322

Last change on this file since 4322 was 4322, checked in by Marek Rychlik, 8 years ago

* empty log message *

File size: 3.2 KB
Line 
1;;; -*- Mode: Lisp -*-
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 "RING"
23 (:use :cl)
24 (:export "RING"
25 "ADD-TO"
26 "SUBTRACT-FROM"
27 "MULTIPLY-BY"
28 "DIVIDE-BY"
29 "UNARY-MINUS"
30 "UNARY-INVERSE"
31 "UNIVERSAL-GCD"
32 "UNIVERSAL-EZGCD"
33 "UNIVERSAL-EQUALP"
34 "UNIVERSAL-ZEROP"
35 "MAKE-ZERO-FOR"
36 "MAKE-UNIT-FOR"
37 "->SEXP")
38 (:documentation "Defines an abstract ring class and ring operations."))
39
40(in-package "RING")
41
42(defclass ring () () (:documentation "An abstract ring."))
43
44(defgeneric multiply-by (self other)
45 (:documentation "Multiply SELF by OTHER."))
46
47(defgeneric divide-by (self other)
48 (:documentation "Divide SELF by OTHER."))
49
50(defgeneric add-to (self other)
51 (:documentation "Add OTHER to SELF."))
52
53(defgeneric subtract-from (self other)
54 (:documentation "Subtract OTHER from SELF."))
55
56(defgeneric unary-minus (self)
57 (:documentation "Changes SELF to its negative."))
58
59(defgeneric unary-inverse (self)
60 (:documentation "Changes SELF to the unary inverse of SELF."))
61
62(defgeneric universal-gcd (object other)
63 (:documentation "Returns GCD(OBJECT, OTHER)"))
64
65(defgeneric universal-ezgcd (x y)
66 (:documentation "Solves the diophantine system: X=C*X1, Y=C*X2,
67C=GCD(X,Y). It returns three values: C, X1 and Y1. The result may be obtained by
68the Euclidean algorithm."))
69
70(defgeneric universal-equalp (self other)
71 (:documentation "Return T if objects SELF and OTHER are equal, NIL otherwise.")
72 (:method ((object1 cons) (object2 cons)) (every #'universal-equalp object1 object2))
73 (:method ((self number) (other number)) (= self other)))
74
75(defgeneric universal-zerop (self)
76 (:documentation "Return T if SELF is a zero in the ring it belongs to."))
77
78(defgeneric ->sexp (self &optional vars)
79 (:documentation "Convert SELF to an S-expression."))
80
81(defgeneric make-zero-for (self)
82 (:documentation "Create a zero in the ring of SELF. A fresh instance
83should be returned upon every call."))
84
85(defgeneric make-unit-for (self)
86 (:documentation "Create a unit in the ring of SELF. A fresh instance
87should be returned upon every call."))
Note: See TracBrowser for help on using the repository browser.