source: CGBLisp/src/RCS/monom.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.3;
2access;
3symbols;
4locks; strict;
5comment @;;; @;
6
7
81.3
9date 2009.01.22.04.04.31; author marek; state Exp;
10branches;
11next 1.2;
12
131.2
14date 2009.01.19.09.27.11; author marek; state Exp;
15branches;
16next 1.1;
17
181.1
19date 2009.01.19.07.38.34; author marek; state Exp;
20branches;
21next ;
22
23
24desc
25@@
26
27
281.3
29log
30@*** empty log message ***
31@
32text
33@#|
34 $Id$
35 *--------------------------------------------------------------------------*
36 | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@@math.arizona.edu) |
37 | Department of Mathematics, University of Arizona, Tucson, AZ 85721 |
38 | |
39 | Everyone is permitted to copy, distribute and modify the code in this |
40 | directory, as long as this copyright note is preserved verbatim. |
41 *--------------------------------------------------------------------------*
42|#
43(defpackage "MONOM"
44 (:use "COMMON-LISP")
45 (:export monom-equal monom-divides-p monom-divisible-by-p monom-rel-prime
46 monom* nmonom* monom/
47 monom-lcm monom-gcd))
48
49(in-package "MONOM")
50
51#+debug(proclaim '(optimize (speed 0) (debug 3)))
52#-debug(proclaim '(optimize (speed 3) (debug 0)))
53
54;;----------------------------------------------------------------
55;; This package implements BASIC OPERATIONS ON MONOMIALS
56;;----------------------------------------------------------------
57;; DATA STRUCTURES: Monomials are represented as lists:
58;;
59;; monom: (n1 n2 ... nk) where ni are non-negative integers
60;;
61;;----------------------------------------------------------------
62;; EXAMPLES: Suppose that variables are x and y. Then
63;;
64;; Monom x*y^2 ---> (1 2)
65;;
66;;----------------------------------------------------------------
67
68(defun monom/ (m1 m2)
69 "Divide monomial M1 by monomial M2."
70 (mapcar #'- m1 m2))
71
72(defun monom* (m1 m2)
73 "Multiply monomial M1 by monomial M2."
74 (mapcar #'+ m1 m2))
75
76(defun nmonom* (m1 m2)
77 "Multiply monomials M1 and M2 - destructive version.
78 M1 is destructively modified, M2 is not modified."
79 (mapl #'(lambda (x y) (incf (car x) (car y))) m1 m2))
80
81(defun monom-divides-p (m1 m2)
82 "Returns T if monomial M1 divides monomial M2, NIL otherwise."
83 (every #'<= m1 m2))
84
85(defun monom-divisible-by-p (m1 m2)
86 "Returns T if monomial M1 is divisible by monomial M2, NIL otherwise."
87 (every #'>= m1 m2))
88
89(defun monom-rel-prime (m1 m2)
90 "Returns T if two monomials M1 and M2 are relatively prime (disjoint)."
91 (every #'(lambda (x y) (zerop (min x y))) m1 m2))
92
93(defun monom-equal (m1 m2)
94 "Returns T if two monomials M1 and M2 are equal."
95 (every #'= m1 m2))
96
97(defun monom-lcm (m1 m2)
98 "Returns least common multiple of monomials M1 and M2."
99 (mapcar #'max m1 m2))
100
101(defun monom-gcd (m1 m2)
102 "Returns greatest common divisor of monomials M1 and M2."
103 (mapcar #'min m1 m2))
104@
105
106
1071.2
108log
109@*** empty log message ***
110@
111text
112@d19 2
113a20 2
114;;(proclaim '(optimize (speed 0) (debug 3)))
115(proclaim '(optimize (speed 3) (debug 0)))
116@
117
118
1191.1
120log
121@Initial revision
122@
123text
124@d2 1
125a2 1
126 $Id: monom.lisp,v 1.13 1997/12/02 23:41:29 marek Exp $
127d19 2
128a20 1
129(proclaim '(optimize (speed 0) (debug 3)))
130@
Note: See TracBrowser for help on using the repository browser.