Index: pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 110)
+++ pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 111)
@@ -103,18 +103,18 @@
 # End spo_get_coefficient_for_monomial.
     
 
-def spo_expression_as_string(powI, powT, powP, powN):
+def spo_expression_as_string(powI, boundI, powT, boundT, powP, powN):
     """
     Computes a string version of the i^k + t^l + p^m + N^n expression for
     output.
     """
     expressionAsString =""
     if powI != 0:
-        expressionAsString += "i^" + str(powI)
+        expressionAsString += str(iBound^powI) + " i^" + str(powI)
     if powT != 0:
         if len(expressionAsString) != 0:
             expressionAsString += " * "
-        expressionAsString += "t^" + str(powT)
+        expressionAsString += str(tBound^powT) + " t^" + str(powT)
     if powP != 0:
         if len(expressionAsString) != 0:
             expressionAsString += " * "
@@ -396,7 +396,8 @@
     return ((protoMatrixRows, knownMonomials, polynomialsList))
 # End spo_polynomial_to_proto_matrix
 
-def spo_polynomial_to_polynomials_list_2(p, alpha, N, columnsWidth=0):
+def spo_polynomial_to_polynomials_list_2(p, alpha, N, iBound, tBound,
+                                         columnsWidth=0):
     """
     From p, alpha, N build a list of polynomials...
     TODO: clean up the comments below!
@@ -448,12 +449,14 @@
                 # No t power is taken into account as we limit our selves to
                 # degree 1 in t and make no "t-shifts".
                 if columnsWidth != 0:
-                    polExpStr = spo_expression_as_string(iPower, 
+                    polExpStr = spo_expression_as_string(iPower,
+                                                         iBound, 
                                                          0, 
+                                                         tBound,
                                                          0, 
                                                          alpha)
                     print "->", polExpStr
-                currentExpression = iVariable^iPower * nAtAlpha
+                currentExpression = iVariable^iPower * nAtAlpha * iBound^iPower
                 # polynomialAtPower == 1 here. Next line should be commented
                 # out but it does not work! Some conversion problem?
                 currentPolynomial = pRing(currentExpression)
@@ -464,7 +467,8 @@
             # polynomial. This is also where the t^pPower monomials shows up for
             # the first time.
             if columnsWidth != 0:
-                polExpStr = spo_expression_as_string(0, 0, pPower, alpha-pPower)
+                polExpStr = spo_expression_as_string(0, iBound, 0, tBound, \
+                                                     pPower, alpha-pPower)
                 print "->", polExpStr
             currentPolynomial = polynomialAtPower * nAtPower
             polynomialsList.append(currentPolynomial) 
@@ -485,24 +489,31 @@
                 internalIpower = iPower
                 for tPower in xrange(pPower,0,-1):
                     if columnsWidth != 0:
-                        polExpStr = spo_expression_as_string(internalIpower, \
-                                                             tPower,  \
-                                                             0, \
+                        polExpStr = spo_expression_as_string(internalIpower, 
+                                                             iBound,
+                                                             tPower,
+                                                             tBound,
+                                                             0,
                                                              alpha)
                         print "->", polExpStr
-                    currentExpression = i^internalIpower * t^tPower * nAtAlpha
+                    currentExpression = i^internalIpower * t^tPower * \
+                                        nAtAlpha * iBound^internalIpower * \
+                                        tBound^tPower
+                    
                     currentPolynomial = pRing(currentExpression)
                     polynomialsList.append(currentPolynomial) 
                     internalIpower += pIdegree
                 # End for tPower
                 # The i^iPower * p^pPower * N^(alpha-pPower) i-shift.
                 if columnsWidth != 0:
-                    polExpStr = spo_expression_as_string(iPower, \
-                                                         0,      \
-                                                         pPower, \
+                    polExpStr = spo_expression_as_string(iPower, 
+                                                         iBound,
+                                                         0,      
+                                                         tBound,
+                                                         pPower, 
                                                          alpha-pPower)
                     print "->", polExpStr
-                currentExpression = i^iPower * nAtPower
+                currentExpression = i^iPower * nAtPower * iBound^iPower
                 currentPolynomial = pRing(currentExpression) * polynomialAtPower
                 polynomialsList.append(currentPolynomial) 
             # End for iPower
@@ -512,7 +523,7 @@
     return polynomialsList
 # End spo_polynomial_to_proto_matrix_2
 
-def spo_polynomial_to_polynomials_list_3(p, alpha, N, iBound, tBound, \
+def spo_polynomial_to_polynomials_list_3(p, alpha, N, iBound, tBound,
                                          columnsWidth=0):
     """
     From p, alpha, N build a list of polynomials...
