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/term.lisp@ 69

Last change on this file since 69 was 51, checked in by Marek Rychlik, 9 years ago

* empty log message *

File size: 1.6 KB
Line 
1(defun make-term-variable (ring nvars pos
2 &optional
3 (power 1)
4 (coeff (funcall (ring-unit ring)))
5 &aux
6 (monom (make-monom nvars :initial-element 0)))
7 (declare (fixnum nvars pos power))
8 (incf (monom-elt monom pos) power)
9 (make-term monom coeff))
10
11(defstruct (term
12 (:constructor make-term (monom coeff))
13 ;;(:constructor make-term-variable)
14 ;;(:type list)
15 )
16 (monom (make-monom 0) :type monom)
17 (coeff nil))
18
19(defun term-sugar (term)
20 (monom-sugar (term-monom term)))
21
22(defun termlist-sugar (p &aux (sugar -1))
23 (declare (fixnum sugar))
24 (dolist (term p sugar)
25 (setf sugar (max sugar (term-sugar term)))))
26
27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28;;
29;; Additional structure operations on a list of terms
30;;
31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
33(defun termlist-contract (p &optional (k 1))
34 "Eliminate first K variables from a polynomial P."
35 (mapcar #'(lambda (term) (make-term (monom-contract k (term-monom term))
36 (term-coeff term)))
37 p))
38
39(defun termlist-extend (p &optional (m (make-monom 1 :initial-element 0)))
40 "Extend every monomial in a polynomial P by inserting at the
41beginning of every monomial the list of powers M."
42 (mapcar #'(lambda (term) (make-term (monom-append m (term-monom term))
43 (term-coeff term)))
44 p))
45
46(defun termlist-add-variables (p n)
47 "Add N variables to a polynomial P by inserting zero powers
48at the beginning of each monomial."
49 (declare (fixnum n))
50 (mapcar #'(lambda (term)
51 (make-term (monom-append (make-monom n :initial-element 0)
52 (term-monom term))
53 (term-coeff term)))
54 p))
Note: See TracBrowser for help on using the repository browser.