1 | head 1.4;
|
---|
2 | access;
|
---|
3 | symbols;
|
---|
4 | locks; strict;
|
---|
5 | comment @;;; @;
|
---|
6 |
|
---|
7 |
|
---|
8 | 1.4
|
---|
9 | date 2009.01.22.04.08.39; author marek; state Exp;
|
---|
10 | branches;
|
---|
11 | next 1.3;
|
---|
12 |
|
---|
13 | 1.3
|
---|
14 | date 2009.01.19.09.31.48; author marek; state Exp;
|
---|
15 | branches;
|
---|
16 | next 1.2;
|
---|
17 |
|
---|
18 | 1.2
|
---|
19 | date 2009.01.19.07.39.39; author marek; state Exp;
|
---|
20 | branches;
|
---|
21 | next 1.1;
|
---|
22 |
|
---|
23 | 1.1
|
---|
24 | date 2009.01.19.06.45.58; author marek; state Exp;
|
---|
25 | branches;
|
---|
26 | next ;
|
---|
27 |
|
---|
28 |
|
---|
29 | desc
|
---|
30 | @@
|
---|
31 |
|
---|
32 |
|
---|
33 | 1.4
|
---|
34 | log
|
---|
35 | @*** empty log message ***
|
---|
36 | @
|
---|
37 | text
|
---|
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 |
|
---|
105 | 1.3
|
---|
106 | log
|
---|
107 | @*** empty log message ***
|
---|
108 | @
|
---|
109 | text
|
---|
110 | @d18 2
|
---|
111 | a19 2
|
---|
112 | ;;(proclaim '(optimize (speed 0) (debug 3)))
|
---|
113 | (proclaim '(optimize (speed 3) (debug 0)))
|
---|
114 | @
|
---|
115 |
|
---|
116 |
|
---|
117 | 1.2
|
---|
118 | log
|
---|
119 | @*** empty log message ***
|
---|
120 | @
|
---|
121 | text
|
---|
122 | @d18 2
|
---|
123 | a19 1
|
---|
124 | (proclaim '(optimize (speed 0) (debug 3)))
|
---|
125 | @
|
---|
126 |
|
---|
127 |
|
---|
128 | 1.1
|
---|
129 | log
|
---|
130 | @Initial revision
|
---|
131 | @
|
---|
132 | text
|
---|
133 | @d2 1
|
---|
134 | a2 1
|
---|
135 | $Id: term.lisp,v 1.30 1997/11/28 23:23:30 marek Exp $
|
---|
136 | d15 1
|
---|
137 | d17 3
|
---|
138 | a32 4
|
---|
139 | (eval-when (compile)
|
---|
140 | (proclaim '(optimize (speed 3) (safety 0)))
|
---|
141 | (proclaim '(inline term-divides-p term* term/)))
|
---|
142 |
|
---|
143 | @
|
---|