@@ -532,7 +543,6 @@
                  printed in colums of columnsWitdth width.
     """
     pRing = p.parent()
-    knownMonomials = []
     polynomialsList = []
     pVariables = p.variables()
     iVariable = pVariables[0]
@@ -556,11 +566,13 @@
                 # degree 1 in t and make no "t-shifts".
                 if columnsWidth != 0:
                     polExpStr = spo_expression_as_string(iPower, 
+                                                         iBound,
                                                          0, 
+                                                         tBound,
                                                          0, 
                                                          alpha)
                     print "->", polExpStr
-                currentExpression = iVariable^iPower * nAtAlpha
+                currentExpression = iVariable^iPower * nAtAlpha * iBound^iPower
                 # polynomialAtPower == 1 here. Next line should be commented
                 # out but it does not work! Some conversion problem?
                 currentPolynomial = pRing(currentExpression)
@@ -571,13 +583,15 @@
             # polynomial. This is also where the t^pPower monomials shows up for
             # the first time. It app
             if columnsWidth != 0:
-                polExpStr = spo_expression_as_string(0, 0, pPower, alpha-pPower)
+                polExpStr = spo_expression_as_string(0, iBound, 
+                                                     0, tBound,
+                                                     pPower, alpha-pPower)
                 print "->", polExpStr
             currentPolynomial = polynomialAtPower * nAtPower
             polynomialsList.append(currentPolynomial) 
             # Exit when pPower == alpha
             if pPower == alpha:
-                return((knownMonomials, polynomialsList))
+                return polynomialsList
             # This is where the "i-shifts" take place. Mixed terms, i^k * t^l
             # (that were introduced at a previous
             # stage or are introduced now) are only shifted to already existing 
@@ -592,46 +606,57 @@
                 internalIpower = iPower
                 for tPower in xrange(pPower,0,-1):
                     if columnsWidth != 0:
-                        polExpStr = spo_expression_as_string(internalIpower, \
-                                                             tPower,  \
-                                                             0, \
+                        polExpStr = spo_expression_as_string(internalIpower,
+                                                             iBound, 
+                                                             tPower,  
+                                                             tBound,
+                                                             0,
                                                              alpha)
                         print "->", polExpStr
-                    currentExpression = i^internalIpower * t^tPower * nAtAlpha
+                    currentExpression = i^internalIpower * t^tPower * nAtAlpha * \
+                                        iBound^internalIpower * tBound^tPower
                     currentPolynomial = pRing(currentExpression)
                     polynomialsList.append(currentPolynomial) 
                     internalIpower += pIdegree
                 # End for tPower
                 # Here we have to choose between a 
                 # i^iPower * p^pPower * N^(alpha-pPower) i-shift and
-                # i^iPower * i^(d_i(p) * pPower) * N^alpha, depend on which 
+                # i^iPower * i^(d_i(p) * pPower) * N^alpha, depending on which 
                 # coefficient is smallest.
                 IcurrentExponent = iPower + \
-                                        (pPower * polynomialAtPower.degree(i))
-                currentMonomial = pRing(i^(IcurrentExponent))
-                currentPolynomial = pRing(i^iPower * nAtPower) * \
-                                                            polynomialAtPower
+                                (pPower * polynomialAtPower.degree(iVariable))
+                currentMonomial = pRing(iVariable^IcurrentExponent)
+                currentPolynomial = pRing(iVariable^iPower * nAtPower * \
+                                          iBound^iPower) * \
+                                          polynomialAtPower
                 currMonomials = currentPolynomial.monomials()
                 currCoefficients = currentPolynomial.coefficients()
                 currentCoefficient = spo_get_coefficient_for_monomial( \
                                                     currMonomials, 
                                                     currCoefficients, 
                                                     currentMonomial)
-                if currentCoefficient > nAtAlpha:
+                print "Current coefficient:", currentCoefficient
+                alterCoefficient = iBound^IcurrentExponent * nAtAlpha 
+                print "N^alpha * ibound^", IcurrentExponent, ":", \
+                         alterCoefficient
+                if currentCoefficient > alterCoefficient :
                     if columnsWidth != 0:
-                        polExpStr = spo_expression_as_string(IcurrentCoefficient, \
-                                                             0,      \
-                                                             0, \
+                        polExpStr = spo_expression_as_string(IcurrentExponent,
+                                                             iBound,
+                                                             0,
+                                                             tBound,
+                                                             0,
                                                              alpha)
-                    print "->", polExpStr
-                    polynomialsList.append(currentMonomial * nAtAlpha)
+                        print "->", polExpStr
+                    polynomialsList.append(currentMonomial * \
+                                           alterCoefficient)
                 else:
                     if columnsWidth != 0:
-                        polExpStr = spo_expression_as_string(iPower, \
-                                                             0,      \
-                                                             pPower, \
+                        polExpStr = spo_expression_as_string(iPower, iBound,
+                                                             0, tBound,
+                                                             pPower, 
                                                              alpha-pPower)
-                    print "->", polExpStr
+                        print "->", polExpStr
                     polynomialsList.append(currentPolynomial) 
             # End for iPower
         polynomialAtPower *= p  
@@ -640,15 +665,86 @@
     return polynomialsList 
 # End spo_polynomial_to_proto_matrix_3
 
-def spo_proto_to_column_matrix(protoMatrixColumns, \
-                               knownMonomialsList, \
-                               boundVar1, \
-                               boundVar2):
+def spo_polynomial_to_polynomials_list_4(p, alpha, N, iBound, tBound,
+                                         columnsWidth=0):
     """
