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 2189


Ignore:
Timestamp:
2015-06-18T08:18:01-07:00 (10 years ago)
Author:
Marek Rychlik
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/f4grobner/term.lisp

    r2021 r2189  
    3838(proclaim '(optimize (speed 3) (space 0) (safety 0) (debug 0)))
    3939
    40 (defclass term ()
    41   ((monom)
    42    (coeff)))
     40(defclass term (monom)
     41  ((coeff :init-arg :coeff :accessor term-coeff)))
    4342
    4443(defun make-term (&key monom coeff)
    4544  (make-instance 'term :monom monom :coeff coeff))
    4645
    47 (defun make-term-variable (ring nvars pos
     46(defun make-term-variable (nvars pos
    4847                           &optional
    4948                             (power 1)
    50                              (coeff (funcall (ring-unit ring))))
     49                             (coeff 1))
    5150  "Construct a term in the polynomial ring RING[X[0],X[1],X[2],...X[NVARS-1]]
    5251over the ring RING which represents a single variable. It assumes
     
    5554Optionally, the term may appear with an arbitrary coefficient, which
    5655defaults to the unit of the RING."
    57   (declare (type ring ring) (type fixnum nvars pos))
     56  (declare (type fixnum nvars pos))
    5857  (make-term :monom (make-monom-variable nvars pos power)
    5958             :coeff coeff))
    6059
    61 (defun term-mul (ring term1 term2)
     60(defmethod ring-mul ((term1 term) (term2 term))
    6261  "Returns the product of the terms TERM1 and TERM2,
    6362or NIL when the product is 0. This definition takes care of divisors of 0
    6463in the coefficient ring."
    65   (declare (type ring ring) (type term term1 term2))
    66   (let ((c (funcall (ring-mul ring) (term-coeff term1) (term-coeff term2))))
    67     (unless (funcall (ring-zerop ring) c)
     64  (let ((c (ring-mul (term-coeff term1) (term-coeff term2))))
     65    (unless (ring-zerop c)
    6866      (make-term :monom (monom-mul (term-monom term1) (term-monom term2))
    6967                 :coeff c))))
Note: See TracChangeset for help on using the changeset viewer.