1 |
;; Calculator for GNU Emacs, part II [calc-poly.el] |
;;; calc-poly.el --- polynomial functions for Calc |
2 |
|
|
3 |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
4 |
;; Written by Dave Gillespie, daveg@synaptics.com. |
|
5 |
|
;; Author: David Gillespie <daveg@synaptics.com> |
6 |
|
;; Maintainer: Colin Walters <walters@debian.org> |
7 |
|
|
8 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
9 |
|
|
22 |
;; file named COPYING. Among other things, the copyright notice |
;; file named COPYING. Among other things, the copyright notice |
23 |
;; and this notice must be preserved on all copies. |
;; and this notice must be preserved on all copies. |
24 |
|
|
25 |
|
;;; Commentary: |
26 |
|
|
27 |
|
;;; Code: |
28 |
|
|
29 |
;; This file is autoloaded from calc-ext.el. |
;; This file is autoloaded from calc-ext.el. |
30 |
(require 'calc-ext) |
(require 'calc-ext) |
138 |
;;; Originally by Ove Ewerlid (ewerlid@mizar.DoCS.UU.SE). |
;;; Originally by Ove Ewerlid (ewerlid@mizar.DoCS.UU.SE). |
139 |
;;; Modifications and simplifications by daveg. |
;;; Modifications and simplifications by daveg. |
140 |
|
|
141 |
(setq math-poly-modulus 1) |
(defvar math-poly-modulus 1) |
142 |
|
|
143 |
;;; Return gcd of two polynomials |
;;; Return gcd of two polynomials |
144 |
(defun calcFunc-pgcd (pn pd) |
(defun calcFunc-pgcd (pn pd) |
238 |
|
|
239 |
|
|
240 |
;;; Divide two polynomials. Return (quotient . remainder). |
;;; Divide two polynomials. Return (quotient . remainder). |
241 |
|
(defvar math-poly-div-base nil) |
242 |
(defun math-poly-div (u v &optional math-poly-div-base) |
(defun math-poly-div (u v &optional math-poly-div-base) |
243 |
(if math-poly-div-base |
(if math-poly-div-base |
244 |
(math-do-poly-div u v) |
(math-do-poly-div u v) |
245 |
(math-do-poly-div (calcFunc-expand u) (calcFunc-expand v)))) |
(math-do-poly-div (calcFunc-expand u) (calcFunc-expand v)))) |
|
(setq math-poly-div-base nil) |
|
246 |
|
|
247 |
(defun math-poly-div-exact (u v &optional base) |
(defun math-poly-div-exact (u v &optional base) |
248 |
(let ((res (math-poly-div u v base))) |
(let ((res (math-poly-div u v base))) |