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-17T12:18:47-07:00 (8 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial-sugar.lisp

    r4513 r4514  
    3232  (setf (slot-value self 'value) (static-sugar self)))
    3333
     34(defmethod update-instance-for-different-class :after ((old monom) (new monom-with-sugar) &key)
     35  "Add sugar to every term."
     36  (reinitialize-instance new :value (static-sugar new)))
     37
     38
    3439(defmethod multiply-by :after ((self sugar) (other sugar))
    3540  (with-slots (value)
     
    6469  (setf (slot-value self 'value) (static-sugar self)))
    6570
     71(defmethod update-instance-for-different-class :after ((old poly) (new poly-with-sugar) &key)
     72  "Add sugar to every term."
     73  (reinitialize-instance new :termlist (mapc #'(lambda (trm) (change-class trm 'term-with-sugar)) (poly-termlist new))))
     74
     75(defmethod update-instance-for-different-class :after ((old poly-with-sugar) (new poly) &key)
     76  "Drop sugar in every term."
     77  (reinitialize-instance new :termlist (mapc #'(lambda (trm) (change-class trm 'term)) (poly-termlist new))))
     78
     79
    6680(defmethod add-to ((self poly-with-sugar) (other poly-with-sugar))
    6781  "Sugar value of the sum of two polynomials, SELF and OTHER, is by definition
    68 the maximum of the sugar values of the two polynomials."
     82the maximum of the sugar values of the summands."
    6983  (with-accessors ((value sugar-value))
    7084      self
    7185    (with-accessors ((other-value sugar-value))
    7286        other
    73       (setf value (max value other-value)))))
     87      (setf value (max value other-value))))
     88  self)
     89
     90(defmethod multiply-by ((self poly-with-sugar) (other poly-with-sugar))
     91  "Sugar value of the product of two polynomials, SELF and OTHER, is by definition
     92the sum of the sugar values of the factors."
     93  (with-accessors ((value sugar-value))
     94      self
     95    (with-accessors ((other-value sugar-value))
     96        other
     97      (setf value (max value other-value))))
     98  self)
Note: See TracChangeset for help on using the changeset viewer.