/usr/share/axiom-20170501/src/algebra/PFORP.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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | )abbrev package PFORP PackageForPoly
++ Author: Gaetan Hache
++ Date Created: 17 nov 1992
++ Date Last Updated: May 2010 by Tim Daly
++ Description:
++ The following is part of the PAFF package
PackageForPoly(R,PolyRing,E,dim) : SIG == CODE where
R : Ring -- was Field but change for SolveTree package. 21/01/98 )
dim : NonNegativeInteger
E : DirectProductCategory(dim,NonNegativeInteger)
PolyRing : FiniteAbelianMonoidRing(R,E)
Term ==> Record(k:E,c:R)
PI ==> PositiveInteger
NNI ==> NonNegativeInteger
INT ==> Integer
SIG ==> with
mapExponents : (E->E, PolyRing) -> PolyRing
degree : (PolyRing , Integer) -> NNI
univariate : PolyRing -> SparseUnivariatePolynomial(R)
totalDegree : PolyRing -> NNI
subs1stVar : (PolyRing , PolyRing) -> PolyRing
subs2ndVar : (PolyRing , PolyRing) -> PolyRing
subsInVar : (PolyRing, PolyRing, Integer) -> PolyRing
minimalForm : PolyRing -> PolyRing
++ minimalForm(pol) returns the minimal forms of the polynomial pol.
firstExponent : PolyRing -> E
++ firstExponent(pol) returns the exponent of the first term in the
++ representation of pol. Not to be confused with the leadingExponent
++ which is the highest exponent according to the order
++ over the monomial.
replaceVarByZero : (PolyRing,Integer) -> PolyRing
++ replaceVarByZero(pol,a) evaluate to zero the variable in pol
++ specified by the integer a.
replaceVarByOne : (PolyRing,Integer) -> PolyRing
++ replaceVarByOne(pol,a) evaluate to one the variable in pol
++ specified by the integer a.
translate : (PolyRing,List R,Integer) -> PolyRing
++ translate(pol,[a,b,c],3) apply to pol the
++ linear change of coordinates, x->x+a, y->y+b, z->1.
translate : (PolyRing,List R) -> PolyRing
++ translate(pol,[a,b,c]) apply to pol the
++ linear change of coordinates, x->x+a, y->y+b, z->z+c
degOneCoef : (PolyRing,PI) -> R
++ degOneCoef(pol,n) returns the coefficient in front of the monomial
++ specified by the positive integer.
constant : PolyRing -> R
++ constant(pol) returns the constant term of the polynomial.
homogenize : (PolyRing,INT) -> PolyRing
++ homogenize(pol,n) returns the homogenized polynomial of pol
++ with respect to the n-th variable.
listAllMonoExp : Integer -> List E
++ listAllMonoExp(l) returns all the exponents of degree l
listAllMono : NNI -> List PolyRing
++ listAllMono(l) returns all the monomials of degree l
degreeOfMinimalForm : PolyRing -> NNI
++ degreeOfMinimalForm does what it says
listVariable : () -> List PolyRing
monomials : PolyRing -> List PolyRing
CODE ==> add
import PolyRing
monomials(pol)==
zero? pol => empty()
lt:=leadingMonomial pol
cons( lt , monomials reductum pol )
lll: Integer -> E
lll(i) ==
le:=new( dim , 0$NNI)$List(NNI)
le.i := 1
directProduct( vector(le)$Vector(NNI) )$E
listVariable==
[monomial(1,ee)$PolyRing for ee in [lll(i) for i in 1..dim]]
univariate(pol)==
zero? pol => 0
d:=degree pol
lc:=leadingCoefficient pol
td := reduce("+", entries d)
monomial(lc,td)$SparseUnivariatePolynomial(R)+univariate(reductum pol)
collectExpon: List Term -> PolyRing
translateLocal: (PolyRing,List R,Integer) -> PolyRing
lA: (Integer,Integer) -> List List NNI
toListRep: PolyRing -> List Term
exponentEntryToZero: (E,Integer) -> E
exponentEntryZero?: (E,Integer) -> Boolean
homogenizeExp: (E,NNI,INT) -> E
translateMonomial: (PolyRing,List R,INT,R) -> PolyRing
leadingTerm: PolyRing -> Term
mapExponents(f,pol)==
zero?(pol) => 0
lt:=leadingTerm pol
newExp:E:= f(lt.k)
newMono:PolyRing:= monomial(lt.c,newExp)$PolyRing
newMono + mapExponents(f,reductum pol)
collectExpon(pol)==
empty? pol => 0
ft:=first pol
monomial(ft.c,ft.k) + collectExpon( rest pol )
subs1stVar(pol, spol)==
zero? pol => 0
lexpE:E:= degree pol
lexp:List NNI:= parts lexpE
coef:= leadingCoefficient pol
coef * spol ** lexp.1 * second(listVariable())**lexp.2 _
+ subs1stVar( reductum pol, spol )
subs2ndVar(pol, spol)==
zero? pol => 0
lexpE:E:= degree pol
lexp:List NNI:= parts lexpE
coef:= leadingCoefficient pol
coef * first(listVariable())**lexp.1 * spol ** lexp.2 _
+ subs2ndVar( reductum pol, spol )
subsInVar( pol, spol, n)==
one?( n ) => subs1stVar( pol, spol)
subs2ndVar(pol,spol)
translate(pol,lpt)==
zero? pol => 0
lexpE:E:= degree pol
lexp:List NNI:= parts lexpE
coef:= leadingCoefficient pol
trVar:=[(listVariable().i + (lpt.i)::PolyRing)**lexp.i for i in 1..dim]
coef * reduce("*",trVar,1) + translate(reductum pol , lpt)
translate(poll,lpt,nV)==
pol:=replaceVarByOne(poll,nV)
translateLocal(pol,lpt,nV)
translateLocal(pol,lpt,nV)==
zero?(pol) => 0
lll:List R:=[l for l in lpt | ^zero?(l)]
nbOfNonZero:=# lll
ltk:=leadingMonomial pol
ltc:=leadingCoefficient pol
if one?(nbOfNonZero) then
pol
else
translateMonomial(ltk,lpt,nV,ltc) + _
translateLocal(reductum(pol),lpt,nV)
exponentEntryToZero(exp,nV)==
pexp:= parts exp
pexp(nV):=0
directProduct(vector(pexp)$Vector(NonNegativeInteger))
exponentEntryZero?(exp,nV)==
pexp:= parts exp
zero?(pexp(nV))
replaceVarByZero(pol,nV)==
-- surement le collectExpon ici n'est pas necessaire !!!!
zero?(pol) => 0
lRep:= toListRep pol
reduce("+",_
[monomial(p.c,p.k)$PolyRing _
for p in lRep | exponentEntryZero?(p.k,nV) ],0)
replaceVarByOne(pol,nV)==
zero?(pol) => 0
lRep:= toListRep pol
reduce("+",_
[monomial(p.c,exponentEntryToZero(p.k,nV))$PolyRing for p in lRep],0)
homogenizeExp(exp,deg,nV)==
lv:List NNI:=parts(exp)
lv.nV:=(deg+lv.nV - reduce("+",lv)) pretend NNI
directProduct(vector(lv)$Vector(NNI))$E
listTerm: PolyRing -> List E
listTerm(pol)==
zero? pol => empty
cons( degree pol, listTerm reductum pol )
degree( a : PolyRing , n : Integer )==
zero? a => error "Degree for 0 is not defined for this degree fnc"
"max" / [ ee.n for ee in listTerm a ]
totalDegree p ==
zero? p => 0
"max"/[reduce("+",t::(Vector NNI), 0) for t in listTerm p]
homogenize(pol,nV)==
degP:=totalDegree(pol)
mapExponents(homogenizeExp(#1,degP,nV),pol)
degOneCoef(p:PolyRing,i:PI)==
vv:=new(dim,0)$Vector(NNI)
vv.i:=1
pd:=directProduct(vv)$E
lp:=toListRep p
lc:=[t.c for t in lp | t.k=pd]
reduce("+",lc,0)
constant(p)==
vv:=new(dim,0)$Vector(NNI)
pd:=directProduct(vv)$E
lp:=toListRep p
lc:=[t.c for t in lp | t.k=pd]
reduce("+",lc,0)
degreeOfMinimalForm(pol)==
totalDegree minimalForm pol
minimalForm(pol)==
zero?(pol) => pol
lpol:=toListRep pol
actTerm:Term:= first lpol
minDeg:NNI:=reduce("+", parts(actTerm.k))
actDeg:NNI
lminForm:List(Term):= [actTerm]
for p in rest(lpol) repeat
actDeg:= reduce("+", parts(p.k))
if actDeg = minDeg then
lminForm := concat(lminForm,p)
if actDeg < minDeg then
minDeg:=actDeg
lminForm:=[p]
collectExpon lminForm
-- le code de collectExponSort a ete emprunte a D. Augot.
leadingTerm(pol)==
zero?(pol) => error "no leading term for 0 (message from package)"
lcoef:R:=leadingCoefficient(pol)$PolyRing
lterm:PolyRing:=leadingMonomial(pol)$PolyRing
tt:E:=degree(lterm)$PolyRing
[tt,lcoef]$Term
toListRep(pol)==
zero?(pol) => empty()
lt:=leadingTerm pol
cons(lt, toListRep reductum pol)
lA(n,l)==
zero?(n) => [new((l pretend NNI),0)$List(NNI)]
one?(l) => [[(n pretend NNI)]]
concat [[ concat([i],lll) for lll in lA(n-i,l-1)] for i in 0..n]
listAllMonoExp(l)==
lst:=lA(l,(dim pretend Integer))
[directProduct(vector(pexp)$Vector(NNI)) for pexp in lst]
translateMonomial(mono,pt,nV,coef)==
lexpE:E:= degree mono
lexp:List NNI:= parts lexpE
lexp(nV):=0
trVar:=[(listVariable().i + (pt.i)::PolyRing)** lexp.i for i in 1..dim]
coef * reduce("*",trVar,1)
listAllMono(l)==
[monomial(1,e)$PolyRing for e in listAllMonoExp(l)]
|