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.

Ignore:
Timestamp:
2016-06-04T18:37:30-07:00 (8 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/monom.lisp

    r4225 r4226  
    536536
    537537(defclass term (monom)
    538   ((coeff :initarg :coeff :initform (error "Must specify coefficient.") :accessor term-coeff :type ring))
     538  ((coeff :initarg :coeff :accessor term-coeff :type ring))
     539  (:default-initargs :coeff 1)
    539540  (:documentation "Implements a term, i.e. a product of a scalar
    540541and powers of some variables, such as 5*X^2*Y^3."))
    541542
     543(defmethod initialize-instance :around ((self term) &rest initargs &key coeff)
     544  "A convenience method. If a coefficient is an integer, wrap it in the INTEGER-RING object"
     545  ;; Dispatch on supplied type of coefficient
     546  (typecase coeff
     547    (integer
     548     (setf (getf initargs :coeff) (make-instance 'integer-ring :value coeff))))
     549  ;; Now pass new initargs to the next method
     550  (apply #'call-next-method (cons self initargs)))
     551 
    542552(defmethod update-instance-for-different-class :after ((old monom) (new term) &key (coeff 1))
    543553  "Converts OLD of class MONOM to a NEW of class TERM, initializing coefficient to COEFF."
Note: See TracChangeset for help on using the changeset viewer.