1 | head 1.4;
|
---|
2 | access;
|
---|
3 | symbols;
|
---|
4 | locks; strict;
|
---|
5 | comment @;;; @;
|
---|
6 |
|
---|
7 |
|
---|
8 | 1.4
|
---|
9 | date 2009.01.22.04.00.56; author marek; state Exp;
|
---|
10 | branches;
|
---|
11 | next 1.3;
|
---|
12 |
|
---|
13 | 1.3
|
---|
14 | date 2009.01.19.09.24.56; author marek; state Exp;
|
---|
15 | branches;
|
---|
16 | next 1.2;
|
---|
17 |
|
---|
18 | 1.2
|
---|
19 | date 2009.01.19.07.40.35; author marek; state Exp;
|
---|
20 | branches;
|
---|
21 | next 1.1;
|
---|
22 |
|
---|
23 | 1.1
|
---|
24 | date 2009.01.19.06.48.09; author marek; state Exp;
|
---|
25 | branches;
|
---|
26 | next ;
|
---|
27 |
|
---|
28 |
|
---|
29 | desc
|
---|
30 | @@
|
---|
31 |
|
---|
32 |
|
---|
33 | 1.4
|
---|
34 | log
|
---|
35 | @*** empty log message ***
|
---|
36 | @
|
---|
37 | text
|
---|
38 | @#|
|
---|
39 | $Id$
|
---|
40 | *--------------------------------------------------------------------------*
|
---|
41 | | Copyright (C) 1994, Marek Rychlik (e-mail: rychlik@@math.arizona.edu) |
|
---|
42 | | Department of Mathematics, University of Arizona, Tucson, AZ 85721 |
|
---|
43 | | |
|
---|
44 | | Everyone is permitted to copy, distribute and modify the code in this |
|
---|
45 | | directory, as long as this copyright note is preserved verbatim. |
|
---|
46 | *--------------------------------------------------------------------------*
|
---|
47 | |#
|
---|
48 | (defpackage "DIVISION"
|
---|
49 | (:use "MONOM" "ORDER" "TERM" "POLY" "COEFFICIENT-RING" "COMMON-LISP")
|
---|
50 | (:export divide poly-exact-divide))
|
---|
51 |
|
---|
52 | (in-package "DIVISION")
|
---|
53 |
|
---|
54 | #+debug(proclaim '(optimize (speed 0) (debug 3)))
|
---|
55 | #-debug(proclaim '(optimize (speed 3) (debug 0)))
|
---|
56 |
|
---|
57 | (defun divide (f fl &optional
|
---|
58 | (pred #'lex>)
|
---|
59 | (ring *coefficient-ring*)
|
---|
60 | &aux (s (length fl)))
|
---|
61 | "Divide polynomial F by a list of polynomials FL; use predicate PRED
|
---|
62 | to sort monomials; assumes that the polynomials have initially been
|
---|
63 | sorted according to PRED. It returnes multiple values. The first value
|
---|
64 | is a list of quotients A. The second value is the remainder R. These
|
---|
65 | object satisfy the quation F = SUM A[J]*FL[I] + R."
|
---|
66 | (do ((a (make-list s))
|
---|
67 | r
|
---|
68 | (p f)
|
---|
69 | (division-occurred nil nil))
|
---|
70 | ((endp p) (values (mapcar #'reverse a) (reverse r)))
|
---|
71 | (declare (list a r p))
|
---|
72 | (do ((fl fl (rest fl))
|
---|
73 | (a a (rest a)))
|
---|
74 | ((or (endp fl) division-occurred))
|
---|
75 | (when (term-divides-p (car (first fl)) (first p))
|
---|
76 | (let ((quot (term/ (first p) (car (first fl)) ring)))
|
---|
77 | (push quot (car a))
|
---|
78 | (setf p (poly-op (rest p) quot (rest (first fl)) pred ring)
|
---|
79 | division-occurred t))))
|
---|
80 | (when (not division-occurred)
|
---|
81 | (setf r (cons (first p) r)
|
---|
82 | p (rest p)))))
|
---|
83 |
|
---|
84 | (defun poly-exact-divide (f g &optional (order #'lex>) (ring *coefficient-ring*))
|
---|
85 | "Divide a polynomial F by another polynomial G. Assume that exact division
|
---|
86 | with no remainder is possible. Returns the quotient."
|
---|
87 | (multiple-value-bind (q r)
|
---|
88 | (divide f (list g) order ring)
|
---|
89 | (unless (endp r) (error "Exact division failed."))
|
---|
90 | (car q)))
|
---|
91 | @
|
---|
92 |
|
---|
93 |
|
---|
94 | 1.3
|
---|
95 | log
|
---|
96 | @*** empty log message ***
|
---|
97 | @
|
---|
98 | text
|
---|
99 | @d17 2
|
---|
100 | a18 2
|
---|
101 | ;;(proclaim '(optimize (speed 0) (debug 3)))
|
---|
102 | (proclaim '(optimize (speed 3) (debug 0)))
|
---|
103 | @
|
---|
104 |
|
---|
105 |
|
---|
106 | 1.2
|
---|
107 | log
|
---|
108 | @*** empty log message ***
|
---|
109 | @
|
---|
110 | text
|
---|
111 | @d17 2
|
---|
112 | a18 1
|
---|
113 | (proclaim '(optimize (speed 0) (debug 3)))
|
---|
114 | @
|
---|
115 |
|
---|
116 |
|
---|
117 | 1.1
|
---|
118 | log
|
---|
119 | @Initial revision
|
---|
120 | @
|
---|
121 | text
|
---|
122 | @d2 1
|
---|
123 | a2 1
|
---|
124 | $Id: division.lisp,v 1.16 1997/12/04 03:44:32 marek Exp $
|
---|
125 | d17 1
|
---|
126 | a17 2
|
---|
127 | (eval-when (compile)
|
---|
128 | (proclaim '(optimize (safety 0) (speed 3))))
|
---|
129 | @
|
---|