Révision 113
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 113) | ||
---|---|---|
741 | 741 |
return polynomialsList |
742 | 742 |
# End spo_polynomial_to_proto_matrix_4 |
743 | 743 |
|
744 |
def spo_polynomial_to_polynomials_list_5(p, alpha, N, iBound, tBound, |
|
745 |
columnsWidth=0): |
|
746 |
""" |
|
747 |
From p, alpha, N build a list of polynomials use to create a base |
|
748 |
that will eventually be reduced with LLL. |
|
749 |
|
|
750 |
The bounds are computed for the coefficients that will be used to |
|
751 |
form the base. |
|
752 |
|
|
753 |
We try to introduce only one new monomial at a time, to obtain a |
|
754 |
triangular matrix (it is easy to compute the volume of the underlining |
|
755 |
latice if the matrix is triangular). |
|
756 |
|
|
757 |
There are many possibilities to introduce the monomials: our goal is also |
|
758 |
to introduce each of them on the diagonal with the smallest coefficient. |
|
759 |
|
|
760 |
The method depends on the structure of the polynomial. Here it is adapted |
|
761 |
to the a_n*i^n + ... + a_1 * i - t + b form. |
|
762 |
|
|
763 |
Parameters |
|
764 |
---------- |
|
765 |
p: the (bivariate) polynomial; |
|
766 |
alpha: |
|
767 |
N: |
|
768 |
iBound: |
|
769 |
tBound: |
|
770 |
columsWidth: if == 0, no information is displayed, otherwise data is |
|
771 |
printed in colums of columnsWitdth width. |
|
772 |
""" |
|
773 |
pRing = p.parent() |
|
774 |
polynomialsList = [] |
|
775 |
pVariables = p.variables() |
|
776 |
iVariable = pVariables[0] |
|
777 |
tVariable = pVariables[1] |
|
778 |
polynomialAtPower = copy(p) |
|
779 |
currentPolynomial = pRing(1) |
|
780 |
pIdegree = p.degree(iVariable) |
|
781 |
pTdegree = p.degree(tVariable) |
|
782 |
maxIdegree = pIdegree * alpha |
|
783 |
currentIdegree = currentPolynomial.degree(iVariable) |
|
784 |
nAtAlpha = N^alpha |
|
785 |
nAtPower = nAtAlpha |
|
786 |
polExpStr = "" |
|
787 |
# We first introduce all the monomials in i alone multiplied by N^alpha. |
|
788 |
for iPower in xrange(0, maxIdegree + 1): |
|
789 |
if columnsWidth !=0: |
|
790 |
polExpStr = spo_expression_as_string(iPower, iBound, |
|
791 |
0, tBound, |
|
792 |
0, alpha) |
|
793 |
print "->", polExpStr |
|
794 |
currentExpression = iVariable^iPower * nAtAlpha * iBound^iPower |
|
795 |
currentPolynomial = pRing(currentExpression) |
|
796 |
polynomialsList.append(currentPolynomial) |
|
797 |
# End for iPower |
|
798 |
# We work from p^1 * N^alpha-1 to p^alpha * N^0 |
|
799 |
for pPower in xrange(1, alpha + 1): |
|
800 |
# First of all the p^pPower * N^(alpha-pPower) polynomial. |
|
801 |
nAtPower /= N |
|
802 |
if columnsWidth !=0: |
|
803 |
polExpStr = spo_expression_as_string(0, iBound, |
|
804 |
0, tBound, |
|
805 |
pPower, alpha-pPower) |
|
806 |
print "->", polExpStr |
|
807 |
currentPolynomial = polynomialAtPower * nAtPower |
|
808 |
polynomialsList.append(currentPolynomial) |
|
809 |
# Exit when pPower == alpha |
|
810 |
if pPower == alpha: |
|
811 |
return polynomialsList |
|
812 |
for iPower in xrange(1, pIdegree + 1): |
|
813 |
iCurrentPower = pIdegree + iPower |
|
814 |
for tPower in xrange(pPower-1, 0, -1): |
|
815 |
print "tPower:", tPower |
|
816 |
if columnsWidth != 0: |
|
817 |
polExpStr = spo_expression_as_string(iCurrentPower, iBound, |
|
818 |
tPower, tBound, |
|
819 |
0, alpha) |
|
820 |
print "->", polExpStr |
|
821 |
currentExpression = i^iCurrentPower * iBound^iCurrentPower * t^tPower * tBound^tPower *nAtAlpha |
|
822 |
currentPolynomial = pRing(currentExpression) |
|
823 |
polynomialsList.append(currentPolynomial) |
|
824 |
iCurrentPower += pIdegree |
|
825 |
# End for tPower |
|
826 |
# We now introduce the mixed i^k * t^l monomials by i^m * p^n * N^(alpha-n) |
|
827 |
if columnsWidth != 0: |
|
828 |
polExpStr = spo_expression_as_string(iPower, iBound, |
|
829 |
0, tBound, |
|
830 |
pPower, alpha-pPower) |
|
831 |
print "->", polExpStr |
|
832 |
currentExpression = i^iPower * iBound^iPower * nAtPower |
|
833 |
currentPolynomial = pRing(currentExpression) * polynomialAtPower |
|
834 |
polynomialsList.append(currentPolynomial) |
|
835 |
# End for iPower |
|
836 |
polynomialAtPower *= p |
|
837 |
# End for pPower loop |
|
838 |
return polynomialsList |
|
839 |
# End spo_polynomial_to_proto_matrix_5 |
|
840 |
|
|
744 | 841 |
def spo_proto_to_column_matrix(protoMatrixColumns): |
745 | 842 |
""" |
746 | 843 |
Create a column (each row holds the coefficients for one monomial) matrix. |
Formats disponibles : Unified diff