Index: sagePolynomialOperations.sage
===================================================================
--- sagePolynomialOperations.sage	(revision 86)
+++ sagePolynomialOperations.sage	(revision 87)
@@ -1,5 +1,5 @@
 load "/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage"
-
+print "sagePolynomialOperations loading..."
 def spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
                                             pCoefficients, 
                                             knownMonomials, 
@@ -107,7 +107,7 @@
     return(expressionAsString)
 # End spo_expression_as_string.
 
-def spo_norm(poly, degree):
+def spo_norm(poly, p=2):
     """
     Behaves more or less (no infinity defined) as the norm for the
     univariate polynomials.
@@ -115,25 +115,40 @@
     Definition: For integer p, the p-norm of a polynomial is the pth root of 
     the sum of the pth powers of the absolute values of the coefficients of 
     the polynomial.
+    
     """
-    # TODO: check the arguments.
+    # TODO: check the arguments (for p see below)..
     norm = 0
+    # For infinity norm.
+    if p == Infinity:
+        for coefficient in poly.coefficients():
+            coefficientAbs = coefficient.abs()
+            if coefficientAbs > norm:
+                norm = coefficientAbs
+        return norm
+    # TODO: check here the value of p
+    # For 1 norm.
+    if p == 1:
+        for coefficient in poly.coefficients():
+            norm +=  coefficient.abs()
+        return norm
+    # For other norms
     for coefficient in poly.coefficients():
-        norm +=  (coefficient^degree).abs()
-    return pow(norm, 1/degree)
+        norm +=  (coefficient^p).abs()
+    return pow(norm, 1/p)
 # end spo_norm
 
 def spo_polynomial_to_proto_matrix(p, pRing, alpha, N, columnsWidth=0):
     """
     From a (bivariate) polynomial and some other parameters build a proto 
-    matrix (an array of rows) to be converted into a "true" matrix and 
+    matrix (an array of "rows") to be converted into a "true" matrix and 
     eventually by reduced by fpLLL.
     The matrix is such as those found in Boneh-Durphee and Stehlé.
     
     Parameters
     ----------
-    p: the (bivariate) polynomial
-    pRing:
+    p: the (bivariate) polynomial;
+    pRing: the ring over which p is defined;
     alpha:
     N:
     columsWidth: if == 0, no information is displayed, otherwise data is 
@@ -144,11 +159,11 @@
     pVariables = p.variables()
     iVariable = pVariables[0]
     tVariable = pVariables[1]
-    polynomialAtPower = P(1)
-    currentPolynomial = P(1)
+    polynomialAtPower = pRing(1)
+    currentPolynomial = pRing(1)
     pIdegree = p.degree(pVariables[0])
     pTdegree = p.degree(pVariables[1])
-    currentIdegree = currentPolynomial.degree(i)
+    currentIdegree = currentPolynomial.degree(iVariable)
     nAtPower = N^alpha
     # We work from p^0 * N^alpha to p^alpha * N^0
     for pPower in xrange(0, alpha + 1):
@@ -209,15 +224,19 @@
             # possible, one step short of the degree in i of p^(pPower+1) .
             # These "pure" i^k monomials can only show up with i multiplications.
             for iPower in xrange(1, pIdegree):
-                print "->", spo_expression_as_string(iPower, 0, pPower, alpha)
+                if columnsWidth != 0:
+                    print "->", spo_expression_as_string(iPower, \
+                                                         0,      \
+                                                         pPower, \
+                                                         alpha)
                 currentExpression = i^iPower * nAtPower
-                currentPolynomial = P(currentExpression) * polynomialAtPower
+                currentPolynomial = pRing(currentExpression) * polynomialAtPower
                 pMonomials = currentPolynomial.monomials()
                 pCoefficients = currentPolynomial.coefficients()
-                spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
-                                                        pCoefficients, 
-                                                        knownMonomials, 
-                                                        protoMatrixRows, 
+                spo_add_polynomial_coeffs_to_matrix_row(pMonomials,      \
+                                                        pCoefficients,   \
+                                                        knownMonomials,  \
+                                                        protoMatrixRows, \
                                                         columnsWidth)
             # End for iPower
             # We want now to introduce a t * p^pPower polynomial. But before
@@ -232,7 +251,7 @@
                                                          0,  
                                                          alpha)
                 currentExpression = i^(iPower * pIdegree) * t^tPower * nAtPower
-                currentPolynomial = P(currentExpression)
+                currentPolynomial = pRing(currentExpression)
                 pMonomials = currentPolynomial.monomials()
                 pCoefficients = currentPolynomial.coefficients()
                 spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
@@ -264,7 +283,7 @@
                                                              0,
                                                              alpha)
                     currentExpression = i^iPower * t^outerTpower * nAtPower
-                    currentPolynomial = P(currentExpression)
+                    currentPolynomial = pRing(currentExpression)
                     pMonomials = currentPolynomial.monomials()
                     pCoefficients = currentPolynomial.coefficients()
                     spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
@@ -295,7 +314,7 @@
                                                                      alpha) 
                             currentExpression = \
                                     i^(iPower) * t^(innerTpower) * nAtPower
-                            currentPolynomial = P(currentExpression)
+                            currentPolynomial = pRing(currentExpression)
                             pMonomials = currentPolynomial.monomials()
                             pCoefficients = currentPolynomial.coefficients()
                             spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
@@ -321,7 +340,7 @@
                                                              pPower,
                                                              alpha)
                     currentExpression = i^iShift * t^outerTpower * nAtPower
-                    currentPolynomial = P(currentExpression) * polynomialAtPower
+                    currentPolynomial = pRing(currentExpression) * polynomialAtPower
                     pMonomials = currentPolynomial.monomials()
                     pCoefficients = currentPolynomial.coefficients()
                     spo_add_polynomial_coeffs_to_matrix_row(pMonomials, 
@@ -335,36 +354,36 @@
         polynomialAtPower *= p  
         nAtPower /= N
     # End for pPower loop
-    return protoMatrixRows
+    return ((protoMatrixRows, knownMonomials))
 # End spo_polynomial_to_proto_matrix
 
-def spo_proto_to_column_matrix(protoMatrixRows):
+def spo_proto_to_column_matrix(protoMatrixColumns):
     """
