Révision 78 pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage
sagePolynomialOperations.sage (revision 78) | ||
---|---|---|
25 | 25 |
# We work from p^0 * N^alpha to p^alpha * N^0 |
26 | 26 |
for pPower in xrange(0, alpha + 1): |
27 | 27 |
# pPower == 0 is a special case. We introduce all the monomials but one |
28 |
# in, those in t necessary to be able to introduce
|
|
28 |
# in i and those in t necessary to be able to introduce
|
|
29 | 29 |
# p. We arbitrary choose to introduce the highest degree monomial in i |
30 | 30 |
# with p. We also introduce all the mixed i^k * t^l monomials with |
31 | 31 |
# k < p.degree(i) and l <= p.degree(t). |
32 |
# Mixed terms introduction is necessary before we start "i shifts" in
|
|
33 |
# the next iteration. |
|
32 |
# Mixed terms introduction is necessary here before we start "i shifts"
|
|
33 |
# in the next iteration.
|
|
34 | 34 |
if pPower == 0: |
35 |
# iter1: power of i
|
|
36 |
# Notice how i^pIdegree is excluded.
|
|
35 |
# Notice that i^pIdegree is excluded as the bound of the xrange is
|
|
36 |
# pIdegree
|
|
37 | 37 |
for iPower in xrange(0, pIdegree): |
38 |
# iter5: power of t. |
|
39 | 38 |
for tPower in xrange(0, pTdegree + 1): |
40 | 39 |
if columnsWidth != 0: |
41 | 40 |
print "->", spo_expression_as_string(iPower, |
... | ... | |
44 | 43 |
alpha) |
45 | 44 |
currentExpression = iVariable^iPower * \ |
46 | 45 |
tVariable^tPower * nAtPower |
47 |
# polynomialAtPower == 1 here. Next line should be commented out but it does not work!
|
|
48 |
# Some convertion problem?
|
|
46 |
# polynomialAtPower == 1 here. Next line should be commented |
|
47 |
# out but it does not work! Some conversion problem?
|
|
49 | 48 |
currentPolynomial = pRing(currentExpression) * \ |
50 | 49 |
polynomialAtPower |
51 | 50 |
pMonomials = currentPolynomial.monomials() |
... | ... | |
55 | 54 |
knownMonomials, |
56 | 55 |
protoMatrixRows, |
57 | 56 |
columnsWidth) |
58 |
# End iter5. |
|
59 |
# End for iter1. |
|
60 |
|
|
57 |
# End tPower. |
|
58 |
# End for iPower. |
|
61 | 59 |
else: # pPower > 0: (p^1..p^alpha) |
62 |
# This where we introduce the p^iPower * N^(alpha-iPower)
|
|
60 |
# This where we introduce the p^pPower * N^(alpha-pPower)
|
|
63 | 61 |
# polynomial. |
64 | 62 |
# This step could technically be fused as the first iteration |
65 | 63 |
# of the next loop (with iPower starting at 0). |
... | ... | |
97 | 95 |
# We want now to introduce a t * p^pPower polynomial. But before |
98 | 96 |
# that we must introduce some mixed monomials. |
99 | 97 |
# This loop is no triggered before pPower == 2. |
100 |
# It introduces a first set of mixed monomials. |
|
98 |
# It introduces a first set of high i degree mixed monomials.
|
|
101 | 99 |
for iPower in xrange(1, pPower): |
102 | 100 |
tPower = pPower - iPower + 1 |
103 | 101 |
if columnsWidth != 0: |
... | ... | |
115 | 113 |
protoMatrixRows, |
116 | 114 |
columnsWidth) |
117 | 115 |
# End for iPower |
118 |
# This is the main loop. It introduces: |
|
116 |
# |
|
117 |
# This is the mixed monomials main loop. It introduces: |
|
119 | 118 |
# - the missing mixed monomials needed before the |
120 |
# t * p^pPower * N^(alpha-pPower) polynomial; |
|
121 |
# - the t * p^pPower * N^(alpha-pPower) itself; |
|
122 |
# - the missing mixed monomials needed before each of the |
|
123 |
# i^k * t^l * p^pPower * N^(alpha-pPower) polynomials; |
|
124 |
# - the i^k * t^l * p^pPower * N^(alpha-pPower) themselves. |
|
119 |
# t^l * p^pPower * N^(alpha-pPower) polynomial; |
|
120 |
# - the t^l * p^pPower * N^(alpha-pPower) itself; |
|
121 |
# - for each of i^k * t^l * p^pPower * N^(alpha-pPower) polynomials: |
|
122 |
# - the the missing mixed monomials needed polynomials, |
|
123 |
# - the i^k * t^l * p^pPower * N^(alpha-pPower) itself. |
|
124 |
# The t^l * p^pPower * N^(alpha-pPower) is introduced when |
|
125 |
# |
|
125 | 126 |
for iShift in xrange(0, pIdegree): |
126 | 127 |
# When pTdegree == 1, the following loop only introduces |
127 | 128 |
# a single new monomial. |
... | ... | |
144 | 145 |
protoMatrixRows, |
145 | 146 |
columnsWidth) |
146 | 147 |
#print "+++++" |
147 |
|
|
148 |
# At iShift == 0, the following loop adds duplicate |
|
149 |
# monomials, since no extra i^l * t^k is needed before |
|
150 |
# introducing the |
|
148 |
# At iShift == 0, the following innerTpower loop adds |
|
149 |
# duplicate monomials, since no extra i^l * t^k is needed |
|
150 |
# before introducing the |
|
151 | 151 |
# i^iShift * t^outerPpower * p^pPower * N^(alpha-pPower) |
152 | 152 |
# polynomial. |
153 | 153 |
# It introduces smaller i degree monomials than the |
154 | 154 |
# one(s) added previously (no pPower multiplication). |
155 | 155 |
# Here the exponent of t decreases as that of i increases. |
156 |
# This conditional is not entered before pPower == 1. |
|
157 |
# The innerTpower loop does not produce anything before |
|
158 |
# pPower == 2. We keep it anyway for other configuration of |
|
159 |
# p. |
|
156 | 160 |
if iShift > 0: |
157 | 161 |
iPower = pIdegree + iShift |
158 | 162 |
for innerTpower in xrange(pPower, 1, -1): |
... | ... | |
174 | 178 |
iPower += pIdegree |
175 | 179 |
# End for innerTpower |
176 | 180 |
# End of if iShift > 0 |
181 |
# When iShift == 0, just after each of the |
|
182 |
# p^pPower * N^(alpha-pPower) polynomials has |
|
183 |
# been introduced (followed by a string of |
|
184 |
# i^k * p^pPower * N^(alpha-pPower) polynomials) a |
|
185 |
# t^l * p^pPower * N^(alpha-pPower) is introduced here. |
|
186 |
# |
|
177 | 187 |
# Eventually, the following section introduces the |
178 | 188 |
# i^iShift * t^outerTpower * p^iPower * N^(alpha-iPower) |
179 | 189 |
# polynomials. |
... | ... | |
193 | 203 |
columnsWidth) |
194 | 204 |
# End for outerTpower |
195 | 205 |
#print "++++++++++" |
196 |
|
|
197 |
|
|
198 | 206 |
# End for iShift |
199 | 207 |
polynomialAtPower *= p |
200 | 208 |
nAtPower /= N |
... | ... | |
221 | 229 |
protoMatrixRows: a list of lists, each one holding the coefficients of the |
222 | 230 |
monomials |
223 | 231 |
columnWith : the width, in characters, of the displayed column ; if 0, |
224 |
do display anything. |
|
232 |
do not display anything.
|
|
225 | 233 |
""" |
226 | 234 |
# We have started with the smaller degrees in the first variable. |
227 | 235 |
pMonomials.reverse() |
Formats disponibles : Unified diff