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 2442


Ignore:
Timestamp:
2015-06-19T09:52:11-07:00 (10 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/polynomial.lisp

    r1927 r2442  
    8484(proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0)))
    8585
    86 (defstruct (poly
     86#|
    8787             ;;
    8888             ;; BOA constructor, by default constructs zero polynomial
     
    9999                                           (termlist (termlist-unit ring dimension))
    100100                                           (sugar 0))))
    101   (termlist nil :type list)
    102   (sugar -1 :type fixnum))
     101
     102|#
     103
     104(defclass poly ()
     105  ((termlist :initarg :terms :accessor poly-termlist))
     106  (:default-initargs :termlist nil))
    103107
    104108;; Leading term
    105 (defmacro poly-lt (p) `(car (poly-termlist ,p)))
     109(defgeneric leading-term (object)
     110  (:method ((self poly))
     111    (car (poly-termlist self))))
    106112
    107113;; Second term
    108 (defmacro poly-second-lt (p) `(cadar (poly-termlist ,p)))
    109 
    110 ;; Leading monomial
    111 (defun poly-lm (p)
    112   (declare (type poly p))
    113   (term-monom (poly-lt p)))
    114 
    115 ;; Second monomial
    116 (defun poly-second-lm (p)
    117   (declare (type poly p))
    118   (term-monom (poly-second-lt p)))
     114(defgeneric second-leading-term (object)
     115  (:method ((self poly))
     116    (cadar (poly-termlist self))))
    119117
    120118;; Leading coefficient
    121 (defun poly-lc (p)
    122   (declare (type poly p))
    123   (term-coeff (poly-lt p)))
     119(defgeneric leading-coefficient (object)
     120  (:method ((self poly))
     121    (r-coeff (leading-term self))))
    124122
    125123;; Second coefficient
    126 (defun poly-second-lc (p)
    127   (declare (type poly p))
    128   (term-coeff (poly-second-lt p)))
     124(defgeneric second-leading-coefficient (object)
     125  (:method ((self poly))
     126    (term-coeff (second-leading-term self))))
    129127
    130128;; Testing for a zero polynomial
Note: See TracChangeset for help on using the changeset viewer.