-    Create a column (each row holds the coefficients of one monomial) matrix.
+    From p, alpha, N build a list of polynomials...
+    TODO: more in depth rationale...
     
+    Our goal is to introduce each monomial with the smallest coefficient.
+     
+    
+        
     Parameters
     ----------
+    p: the (bivariate) polynomial;
+    pRing: the ring over which p is defined;
+    alpha:
+    N:
+    columsWidth: if == 0, no information is displayed, otherwise data is 
+                 printed in colums of columnsWitdth width.
+    """
+    pRing = p.parent()
+    polynomialsList = []
+    pVariables = p.variables()
+    iVariable = pVariables[0]
+    tVariable = pVariables[1]
+    polynomialAtPower = copy(p)
+    currentPolynomial = pRing(1)
+    pIdegree = p.degree(iVariable)
+    pTdegree = p.degree(tVariable)
+    maxIdegree = pIdegree * alpha
+    currentIdegree = currentPolynomial.degree(iVariable)
+    nAtAlpha = N^alpha
+    nAtPower = nAtAlpha
+    polExpStr = ""
+    # We first introduce all the monomials in i alone multiplied by N^alpha.
+    for iPower in xrange(0, maxIdegree + 1):
+        if columnsWidth !=0:
+            polExpStr = spo_expression_as_string(iPower, iBound,
+                                                 0, tBound, 
+                                                 0, alpha)
+            print "->", polExpStr
+        currentExpression = iVariable^iPower * nAtAlpha * iBound^iPower
+        currentPolynomial = pRing(currentExpression)
+        polynomialsList.append(currentPolynomial)
+    # End for iPower
+    # We work from p^1 * N^alpha-1 to p^alpha * N^0
+    for pPower in xrange(1, alpha + 1):
+        # First of all the p^pPower * N^(alpha-pPower) polynomial.
+        nAtPower /= N
+        if columnsWidth !=0:
+            polExpStr = spo_expression_as_string(0, iBound,
+                                                 0, tBound,
+                                                 pPower, alpha-pPower)
+            print "->", polExpStr
+        currentPolynomial = polynomialAtPower * nAtPower
+        polynomialsList.append(currentPolynomial)
+        # Exit when pPower == alpha
+        if pPower == alpha:
+            return polynomialsList
+        # We now introduce the mixed i^k * t^l monomials by i^m * p^n * N^(alpha-n)
+        for iPower in xrange(1, pIdegree + 1): 
+            if columnsWidth != 0:
+                polExpStr = spo_expression_as_string(iPower, iBound,
+                                                     0, tBound, 
+                                                     pPower, alpha-pPower)
+                print "->", polExpStr
+            currentExpression = i^iPower * iBound^iPower * nAtPower
+            currentPolynomial = pRing(currentExpression) * polynomialAtPower
+            polynomialsList.append(currentPolynomial) 
+        # End for iPower
+        polynomialAtPower *= p  
+    # End for pPower loop
+    return polynomialsList 
+# End spo_polynomial_to_proto_matrix_4
+
+def spo_proto_to_column_matrix(protoMatrixColumns):
+    """
+    Create a column (each row holds the coefficients for one monomial) matrix.
+    
+    Parameters
+    ----------
     protoMatrixColumns: a list of coefficient lists.
     """
     numColumns = len(protoMatrixColumns)
@@ -663,18 +759,14 @@
         for rowIndex in xrange(0, len(protoMatrixColumns[colIndex])):
             if protoMatrixColumns[colIndex][rowIndex] != 0:
                 baseMatrix[rowIndex, colIndex] = \
-                    protoMatrixColumns[colIndex][rowIndex] * \
-                    knownMonomialsList[rowIndex](boundVar1, boundVar2)
+                    protoMatrixColumns[colIndex][rowIndex]
     return baseMatrix
 # End spo_proto_to_column_matrix.
 #
-def spo_proto_to_row_matrix(protoMatrixRows, \
-                            knownMonomialsList, \
-                            boundVar1, \
-                            boundVar2):
+def spo_proto_to_row_matrix(protoMatrixRows):
     """
