close Warning: Can't synchronize with repository "(default)" (The repository directory has changed, you should resynchronize the repository with: trac-admin $ENV repository resync '(default)'). Look in the Trac log for more information.

Changeset 3446 for branches/f4grobner


Ignore:
Timestamp:
2015-09-05T09:24:58-07:00 (9 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/monom.lisp

    r3443 r3446  
    2121
    2222(defpackage "MONOM"
    23   (:use :cl)
     23  (:use :cl :copy)
    2424  (:export "MONOM"
    2525           "EXPONENT"
     
    158158
    159159
    160 (defmethod monom-sugar (m &aux (start 0) (end (monom-dimension m)))
    161   "Return the sugar of a monomial M. Optinally, a range
    162 of variables may be specified with arguments START and END."
    163   (declare (type fixnum start end))
    164   (monom-total-degree m start end))
    165 
    166 (defmethod monom-multiply-by ((self monom) (other monom))
    167   (with-slots ((exponents1 exponents))
    168       self
    169     (with-slots ((exponents2 exponents))
    170         other
    171       (unless (= (length exponents1) (length exponents2))
    172         (error "Incompatible dimensions"))
    173       (map-into exponents1 #'+ exponents1 exponents2)))
    174   self)
    175 
    176 (defmethod divide-by ((self monom) (other monom))
    177   (with-slots ((exponents1 exponents))
    178       self
    179     (with-slots ((exponents2 exponents))
    180         other
    181       (unless (= (length exponents1) (length exponents2))
    182         (error "divide-by: Incompatible dimensions."))
    183       (unless (every #'>= exponents1 exponents2)
    184         (error "divide-by: Negative power would result."))
    185       (map-into exponents1 #'- exponents1 exponents2)))
    186   self)
    187 
    188 (defmethod monom-copy-instance ((object monom)  &rest initargs &key &allow-other-keys)
    189   "An :AROUNT method for COPY-INSTANCE. The primary method is a shallow copy,
    190   while for monomials we typically need a fresh copy of the
    191   exponents."
    192   (declare (ignore object initargs))
    193   (let ((copy (call-next-method)))
    194     (setf (monom-exponents copy) (copy-seq (monom-exponents copy)))
    195     copy))
     160(defmethod monom-sugar (m &optional start end)
     161  (:documentation "Return the sugar of a monomial M. Optinally, a range
     162of variables may be specified with arguments START and END.")
     163  (:method ((m monom)  &optional (start 0) (end (monom-dimension m)))
     164    (declare (type fixnum start end))
     165    (monom-total-degree m start end)))
     166
     167(defgeneric monom-multiply-by (self other)
     168  (:method ((self monom) (other monom))
     169    (with-slots ((exponents1 exponents))
     170        self
     171      (with-slots ((exponents2 exponents))
     172          other
     173        (unless (= (length exponents1) (length exponents2))
     174          (error "Incompatible dimensions"))
     175        (map-into exponents1 #'+ exponents1 exponents2)))
     176  self))
     177
     178(defgeneric divide-by (self other)
     179  (:method ((self monom) (other monom))
     180    (with-slots ((exponents1 exponents))
     181        self
     182      (with-slots ((exponents2 exponents))
     183          other
     184        (unless (= (length exponents1) (length exponents2))
     185          (error "divide-by: Incompatible dimensions."))
     186        (unless (every #'>= exponents1 exponents2)
     187          (error "divide-by: Negative power would result."))
     188        (map-into exponents1 #'- exponents1 exponents2)))
     189  self))
     190
     191(defgeneric monom-copy-instance (object &rest initargs &key &allow-other-keys)
     192  (:documentation "Returns a deep copy of OBJECT.")
     193  (:method ((object monom)  &rest initargs &key &allow-other-keys)
     194    (declare (ignore object initargs))
     195    (let ((copy (call-next-method)))
     196      (setf (monom-exponents copy) (copy-seq (monom-exponents copy)))
     197      copy)))
    196198
    197199(defmethod monom-multiply-2 ((m1 monom) (m2 monom))
Note: See TracChangeset for help on using the changeset viewer.