Révision 76
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 76) | ||
---|---|---|
13 | 13 |
""" |
14 | 14 |
pVariables = p.variables() |
15 | 15 |
iVariable = pVariables[0] |
16 |
tVaraible = pVariables[1]
|
|
16 |
tVariable = pVariables[1]
|
|
17 | 17 |
polynomialAtPower = P(1) |
18 | 18 |
currentPolynomial = P(1) |
19 | 19 |
pIdegree = p.degree(pVariables[0]) |
... | ... | |
22 | 22 |
nAtPower = N^alpha |
23 | 23 |
# We work from p^0 * N^alpha to p^alpha * N^0 |
24 | 24 |
for pPower in xrange(0, alpha + 1): |
25 |
# pPower == 0 is a special case. We introduce all the monomials in |
|
26 |
# i, those in t and the mixed one necessary to be able to introduce |
|
27 |
# p and only a one monomial (our (arbitrary) choice is, at this point, |
|
28 |
# to add i to it's maximum power in p. |
|
25 |
# pPower == 0 is a special case. We introduce all the monomials but one |
|
26 |
# in, those in t necessary to be able to introduce |
|
27 |
# p. We arbitrary choose to introduce the highest degree monomial in i |
|
28 |
# with p. We also introduce all the mixed i^k * t^l monomials with |
|
29 |
# k < p.degree(i) and l <= p.degree(t) |
|
29 | 30 |
if pPower == 0: |
30 | 31 |
# iter1: power of i |
31 | 32 |
# Notice how i^pIdegree is excluded. |
... | ... | |
33 | 34 |
# iter5: power of t. |
34 | 35 |
for tPower in xrange(0, pTdegree + 1): |
35 | 36 |
if columnWidth != 0: |
36 |
print "->", spo_expression_as_string(iter1,
|
|
37 |
iter5,
|
|
38 |
iter0,
|
|
37 |
print "->", spo_expression_as_string(iPower,
|
|
38 |
tPower,
|
|
39 |
pPower,
|
|
39 | 40 |
alpha) |
40 | 41 |
currentExpression = iVariable^iPower * \ |
41 | 42 |
tVariable^tPower * nAtPower |
... | ... | |
45 | 46 |
polynomialAtPower |
46 | 47 |
pMonomials = currentPolynomial.monomials() |
47 | 48 |
pCoefficients = currentPolynomial.coefficients() |
48 |
add_polynomial_coeffs_to_matrix(pMonomials, pCoefficients, knownMonomials, protoMatrixRows, monomialLengthChars) |
|
49 |
spo_add_polynomial_coeffs_to_matrix(pMonomials, pCoefficients, knownMonomials, protoMatrixRows, monomialLengthChars)
|
|
49 | 50 |
# End iter5. |
50 | 51 |
# End for iter1. |
51 | 52 |
|
... | ... | |
139 | 140 |
# End spo_add_polynomial_coeffs_to_matrix |
140 | 141 |
|
141 | 142 |
def spo_expression_as_string(powI, powT, powP, alpha): |
143 |
""" |
|
144 |
Computes a string version of the i^k + t^l + p^m + N^n expression for |
|
145 |
output. |
|
146 |
""" |
|
142 | 147 |
expressionAsString ="" |
143 | 148 |
if powI != 0: |
144 | 149 |
expressionAsString += "i^" + str(powI) |
Formats disponibles : Unified diff