-    Create a row (each column holds the evaluation one monomial at boundVar1 and
-    boundVar2 values) matrix.
+    Create a row (each column holds the coefficients corresponding to one 
+    monomial) matrix from the protoMatrixRows list.
     
     Parameters
     ----------
@@ -692,8 +784,7 @@
         for colIndex in xrange(0, len(protoMatrixRows[rowIndex])):
             if protoMatrixRows[rowIndex][colIndex] !=  0:
                 baseMatrix[rowIndex, colIndex] = \
-                    protoMatrixRows[rowIndex][colIndex] * \
-                    knownMonomialsList[colIndex](boundVar1,boundVar2)
+                    protoMatrixRows[rowIndex][colIndex]
             #print rowIndex, colIndex,
             #print protoMatrixRows[rowIndex][colIndex],
             #print knownMonomialsList[colIndex](boundVar1,boundVar2)
Index: pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage	(revision 110)
+++ pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage	(revision 111)
@@ -116,6 +116,18 @@
     return(varDeclarationString, varListArrayDeclaration) 
 # End smo_transformation_row_matrix_strings.
 
+def smo_triangular_matrix_determinant(matrix):
+    if matrix == None:
+        return None
+    numRows = matrix.nrows()
+    if numRows < 1:
+        return 0
+    determinant = 1
+    for rowIndex in xrange(numRows):
+        determinant *= matrix[rowIndex, rowIndex]
+    return determinant
+# End smo_triangular_matrix_determinant
+#
 def smo_zero_rows_index_list(matrix):
     """
     Compute the list of indices of the rows that have a 0 norm.
