/usr/share/axiom-20170501/src/algebra/XDPOLY.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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | )abbrev domain XDPOLY XDistributedPolynomial
++ Author: Michel Petitot petitot@lifl.fr
++ Date Created: 91
++ Date Last Updated: 7 Juillet 92
++ Description:
++ This type supports distributed multivariate polynomials
++ whose variables do not commute.
++ The coefficient ring may be non-commutative too.
++ However, coefficients and variables commute.
XDistributedPolynomial(vl,R) : SIG == CODE where
vl : OrderedSet
R : Ring
WORD ==> OrderedFreeMonoid(vl)
I ==> Integer
NNI ==> NonNegativeInteger
TERM ==> Record(k:WORD, c:R)
SIG ==> Join(FreeModuleCat(R, WORD), XPolynomialsCat(vl,R))
CODE ==> XPolynomialRing(R,WORD) add
import( WORD, TERM)
-- Representation
Rep := List TERM
-- local functions
shw: (WORD , WORD) -> % -- shuffle de 2 mots
-- definitions
mindegTerm p == last(p)$Rep
if R has CommutativeRing then
sh(p:%, n:NNI):% ==
n=0 => 1
n=1 => p
n1: NNI := (n-$I 1)::NNI
sh(p, sh(p,n1))
sh(p1:%, p2:%) ==
p:% := 0
for t1 in p1 repeat
for t2 in p2 repeat
p := p + (t1.c * t2.c) * shw(t1.k,t2.k)
p
coerce(v: vl):% == coerce(v::WORD)
v:vl * p:% ==
[[v * t.k , t.c]$TERM for t in p]
mirror p ==
null p => p
monom(mirror$WORD leadingMonomial p, leadingCoefficient p) + _
mirror reductum p
degree(p) == length(maxdeg(p))$WORD
trunc(p, n) ==
p = 0 => p
degree(p) > n => trunc( reductum p , n)
p
varList p ==
constant? p => []
le : List vl := "setUnion"/[varList(t.k) for t in p]
sort_!(le)
rquo(p:% , w: WORD) ==
[[r::WORD,t.c]$TERM for t in p | not (r:= rquo(t.k,w)) case "failed" ]
lquo(p:% , w: WORD) ==
[[r::WORD,t.c]$TERM for t in p | not (r:= lquo(t.k,w)) case "failed" ]
rquo(p:% , v: vl) ==
[[r::WORD,t.c]$TERM for t in p | not (r:= rquo(t.k,v)) case "failed" ]
lquo(p:% , v: vl) ==
[[r::WORD,t.c]$TERM for t in p | not (r:= lquo(t.k,v)) case "failed" ]
shw(w1,w2) ==
w1 = 1$WORD => w2::%
w2 = 1$WORD => w1::%
x: vl := first w1 ; y: vl := first w2
x * shw(rest w1,w2) + y * shw(w1,rest w2)
lquo(p:%,q:%):% ==
+/ [r * t.c for t in q | (r := lquo(p,t.k)) ^= 0]
rquo(p:%,q:%):% ==
+/ [r * t.c for t in q | (r := rquo(p,t.k)) ^= 0]
coef(p:%,q:%):R ==
p = 0 => 0$R
q = 0 => 0$R
p.first.k > q.first.k => coef(p.rest,q)
p.first.k < q.first.k => coef(p,q.rest)
return p.first.c * q.first.c + coef(p.rest,q.rest)
|