-    Create a row (each column holds the coefficients of one polynomial) matrix.
+    Create a column (each row holds the coefficients of one monomial) matrix.
     protoMatrixRows.
     
     Parameters
     ----------
-    protoMatrixRows: a list of coefficient lists.
+    protoMatrixColumns: a list of coefficient lists.
     """
-    numRows = len(protoMatrixRows)
-    if numRows == 0:
+    numColumns = len(protoMatrixColumns)
+    if numColumns == 0:
         return None
-    numColumns = len(protoMatrixRows[numRows-1])
+    # The last column holds has the maximum length. 
+    numRows = len(protoMatrixColumns[numColumns-1])
     if numColumns == 0:
         return None
     baseMatrix = matrix(ZZ, numRows, numColumns)
-    for rowIndex in xrange(0, numRows):
-        if monomialLengthChars != 0:
-            print protoMatrixRows[rowIndex]
-        for colIndex in xrange(0, len(protoMatrixRows[rowIndex])):
-            baseMatrix[colIndex, rowIndex] = protoMatrixRows[rowIndex][colIndex]
+    for colIndex in xrange(0, numColumns):
+        for rowIndex in xrange(0, len(protoMatrixColumns[colIndex])):
+            baseMatrix[rowIndex, colIndex] = \
+            protoMatrixColumns[colIndex][rowIndex]
     return baseMatrix
 # End spo_proto_to_column_matrix.
 #
 def spo_proto_to_row_matrix(protoMatrixRows):
     """
-    Create a row (each row holds the coefficients of one polynomial) matrix.
+    Create a row (each column holds the coefficients of one monomial) matrix.
     protoMatrixRows.
     
     Parameters
@@ -379,11 +398,9 @@
         return None
     baseMatrix = matrix(ZZ, numRows, numColumns)
     for rowIndex in xrange(0, numRows):
-        if monomialLengthChars != 0:
-            print protoMatrixRows[rowIndex]
         for colIndex in xrange(0, len(protoMatrixRows[rowIndex])):
             baseMatrix[rowIndex, colIndex] = protoMatrixRows[rowIndex][colIndex]
     return baseMatrix
 # End spo_proto_to_row_matrix.
 #
-print "sagePolynomialOperations loaded..."
\ No newline at end of file
+print "\t...sagePolynomialOperations loaded"
\ No newline at end of file
