head 1.3; access; symbols; locks; strict; comment @;;; @; 1.3 date 2009.01.22.04.04.31; author marek; state Exp; branches; next 1.2; 1.2 date 2009.01.19.09.27.11; author marek; state Exp; branches; next 1.1; 1.1 date 2009.01.19.07.38.34; author marek; state Exp; branches; next ; desc @@ 1.3 log @*** empty log message *** @ text @#| $Id$ *--------------------------------------------------------------------------* | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@@math.arizona.edu) | | Department of Mathematics, University of Arizona, Tucson, AZ 85721 | | | | Everyone is permitted to copy, distribute and modify the code in this | | directory, as long as this copyright note is preserved verbatim. | *--------------------------------------------------------------------------* |# (defpackage "MONOM" (:use "COMMON-LISP") (:export monom-equal monom-divides-p monom-divisible-by-p monom-rel-prime monom* nmonom* monom/ monom-lcm monom-gcd)) (in-package "MONOM") #+debug(proclaim '(optimize (speed 0) (debug 3))) #-debug(proclaim '(optimize (speed 3) (debug 0))) ;;---------------------------------------------------------------- ;; This package implements BASIC OPERATIONS ON MONOMIALS ;;---------------------------------------------------------------- ;; DATA STRUCTURES: Monomials are represented as lists: ;; ;; monom: (n1 n2 ... nk) where ni are non-negative integers ;; ;;---------------------------------------------------------------- ;; EXAMPLES: Suppose that variables are x and y. Then ;; ;; Monom x*y^2 ---> (1 2) ;; ;;---------------------------------------------------------------- (defun monom/ (m1 m2) "Divide monomial M1 by monomial M2." (mapcar #'- m1 m2)) (defun monom* (m1 m2) "Multiply monomial M1 by monomial M2." (mapcar #'+ m1 m2)) (defun nmonom* (m1 m2) "Multiply monomials M1 and M2 - destructive version. M1 is destructively modified, M2 is not modified." (mapl #'(lambda (x y) (incf (car x) (car y))) m1 m2)) (defun monom-divides-p (m1 m2) "Returns T if monomial M1 divides monomial M2, NIL otherwise." (every #'<= m1 m2)) (defun monom-divisible-by-p (m1 m2) "Returns T if monomial M1 is divisible by monomial M2, NIL otherwise." (every #'>= m1 m2)) (defun monom-rel-prime (m1 m2) "Returns T if two monomials M1 and M2 are relatively prime (disjoint)." (every #'(lambda (x y) (zerop (min x y))) m1 m2)) (defun monom-equal (m1 m2) "Returns T if two monomials M1 and M2 are equal." (every #'= m1 m2)) (defun monom-lcm (m1 m2) "Returns least common multiple of monomials M1 and M2." (mapcar #'max m1 m2)) (defun monom-gcd (m1 m2) "Returns greatest common divisor of monomials M1 and M2." (mapcar #'min m1 m2)) @ 1.2 log @*** empty log message *** @ text @d19 2 a20 2 ;;(proclaim '(optimize (speed 0) (debug 3))) (proclaim '(optimize (speed 3) (debug 0))) @ 1.1 log @Initial revision @ text @d2 1 a2 1 $Id: monom.lisp,v 1.13 1997/12/02 23:41:29 marek Exp $ d19 2 a20 1 (proclaim '(optimize (speed 0) (debug 3))) @