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.

source: branches/f4grobner/polynomial-sugar.lisp@ 4504

Last change on this file since 4504 was 4504, checked in by Marek Rychlik, 8 years ago

* empty log message *

File size: 797 bytes
Line 
1(in-package "POLYNOMIAL")
2
3(defgeneric static-sugar (object)
4 (:documentation "Return statically calculated sugar of object OBJECT. That is,
5the sugar value which does not assume that the object is a result of any prior calculations.")
6 (:method ((object monom))
7 (total-degree object))
8 (:method ((object poly))
9 (with-slots (termlist)
10 object
11 (loop for trm in termlist maximize (sugar trm)))))
12
13(defclass sugar ()
14 ((value :initarg :value :initform -1 :accessor sugar-value :type fixnum)))
15
16(defclass monom-with-sugar (monom sugar) ())
17
18(defmethod shared-initialize :after ((self monom-with-sugar) slot-names &rest initargs &key)
19 "Initialize sugar value based on the exponents."
20 (declare (ignore slot-names initargs))
21 (setf (slot-value self 'value) (static-sugar self)))
22
23
Note: See TracBrowser for help on using the repository browser.