/usr/share/axiom-20170501/src/algebra/UPDIVP.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | )abbrev package UPDIVP UnivariatePolynomialDivisionPackage
++ Author: Frederic Lehobey
++ Date Created: 3 June 1997
++ Date Last Updated: 3 June 1997
++ Description:
++ UnivariatePolynomialDivisionPackage provides a
++ division for non monic univarite polynomials with coefficients in
++ an \spad{IntegralDomain}.
UnivariatePolynomialDivisionPackage(R,UP) : SIG == CODE where
R : IntegralDomain
UP : UnivariatePolynomialCategory(R)
N ==> NonNegativeInteger
QR ==> Record(quotient: UP, remainder: UP)
SIG ==> with
divideIfCan : (UP,UP) -> Union(QR,"failed")
++ divideIfCan(f,g) returns quotient and remainder of the
++ division of f by g or "failed" if it has not succeeded.
CODE ==> add
divideIfCan(p1:UP,p2:UP):Union(QR,"failed") ==
zero? p2 => error "divideIfCan: division by zero"
((lc := leadingCoefficient p2) = 1) => monicDivide(p1,p2)
q: UP := 0
while not ((e := subtractIfCan(degree(p1),degree(p2))) case "failed")
repeat
c := leadingCoefficient(p1) exquo lc
c case "failed" => return "failed"
ee := e::N
q := q+monomial(c::R,ee)
p1 := p1-c*mapExponents(x +-> x+ee, p2)
[q,p1]
|