Révision 92
| pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 92) | ||
|---|---|---|
| 156 | 156 |
""" |
| 157 | 157 |
knownMonomials = [] |
| 158 | 158 |
protoMatrixRows = [] |
| 159 |
polynomialsList = [] |
|
| 159 | 160 |
pVariables = p.variables() |
| 160 | 161 |
iVariable = pVariables[0] |
| 161 | 162 |
tVariable = pVariables[1] |
| ... | ... | |
| 166 | 167 |
currentIdegree = currentPolynomial.degree(iVariable) |
| 167 | 168 |
nAtPower = N^alpha |
| 168 | 169 |
nAtAlpha = nAtPower |
| 170 |
polExpStr = "" |
|
| 169 | 171 |
# We work from p^0 * N^alpha to p^alpha * N^0 |
| 170 | 172 |
for pPower in xrange(0, alpha + 1): |
| 171 | 173 |
# pPower == 0 is a special case. We introduce all the monomials but one |
| ... | ... | |
| 181 | 183 |
for iPower in xrange(0, pIdegree): |
| 182 | 184 |
for tPower in xrange(0, pTdegree + 1): |
| 183 | 185 |
if columnsWidth != 0: |
| 184 |
print "->", spo_expression_as_string(iPower,
|
|
| 186 |
polExpStr = spo_expression_as_string(iPower,
|
|
| 185 | 187 |
tPower, |
| 186 | 188 |
pPower, |
| 187 | 189 |
alpha) |
| 190 |
print "->", polExpStr |
|
| 188 | 191 |
currentExpression = iVariable^iPower * \ |
| 189 | 192 |
tVariable^tPower * nAtAlpha |
| 190 | 193 |
# polynomialAtPower == 1 here. Next line should be commented |
| 191 | 194 |
# out but it does not work! Some conversion problem? |
| 192 | 195 |
currentPolynomial = pRing(currentExpression) |
| 196 |
polynomialsList.append(polExpStr) |
|
| 193 | 197 |
pMonomials = currentPolynomial.monomials() |
| 194 | 198 |
pCoefficients = currentPolynomial.coefficients() |
| 195 | 199 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 206 | 210 |
# of the next loop (with iPower starting at 0). |
| 207 | 211 |
# We set it apart for clarity. |
| 208 | 212 |
if columnsWidth != 0: |
| 209 |
print "->", spo_expression_as_string(0, 0, pPower, alpha) |
|
| 213 |
polExpStr = spo_expression_as_string(0, 0, pPower, alpha) |
|
| 214 |
print "->", polExpStr |
|
| 210 | 215 |
currentPolynomial = polynomialAtPower * nAtPower |
| 216 |
polynomialsList.append(polExpStr) |
|
| 211 | 217 |
pMonomials = currentPolynomial.monomials() |
| 212 | 218 |
pCoefficients = currentPolynomial.coefficients() |
| 213 | 219 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 225 | 231 |
# These "pure" i^k monomials can only show up with i multiplications. |
| 226 | 232 |
for iPower in xrange(1, pIdegree): |
| 227 | 233 |
if columnsWidth != 0: |
| 228 |
print "->", spo_expression_as_string(iPower, \
|
|
| 234 |
polExpStr = spo_expression_as_string(iPower, \
|
|
| 229 | 235 |
0, \ |
| 230 | 236 |
pPower, \ |
| 231 | 237 |
alpha) |
| 238 |
print "->", polExpStr |
|
| 232 | 239 |
currentExpression = i^iPower * nAtPower |
| 233 | 240 |
currentPolynomial = pRing(currentExpression) * polynomialAtPower |
| 241 |
polynomialsList.append(polExpStr) |
|
| 234 | 242 |
pMonomials = currentPolynomial.monomials() |
| 235 | 243 |
pCoefficients = currentPolynomial.coefficients() |
| 236 | 244 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, \ |
| ... | ... | |
| 246 | 254 |
for iPower in xrange(1, pPower): |
| 247 | 255 |
tPower = pPower - iPower + 1 |
| 248 | 256 |
if columnsWidth != 0: |
| 249 |
print "->", spo_expression_as_string(iPower * pIdegree,
|
|
| 257 |
polExpStr = spo_expression_as_string(iPower * pIdegree,
|
|
| 250 | 258 |
tPower, |
| 251 | 259 |
0, |
| 252 | 260 |
alpha) |
| 261 |
print "->", polExpStr |
|
| 253 | 262 |
currentExpression = i^(iPower * pIdegree) * t^tPower * nAtAlpha |
| 254 | 263 |
currentPolynomial = pRing(currentExpression) |
| 264 |
polynomialsList.append(polExpStr) |
|
| 255 | 265 |
pMonomials = currentPolynomial.monomials() |
| 256 | 266 |
pCoefficients = currentPolynomial.coefficients() |
| 257 | 267 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 278 | 288 |
# First one high i degree mixed monomial. |
| 279 | 289 |
iPower = iShift + pPower * pIdegree |
| 280 | 290 |
if columnsWidth != 0: |
| 281 |
print "->", spo_expression_as_string(iPower,
|
|
| 291 |
polExpStr = spo_expression_as_string(iPower,
|
|
| 282 | 292 |
outerTpower, |
| 283 | 293 |
0, |
| 284 | 294 |
alpha) |
| 295 |
print "->", polExpStr |
|
| 285 | 296 |
currentExpression = i^iPower * t^outerTpower * nAtAlpha |
| 286 | 297 |
currentPolynomial = pRing(currentExpression) |
| 298 |
polynomialsList.append(polExpStr) |
|
| 287 | 299 |
pMonomials = currentPolynomial.monomials() |
| 288 | 300 |
pCoefficients = currentPolynomial.coefficients() |
| 289 | 301 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 308 | 320 |
iPower = pIdegree + iShift |
| 309 | 321 |
for innerTpower in xrange(pPower, 1, -1): |
| 310 | 322 |
if columnsWidth != 0: |
| 311 |
print "->", spo_expression_as_string(iPower,
|
|
| 323 |
polExpStr = spo_expression_as_string(iPower,
|
|
| 312 | 324 |
innerTpower, |
| 313 | 325 |
0, |
| 314 | 326 |
alpha) |
| 315 | 327 |
currentExpression = \ |
| 316 | 328 |
i^(iPower) * t^(innerTpower) * nAtAlpha |
| 317 | 329 |
currentPolynomial = pRing(currentExpression) |
| 330 |
polynomialsList.append(polExpStr) |
|
| 318 | 331 |
pMonomials = currentPolynomial.monomials() |
| 319 | 332 |
pCoefficients = currentPolynomial.coefficients() |
| 320 | 333 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 335 | 348 |
# i^iShift * t^outerTpower * p^iPower * N^(alpha-iPower) |
| 336 | 349 |
# polynomials. |
| 337 | 350 |
if columnsWidth != 0: |
| 338 |
print "->", spo_expression_as_string(iShift,
|
|
| 351 |
polExpStr = spo_expression_as_string(iShift,
|
|
| 339 | 352 |
outerTpower, |
| 340 | 353 |
pPower, |
| 341 | 354 |
alpha) |
| 355 |
print "->", polExpStr |
|
| 342 | 356 |
currentExpression = i^iShift * t^outerTpower * nAtPower |
| 343 | 357 |
currentPolynomial = pRing(currentExpression) * polynomialAtPower |
| 358 |
polynomialsList.append(polExpStr) |
|
| 344 | 359 |
pMonomials = currentPolynomial.monomials() |
| 345 | 360 |
pCoefficients = currentPolynomial.coefficients() |
| 346 | 361 |
spo_add_polynomial_coeffs_to_matrix_row(pMonomials, |
| ... | ... | |
| 354 | 369 |
polynomialAtPower *= p |
| 355 | 370 |
nAtPower /= N |
| 356 | 371 |
# End for pPower loop |
| 357 |
return ((protoMatrixRows, knownMonomials)) |
|
| 372 |
return ((protoMatrixRows, knownMonomials, polynomialsList))
|
|
| 358 | 373 |
# End spo_polynomial_to_proto_matrix |
| 359 | 374 |
|
| 360 | 375 |
def spo_proto_to_column_matrix(protoMatrixColumns, \ |
Formats disponibles : Unified diff