Changeset 2201 for branches/f4grobner
- Timestamp:
- 2015-06-18T09:27:32-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/monom.lisp
r2200 r2201 64 64 (princ (slot-value m 'exponents) stream)) 65 65 66 (defun make-monom (&key 67 (dimension nil dimension-suppied-p) 68 (initial-exponents nil initial-exponents-supplied-p) 69 (initial-exponent nil initial-exponent-supplied-p) 70 &aux 71 (dimension (cond (dimension-suppied-p dimension) 72 (initial-exponents-supplied-p (length initial-exponents)) 73 (t (error "You must provide DIMENSION or INITIAL-EXPONENTS")))) 74 (exponents (cond 75 ;; when exponents are supplied 76 (initial-exponents-supplied-p 77 (when (and dimension-suppied-p (/= dimension (length initial-exponents))) 78 (error "INITIAL-EXPONENTS must have length DIMENSION")) 79 (make-array (list dimension) :initial-contents initial-exponents 80 :element-type 'exponent)) 81 ;; when all exponents are to be identical 82 (initial-exponent-supplied-p 83 (make-array (list dimension) :initial-element initial-exponent 84 :element-type 'exponent)) 85 ;; otherwise, all exponents are zero 86 (t 87 (make-array (list dimension) :element-type 'exponent :initial-element 0))))) 66 (defmethod initialize-instance ((self monom) 67 (dimension nil dimension-suppied-p) 68 (initial-exponents nil initial-exponents-supplied-p) 69 (initial-exponent nil initial-exponent-supplied-p)) 88 70 "A constructor (factory) of monomials. If DIMENSION is given, a 89 71 sequence of DIMENSION elements of type EXPONENT is constructed, where … … 91 73 to 0. Alternatively, all elements may be specified as a list 92 74 INITIAL-EXPONENTS." 93 (make-instance 'monom :dimension dimension :exponents exponents)) 75 (with-slots (dimension exponents) 76 self 77 (setf dimension (cond (dimension-suppied-p dimension) 78 (initial-exponents-supplied-p (length initial-exponents)) 79 (t (error "You must provide DIMENSION or INITIAL-EXPONENTS"))) 80 exponents (cond 81 ;; when exponents are supplied 82 (initial-exponents-supplied-p 83 (when (and dimension-suppied-p (/= dimension (length initial-exponents))) 84 (error "INITIAL-EXPONENTS must have length DIMENSION")) 85 (make-array (list dimension) :initial-contents initial-exponents 86 :element-type 'exponent)) 87 ;; when all exponents are to be identical 88 (initial-exponent-supplied-p 89 (make-array (list dimension) :initial-element initial-exponent 90 :element-type 'exponent)) 91 ;; otherwise, all exponents are zero 92 (t 93 (make-array (list dimension) :element-type 'exponent :initial-element 0))))) 94 (call-next-method)) 94 95 95 96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Note:
See TracChangeset
for help on using the changeset viewer.