head 1.4; access; symbols; locks; strict; comment @;;; @; 1.4 date 2009.01.22.04.08.39; author marek; state Exp; branches; next 1.3; 1.3 date 2009.01.19.09.31.48; author marek; state Exp; branches; next 1.2; 1.2 date 2009.01.19.07.39.39; author marek; state Exp; branches; next 1.1; 1.1 date 2009.01.19.06.45.58; author marek; state Exp; branches; next ; desc @@ 1.4 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 "TERM" (:use "MONOM" "COEFFICIENT-RING" "COMMON-LISP") (:export term-divides-p term* term/ term-coefficient term-monom monom-times-term)) (in-package "TERM") #+debug(proclaim '(optimize (speed 0) (debug 3))) #-debug(proclaim '(optimize (speed 3) (debug 0))) ;;---------------------------------------------------------------- ;; Basic operations on terms ;;---------------------------------------------------------------- ;; THE REPRESENTATION: Terms are cons cells consisting ;; of a monom and coefficient ;; ;; term: (monom . coefficient) ;; ;;---------------------------------------------------------------- ;; EXAMPLES: Suppose that variables are x and y. Then ;; Term 3*x*y^2 ---> ((1 2) . 3) ;;---------------------------------------------------------------- ;; Multiplication of terms (defun term* (term1 term2 &optional (ring *coefficient-ring*)) (cons (monom* (car term1) (car term2)) (funcall (ring-* ring) (cdr term1) (cdr term2)))) ;;;; Division of terms (defun term/ (term1 term2 &optional (ring *coefficient-ring*)) (cons (monom/ (car term1) (car term2)) (funcall (ring-/ ring) (cdr term1) (cdr term2)))) ;; Multiply monomial by term (defun monom-times-term (m term) (cons (monom* m (car term)) (cdr term))) ;; Whether a term divides another term (defun term-divides-p (term1 term2) (monom-divides-p (car term1) (car term2))) ;; Accessor functions (defmacro term-monom (term) `(car ,term)) (defmacro term-coefficient (term) `(cdr ,term)) ;; Setf methods (defsetf term-monom (term) (monom) `(setf (car ,term) ,monom)) (defsetf term-coefficient (term) (coefficient) `(setf (cdr ,term) ,coefficient)) @ 1.3 log @*** empty log message *** @ text @d18 2 a19 2 ;;(proclaim '(optimize (speed 0) (debug 3))) (proclaim '(optimize (speed 3) (debug 0))) @ 1.2 log @*** empty log message *** @ text @d18 2 a19 1 (proclaim '(optimize (speed 0) (debug 3))) @ 1.1 log @Initial revision @ text @d2 1 a2 1 $Id: term.lisp,v 1.30 1997/11/28 23:23:30 marek Exp $ d15 1 d17 3 a32 4 (eval-when (compile) (proclaim '(optimize (speed 3) (safety 0))) (proclaim '(inline term-divides-p term* term/))) @