Révision 108
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 108) | ||
---|---|---|
497 | 497 |
return((knownMonomials, polynomialsList)) |
498 | 498 |
# End spo_polynomial_to_proto_matrix_2 |
499 | 499 |
|
500 |
def spo_polynomial_to_polynomials_list_3(p, alpha, N, columnsWidth=0): |
|
501 |
""" |
|
502 |
From p, alpha, N build a list of polynomials... |
|
503 |
TODO: more in depth rationale... |
|
504 |
|
|
505 |
Our goal is to introduce each monomial with the smallest coefficient. |
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
Parameters |
|
510 |
---------- |
|
511 |
p: the (bivariate) polynomial; |
|
512 |
pRing: the ring over which p is defined; |
|
513 |
alpha: |
|
514 |
N: |
|
515 |
columsWidth: if == 0, no information is displayed, otherwise data is |
|
516 |
printed in colums of columnsWitdth width. |
|
517 |
""" |
|
518 |
pRing = p.parent() |
|
519 |
knownMonomials = [] |
|
520 |
polynomialsList = [] |
|
521 |
pVariables = p.variables() |
|
522 |
iVariable = pVariables[0] |
|
523 |
tVariable = pVariables[1] |
|
524 |
polynomialAtPower = pRing(1) |
|
525 |
currentPolynomial = pRing(1) |
|
526 |
pIdegree = p.degree(iVariable) |
|
527 |
pTdegree = p.degree(tVariable) |
|
528 |
currentIdegree = currentPolynomial.degree(iVariable) |
|
529 |
nAtAlpha = N^alpha |
|
530 |
nAtPower = nAtAlpha |
|
531 |
polExpStr = "" |
|
532 |
# We work from p^0 * N^alpha to p^alpha * N^0 |
|
533 |
for pPower in xrange(0, alpha + 1): |
|
534 |
# pPower == 0 is a special case. We introduce all the monomials in i |
|
535 |
# up to i^pIdegree. |
|
536 |
if pPower == 0: |
|
537 |
# Notice who iPower runs up to i^pIdegree. |
|
538 |
for iPower in xrange(0, pIdegree + 1): |
|
539 |
# No t power is taken into account as we limit our selves to |
|
540 |
# degree 1 in t and make no "t-shifts". |
|
541 |
if columnsWidth != 0: |
|
542 |
polExpStr = spo_expression_as_string(iPower, |
|
543 |
0, |
|
544 |
0, |
|
545 |
alpha) |
|
546 |
print "->", polExpStr |
|
547 |
currentExpression = iVariable^iPower * nAtAlpha |
|
548 |
# polynomialAtPower == 1 here. Next line should be commented |
|
549 |
# out but it does not work! Some conversion problem? |
|
550 |
currentPolynomial = pRing(currentExpression) |
|
551 |
polynomialsList.append(currentPolynomial) |
|
552 |
# End for iPower. |
|
553 |
else: # pPower > 0: (p^1..p^alpha) |
|
554 |
# This where we introduce the p^pPower * N^(alpha-pPower) |
|
555 |
# polynomial. This is also where the t^pPower monomials shows up for |
|
556 |
# the first time. It app |
|
557 |
if columnsWidth != 0: |
|
558 |
polExpStr = spo_expression_as_string(0, 0, pPower, alpha-pPower) |
|
559 |
print "->", polExpStr |
|
560 |
currentPolynomial = polynomialAtPower * nAtPower |
|
561 |
polynomialsList.append(currentPolynomial) |
|
562 |
# Exit when pPower == alpha |
|
563 |
if pPower == alpha: |
|
564 |
return((knownMonomials, polynomialsList)) |
|
565 |
# This is where the "i-shifts" take place. Mixed terms, i^k * t^l |
|
566 |
# (that were introduced at a previous |
|
567 |
# stage or are introduced now) are only shifted to already existing |
|
568 |
# ones with the notable exception of i^iPower * t^pPower, which |
|
569 |
# must be manually introduced. |
|
570 |
# p^pPower is "shifted" to higher degrees in i as far as |
|
571 |
# possible, up to of the degree in i of p^(pPower+1). |
|
572 |
# These "pure" i^k monomials can only show up with i multiplications. |
|
573 |
for iPower in xrange(1, pIdegree + 1): |
|
574 |
# The i^iPower * t^pPower monomial. Notice the alpha exponent |
|
575 |
# for N. |
|
576 |
internalIpower = iPower |
|
577 |
for tPower in xrange(pPower,0,-1): |
|
578 |
if columnsWidth != 0: |
|
579 |
polExpStr = spo_expression_as_string(internalIpower, \ |
|
580 |
tPower, \ |
|
581 |
0, \ |
|
582 |
alpha) |
|
583 |
print "->", polExpStr |
|
584 |
currentExpression = i^internalIpower * t^tPower * nAtAlpha |
|
585 |
currentPolynomial = pRing(currentExpression) |
|
586 |
polynomialsList.append(currentPolynomial) |
|
587 |
internalIpower += pIdegree |
|
588 |
# End for tPower |
|
589 |
# The i^iPower * p^pPower * N^(alpha-pPower) i-shift. |
|
590 |
if columnsWidth != 0: |
|
591 |
polExpStr = spo_expression_as_string(iPower, \ |
|
592 |
0, \ |
|
593 |
pPower, \ |
|
594 |
alpha-pPower) |
|
595 |
print "->", polExpStr |
|
596 |
currentExpression = i^iPower * nAtPower |
|
597 |
currentPolynomial = pRing(currentExpression) * polynomialAtPower |
|
598 |
polynomialsList.append(currentPolynomial) |
|
599 |
# End for iPower |
|
600 |
polynomialAtPower *= p |
|
601 |
nAtPower /= N |
|
602 |
# End for pPower loop |
|
603 |
return((knownMonomials, polynomialsList)) |
|
604 |
# End spo_polynomial_to_proto_matrix_3 |
|
605 |
|
|
500 | 606 |
def spo_proto_to_column_matrix(protoMatrixColumns, \ |
501 | 607 |
knownMonomialsList, \ |
502 | 608 |
boundVar1, \ |
Formats disponibles : Unified diff