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 4300 for branches


Ignore:
Timestamp:
2016-06-04T22:13:59-07:00 (8 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/integer-ring.lisp

    r4267 r4300  
    2121
    2222(defpackage "INTEGER-RING"
    23   (:use :cl :copy :ring)
     23  (:use :cl :copy :ring :rational-field)
    2424  (:export "INTEGER-RING"
    2525           "INTEGER-RING-VALUE"
     
    3939(in-package "INTEGER-RING")
    4040
    41 (defclass integer-ring (ring)
     41(defclass integer-ring (rational-field)
    4242  ((value :initarg :value :initform 0 :accessor integer-ring-value :type integer))
    4343  (:documentation "An object representing an integer.")
     
    5050      (format stream "VALUE=~A" value))))
    5151
    52 (defmethod  multiply-by ((self integer-ring) (other integer-ring))
    53   (with-slots (value)
    54       self
    55     (with-slots ((other-value value))
    56         other
    57     (setf value (* value other-value))))
    58   self)
    59 
    60 (defmethod divide-by ((self integer-ring) (other integer-ring))
    61   (with-slots (value)
    62       self
    63     (with-slots ((other-value value))
    64         other
    65       (assert (zerop (mod value other-value)))
    66       (setf value (/ value other-value))))
    67   self)
    68 
    69 (defmethod  add-to ((self integer-ring) (other integer-ring))
    70   (with-slots (value)
    71       self
    72     (with-slots ((other-value value))
    73         other
    74     (setf value (+ value other-value))))
    75   self)
    76 
    77 (defmethod  subtract-from ((self integer-ring) (other integer-ring))
    78   (with-slots (value)
    79       self
    80     (with-slots ((other-value value))
    81         other
    82       (setf value (- value other-value))))
    83   self)
    84 
    85 (defmethod unary-minus ((self integer-ring))
    86   (with-slots (value)
    87       self
    88     (setf value (- value)))
    89   self)
    90 
    9152(defmethod unary-inverse ((self integer-ring))
    9253  (with-slots (value)
     
    9657      (-1 self)
    9758      (otherwise (error "Non-invertible ring element: ~S" self)))))
    98 
    99 (defmethod universal-zerop ((self integer-ring))
    100   (with-slots (value)
    101       self
    102     (zerop value)))
    10359
    10460(defmethod universal-gcd ((self integer-ring) (other integer-ring))
     
    11874                (make-instance 'integer-ring :value (/ value c))
    11975                (make-instance 'integer-ring :value (/ other-value c)))))))
    120 
    121 (defmethod universal-equalp ((self integer-ring) (other integer-ring))
    122   (with-slots (value)
    123       self
    124     (with-slots ((other-value value))
    125         other
    126       (= value other-value))))
    127 
    128 (defmethod ->sexp ((self integer-ring) &optional vars)
    129   (declare (ignore vars))
    130   (integer-ring-value self))
Note: See TracChangeset for help on using the changeset viewer.