source: CGBLisp/src/RCS/term.lisp,v@ 1

Last change on this file since 1 was 1, checked in by Marek Rychlik, 15 years ago

First import of a version circa 1997.

File size: 3.1 KB
Line 
1head 1.4;
2access;
3symbols;
4locks; strict;
5comment @;;; @;
6
7
81.4
9date 2009.01.22.04.08.39; author marek; state Exp;
10branches;
11next 1.3;
12
131.3
14date 2009.01.19.09.31.48; author marek; state Exp;
15branches;
16next 1.2;
17
181.2
19date 2009.01.19.07.39.39; author marek; state Exp;
20branches;
21next 1.1;
22
231.1
24date 2009.01.19.06.45.58; author marek; state Exp;
25branches;
26next ;
27
28
29desc
30@@
31
32
331.4
34log
35@*** empty log message ***
36@
37text
38@#|
39 $Id$
40 *--------------------------------------------------------------------------*
41 | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@@math.arizona.edu) |
42 | Department of Mathematics, University of Arizona, Tucson, AZ 85721 |
43 | |
44 | Everyone is permitted to copy, distribute and modify the code in this |
45 | directory, as long as this copyright note is preserved verbatim. |
46 *--------------------------------------------------------------------------*
47|#
48
49(defpackage "TERM"
50 (:use "MONOM" "COEFFICIENT-RING" "COMMON-LISP")
51 (:export term-divides-p term* term/ term-coefficient term-monom monom-times-term))
52
53(in-package "TERM")
54
55#+debug(proclaim '(optimize (speed 0) (debug 3)))
56#-debug(proclaim '(optimize (speed 3) (debug 0)))
57
58;;----------------------------------------------------------------
59;; Basic operations on terms
60;;----------------------------------------------------------------
61;; THE REPRESENTATION: Terms are cons cells consisting
62;; of a monom and coefficient
63;;
64;; term: (monom . coefficient)
65;;
66;;----------------------------------------------------------------
67;; EXAMPLES: Suppose that variables are x and y. Then
68;; Term 3*x*y^2 ---> ((1 2) . 3)
69;;----------------------------------------------------------------
70
71;; Multiplication of terms
72(defun term* (term1 term2 &optional (ring *coefficient-ring*))
73 (cons
74 (monom* (car term1) (car term2))
75 (funcall (ring-* ring) (cdr term1) (cdr term2))))
76
77;;;; Division of terms
78(defun term/ (term1 term2 &optional (ring *coefficient-ring*))
79 (cons
80 (monom/ (car term1) (car term2))
81 (funcall (ring-/ ring) (cdr term1) (cdr term2))))
82
83;; Multiply monomial by term
84(defun monom-times-term (m term)
85 (cons (monom* m (car term)) (cdr term)))
86
87;; Whether a term divides another term
88(defun term-divides-p (term1 term2)
89 (monom-divides-p (car term1) (car term2)))
90
91;; Accessor functions
92(defmacro term-monom (term) `(car ,term))
93(defmacro term-coefficient (term) `(cdr ,term))
94
95;; Setf methods
96(defsetf term-monom (term) (monom)
97 `(setf (car ,term) ,monom))
98
99(defsetf term-coefficient (term) (coefficient)
100 `(setf (cdr ,term) ,coefficient))
101
102@
103
104
1051.3
106log
107@*** empty log message ***
108@
109text
110@d18 2
111a19 2
112;;(proclaim '(optimize (speed 0) (debug 3)))
113(proclaim '(optimize (speed 3) (debug 0)))
114@
115
116
1171.2
118log
119@*** empty log message ***
120@
121text
122@d18 2
123a19 1
124(proclaim '(optimize (speed 0) (debug 3)))
125@
126
127
1281.1
129log
130@Initial revision
131@
132text
133@d2 1
134a2 1
135 $Id: term.lisp,v 1.30 1997/11/28 23:23:30 marek Exp $
136d15 1
137d17 3
138a32 4
139(eval-when (compile)
140 (proclaim '(optimize (speed 3) (safety 0)))
141 (proclaim '(inline term-divides-p term* term/)))
142
143@
Note: See TracBrowser for help on using the repository browser.