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/f4-matrix.lisp@ 105

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

* empty log message *

File size: 3.2 KB
Line 
1;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*-
2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3;;;
4;;; Copyright (C) 2015 Marek Rychlik <rychlik@u.arizona.edu>
5;;;
6;;; This program is free software; you can redistribute it and/or modify
7;;; it under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 2 of the License, or
9;;; (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19;;;
20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21
22(in-package :maxima)
23
24(macsyma-module f4-maxima)
25
26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27;;
28;; An implementation of the normal form
29;;
30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
32(defun f4-normal-form-step (ring fl p r c division-count
33 &aux (g (find (poly-lm p) fl
34 :test #'monom-divisible-by-p
35 :key #'poly-lm)))
36 (cond
37 (g ;division possible
38 (incf division-count)
39 (multiple-value-bind (gcd cg cp)
40 (funcall (ring-ezgcd ring) (poly-lc g) (poly-lc p))
41 (declare (ignore gcd))
42 (let ((m (monom-div (poly-lm p) (poly-lm g))))
43 ;; Multiply the equation c*f=sum ai*fi+r+p by cg.
44 (setf r (scalar-times-poly ring cg r)
45 c (funcall (ring-mul ring) c cg)
46 ;; p := cg*p-cp*m*g
47 p (grobner-op ring cp cg m p g))))
48 (debug-cgb "/"))
49 (t ;no division possible
50 (push (poly-lt p) (poly-termlist r)) ;move lt(p) to remainder
51 (setf (poly-sugar r) (max (poly-sugar r) (term-sugar (poly-lt p))))
52 (pop (poly-termlist p)) ;remove lt(p) from p
53 (debug-cgb "+")))
54 (values p r c division-count))
55
56;; Merge it sometime with poly-pseudo-divide
57(defun f4-normal-form (ring f fl &optional (top-reduction-only $poly_top_reduction_only))
58 ;; Loop invariant: c*f0=sum ai*fi+r+f, where f0 is the initial value of f
59 #+grobner-check(when (null fl) (warn "normal-form: empty divisor list."))
60 (do ((r (make-poly-zero))
61 (c (funcall (ring-unit ring)))
62 (division-count 0))
63 ((or (poly-zerop f)
64 ;;(endp fl)
65 (and top-reduction-only (not (poly-zerop r))))
66 (progn
67 (debug-cgb "~&~3T~d reduction~:p" division-count)
68 (when (poly-zerop r)
69 (debug-cgb " ---> 0")))
70 (setf (poly-termlist f) (nreconc (poly-termlist r) (poly-termlist f)))
71 (values f c division-count))
72 (declare (fixnum division-count)
73 (type poly r))
74 (multiple-value-setq (f r c division-count)
75 (f4-normal-form-step ring fl f r c division-count))))
Note: See TracBrowser for help on using the repository browser.