Index: pobysoPythonSage/src/sageSLZ/sageSLZ-Notes.html
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageSLZ-Notes.html	(revision 79)
+++ pobysoPythonSage/src/sageSLZ/sageSLZ-Notes.html	(revision 80)
@@ -68,7 +68,7 @@
 abbr           {font-family : helvetica, arial, sans-serif;
                 font-style : normal;
                 font-weight : bold}
-/* Identique � <abbr> */
+/* Identique � abbr */
 acronym        {font-family : helvetica, arial, sans-serif;
                 font-style : normal;
                 font-weight : bold}
@@ -265,9 +265,9 @@
 hr.twentypc    {margin-left: 40%;
                 margin-right: 40%;}
 /* Notes */
-/* L'appel de note est r�alis� par un �l�ment <a> de classe callNote */
+/* L'appel de note est r�alis� par un �l�ment "a" de classe callNote */
 a.callNote     {}
-/* Le retour de note est r�alis� par un �l�ment </a><a> de classe retFromNote */
+/* Le retour de note est r�alis� par un �l�ment "a" de classe retFromNote */
 a.retFromNote  {}
 /* Liste des notes proprement dite */
 ol.notes       {margin-left: 0%;
@@ -296,7 +296,7 @@
 div.toc        {margin-left : 50pt}
 ul.toc         {font-size : 14pt ; 
                 font-family : Helvetica , Arial , sans-serif}
-</a></abbr></style>
+</style>
   <title>sageSLZ Notes</title>
 </head>
 
Index: pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 79)
+++ pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 80)
@@ -1,10 +1,117 @@
 load "/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage"
 
+def spo_add_polynomial_coeffs_to_matrix(pMonomials, 
+                                        pCoefficients, 
+                                        knownMonomials, 
+                                        protoMatrixRows, 
+                                        columnsWidth=0):
+    """
+    For a given polynomial (under the form of monomials and coefficents lists),
+    add the coefficients of the protoMatrix (a list of proto matrix rows).
+    Coefficients are added to the protoMatrix row in the order imposed by the 
+    monomials discovery list (the knownMonomials list) built as construction
+    goes on. 
+    As a bonus data can be printed out for a visual check.
+    pMonomials     : the list of the monomials coming form some polynomial;
+    pCoefficients  : the list of the corresponding coefficients to add to
+                     the protoMatrix in the exact same order as the monomials;
+    knownMonomials : the list of the already knonw monomials;
+    protoMatrixRows: a list of lists, each one holding the coefficients of the 
+                     monomials
+    columnWith     : the width, in characters, of the displayed column ; if 0, 
+                     do not display anything.
+    """
+    # We have started with the smaller degrees in the first variable.
+    pMonomials.reverse()
+    pCoefficients.reverse()
+    # New empty proto matrix row.
+    protoMatrixRowCoefficients = []
+    # We work according to the order of the already known monomials
+    # No known monomials yet: add the pMonomials to knownMonomials 
+    # and add the coefficients to the proto matrix row.
+    if len(knownMonomials) == 0: 
+        for pmIdx in xrange(0, len(pMonomials)):
+            knownMonomials.append(pMonomials[pmIdx])
+            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
+            if columnsWidth != 0:
+                monomialAsString = str(pCoefficients[pmIdx]) + " " + \
+                                   str(pMonomials[pmIdx])
+                print monomialAsString, " " * \
+                      (columnsWidth - len(monomialAsString)),
+    # There are some known monomials. We search for them in pMonomials and 
+    # add their coefficients to the proto matrix row.
+    else: 
+        for knownMonomialIndex in xrange(0,len(knownMonomials)):
+            # We lazily use an exception here since pMonomials.index() function
+            # may fail throwing the ValueError exception.
+            try:
+                indexInPmonomials = \
+                    pMonomials.index(knownMonomials[knownMonomialIndex])
+                if columnsWidth != 0:
+                    monomialAsString = str(pCoefficients[indexInPmonomials]) + \
+                        " " + str(knownMonomials[knownMonomialIndex])
+                    print monomialAsString, " " * \
+                        (columnsWidth - len(monomialAsString)),
+                # Add the coefficient to the proto matrix row and delete the \
+                # known monomial from the current pMonomial list 
+                #(and the corresponding coefficient as well).
+                protoMatrixRowCoefficients.append(pCoefficients[indexInPmonomials])
+                del pMonomials[indexInPmonomials]
+                del pCoefficients[indexInPmonomials]
+            # The knownMonomials element is not in pMonomials
+            except ValueError:   
+                protoMatrixRowCoefficients.append(0)
+                if columnsWidth != 0:
+                    monomialAsString = "0" + " "+ \
+                        str(knownMonomials[knownMonomialIndex])
+                    print monomialAsString, " " * \
+                        (columnsWidth - len(monomialAsString)),
+        # End for knownMonomialKey loop. 
+        # We now append the remaining monomials of pMonomials to knownMonomials 
+        # and the corresponding coefficients to proto matrix row.
+        for pmIdx in xrange(0, len(pMonomials)):
+            knownMonomials.append(pMonomials[pmIdx])
+            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
+            if columnsWidth != 0:
+                monomialAsString = str(pCoefficients[pmIdx]) + " " \
+                    + str(pMonomials[pmIdx])
+                print monomialAsString, " " * \
+                    (columnsWidth - len(monomialAsString)),
+        # End for pmIdx loop.
+    # Add the new list row elements to the proto matrix.
+    protoMatrixRows.append(protoMatrixRowCoefficients)
+    if columnsWidth != 0:
+        print    
+# End spo_add_polynomial_coeffs_to_matrix
+
+def spo_expression_as_string(powI, powT, powP, alpha):
+    """
+    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)
+    if powT != 0:
+        if len(expressionAsString) != 0:
+            expressionAsString += " * "
+        expressionAsString += "t^" + str(powT)
+    if powP != 0:
+        if len(expressionAsString) != 0:
+            expressionAsString += " * "
+        expressionAsString += "p^" + str(powP)
+    if (alpha - powP) != 0 :
+        if len(expressionAsString) != 0:
+            expressionAsString += " * "
+        expressionAsString += "N^" + str(alpha - powP)
+    return(expressionAsString)
+# End spo_expression_as_string.
+
 def spo_polynomial_to_matrix(p, pRing, alpha, N, columnsWidth=0):
     """
     From a (bivariate) polynomial and some other parameters build a matrix
     to be reduced by fpLLL.
-    The matrix is such as those found in Boneh-Durphy and Stehlé.
+    The matrix is such as those found in Boneh-Durphee and Stehl�.
     
     p: the (bivariate) polynomial
     alpha:
@@ -209,110 +316,3 @@
     # End for pPower loop
     return protoMatrixRows
 # End spo_polynomial_to_matrix
-
-def spo_add_polynomial_coeffs_to_matrix(pMonomials, 
-                                        pCoefficients, 
-                                        knownMonomials, 
-                                        protoMatrixRows, 
-                                        columnsWidth=0):
-    """
-    For a given polynomial (under the form of monomials and coefficents lists),
-    add the coefficients of the protoMatrix (a list of proto rows).
-    Coefficients are added to the protoMatrix row in the order imposed by the 
-    monomials discovery list (the knownMonomials list) built as construction
-    goes on. 
-    As a bonus data can be printed out for a visual check.
-    pMonomials     : the list of the monomials coming form some polynomial;
-    pCoefficients  : the list of the corresponding coefficients to add to
-                     the protoMatrix in the exact same order as the monomials;
-    knownMonomials : the list of the already knonw monomials;
-    protoMatrixRows: a list of lists, each one holding the coefficients of the 
-                     monomials
-    columnWith     : the width, in characters, of the displayed column ; if 0, 
-                     do not display anything.
-    """
-    # We have started with the smaller degrees in the first variable.
-    pMonomials.reverse()
-    pCoefficients.reverse()
-    # New empty proto matrix row.
-    protoMatrixRowCoefficients = []
-    # We work according to the order of the already known monomials
-    # No known monomials yet: add the pMonomials to knownMonomials 
-    # and add the coefficients to the proto matrix row.
-    if len(knownMonomials) == 0: 
-        for pmIdx in xrange(0, len(pMonomials)):
-            knownMonomials.append(pMonomials[pmIdx])
-            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
-            if columnsWidth != 0:
-                monomialAsString = str(pCoefficients[pmIdx]) + " " + \
-                                   str(pMonomials[pmIdx])
-                print monomialAsString, " " * \
-                      (columnsWidth - len(monomialAsString)),
-    # There are some known monomials. We search for them in pMonomials and 
-    # add their coefficients to the proto matrix row.
-    else: 
-        for knownMonomialIndex in xrange(0,len(knownMonomials)):
-            # We lazily use an exception here since pMonomials.index() function
-            # may fail throwing the ValueError exception.
-            try:
-                indexInPmonomials = \
-                    pMonomials.index(knownMonomials[knownMonomialIndex])
-                if columnsWidth != 0:
-                    monomialAsString = str(pCoefficients[indexInPmonomials]) + \
-                        " " + str(knownMonomials[knownMonomialIndex])
-                    print monomialAsString, " " * \
-                        (columnsWidth - len(monomialAsString)),
-                # Add the coefficient to the proto matrix row and delete the \
-                # known monomial from the current pMonomial list 
-                #(and the corresponding coefficient as well).
-                protoMatrixRowCoefficients.append(pCoefficients[indexInPmonomials])
-                del pMonomials[indexInPmonomials]
-                del pCoefficients[indexInPmonomials]
-            # The knownMonomials element is not in pMonomials
-            except ValueError:   
-                protoMatrixRowCoefficients.append(0)
-                if columnsWidth != 0:
-                    monomialAsString = "0" + " "+ \
-                        str(knownMonomials[knownMonomialIndex])
-                    print monomialAsString, " " * \
-                        (columnsWidth - len(monomialAsString)),
-        # End for knownMonomialKey loop. 
-        # We now append the remaining monomials of pMonomials to knownMonomials 
-        # and the corresponding coefficients to proto matrix row.
-        for pmIdx in xrange(0, len(pMonomials)):
-            knownMonomials.append(pMonomials[pmIdx])
-            protoMatrixRowCoefficients.append(pCoefficients[pmIdx])
-            if columnsWidth != 0:
-                monomialAsString = str(pCoefficients[pmIdx]) + " " \
-                    + str(pMonomials[pmIdx])
-                print monomialAsString, " " * \
-                    (columnsWidth - len(monomialAsString)),
-        # End for pmIdx loop.
-    # Add the new list row elements to the proto matrix.
-    protoMatrixRows.append(protoMatrixRowCoefficients)
-    if columnsWidth != 0:
-        print    
-# End spo_add_polynomial_coeffs_to_matrix
-
-def spo_expression_as_string(powI, powT, powP, alpha):
-    """
-    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)
-    if powT != 0:
-        if len(expressionAsString) != 0:
-            expressionAsString += " * "
-        expressionAsString += "t^" + str(powT)
-    if powP != 0:
-        if len(expressionAsString) != 0:
-            expressionAsString += " * "
-        expressionAsString += "p^" + str(powP)
-    if (alpha - powP) != 0 :
-        if len(expressionAsString) != 0:
-            expressionAsString += " * "
-        expressionAsString += "N^" + str(alpha - powP)
-    return(expressionAsString)
-# End spo_expression_as_string.
\ No newline at end of file
Index: pobysoPythonSage/src/sageSLZ/sageSLZ.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 79)
+++ pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 80)
@@ -58,7 +58,6 @@
     # End slz_compute_polynomial_and_interval
 
 def slz_compute_scaled_function(functionSa, \
-                                      variableNameSa, \
                                       lowerBoundSa, \
                                       upperBoundSa, \
                                       floatingPointPrecSa):
@@ -72,18 +71,21 @@
     [3]: the scaled image lower bound
     [4]: the scaled image upper bound
     """
-    x = var(variableNameSa)
+    x = functionSa.variables()[0]
+    # Reassert f as a function (an not a mere expression).
+    
     # Scalling the domain -> [1,2[.
     boundsIntervalRifSa = RealIntervalField(floatingPointPrecSa)
     domainBoundsIntervalSa = boundsIntervalRifSa(lowerBoundSa, upperBoundSa)
     (domainScalingExpressionSa, invDomainScalingExpressionSa) = \
-        slz_interval_scaling_expression(domainBoundsIntervalSa, variableNameSa)
+        slz_interval_scaling_expression(domainBoundsIntervalSa, x)
     print "domainScalingExpression for argument :", domainScalingExpressionSa
     print "f: ", f
     ff = f.subs({x : domainScalingExpressionSa})
     #ff = f.subs_expr(x==domainScalingExpressionSa)
-    scaledLowerBoundSa = invDomainScalingExpressionSa(lowerBoundSa).n()
-    scaledUpperBoundSa = invDomainScalingExpressionSa(upperBoundSa).n()
+    domainScalingFunction(x) = invDomainScalingExpressionSa
+    scaledLowerBoundSa = domainScalingFunction(lowerBoundSa).n()
+    scaledUpperBoundSa = domainScalingFunction(upperBoundSa).n()
     print 'ff:', ff, "- Domain:", scaledLowerBoundSa, scaledUpperBoundSa
     #
     # Scalling the image -> [1,2[.
@@ -96,7 +98,7 @@
     print 'ff:', ff, '- Image:', flbSa, fubSa, imageBinadeBottomSa
     imageBoundsIntervalSa = boundsIntervalRifSa(flbSa, fubSa)
     (imageScalingExpressionSa, invImageScalingExpressionSa) = \
-        slz_interval_scaling_expression(imageBoundsIntervalSa, variableNameSa)
+        slz_interval_scaling_expression(imageBoundsIntervalSa, x)
     iis = invImageScalingExpressionSa.function(x)
     fff = iis.subs({x:ff})
     print "fff:", fff,
@@ -110,7 +112,7 @@
     return(polynomialRing(polyOfFloat))
 # End slz_float_poly_of_float_to_rat_poly_of_rat
      
-def slz_get_intervals_and_polynomials(functionSa, variableNameSa, degreeSa, 
+def slz_get_intervals_and_polynomials(functionSa, degreeSa, 
                                       lowerBoundSa, 
                                       upperBoundSa, floatingPointPrecSa, 
                                       internalSollyaPrecSa, approxPrecSa):
@@ -133,36 +135,14 @@
     - the center, x0, of the interval;
     - the corresponding approximation error.
     """
-    x = var(variableNameSa)
-    # Scalling the domain -> [1,2[.
-    boundsIntervalRifSa = RealIntervalField(floatingPointPrecSa)
-    domainBoundsIntervalSa = boundsIntervalRifSa(lowerBoundSa, upperBoundSa)
-    (domainScalingExpressionSa, invDomainScalingExpressionSa) = \
-        slz_interval_scaling_expression(domainBoundsIntervalSa, variableNameSa)
-    print "domainScalingExpression for argument :", domainScalingExpressionSa
-    print "f: ", f
-    ff = f.subs({x : domainScalingExpressionSa})
-    #ff = f.subs_expr(x==domainScalingExpressionSa)
-    scaledLowerBoundSa = invDomainScalingExpressionSa(lowerBoundSa).n()
-    scaledUpperBoundSa = invDomainScalingExpressionSa(upperBoundSa).n()
-    print 'ff:', ff, "- Domain:", scaledLowerBoundSa, scaledUpperBoundSa
+    x = functionSa.variables()[0] # Actual variable name can be anything.
+    (fff, scaledLowerBoundSa, scaledUpperBoundSa, \
+            scaledLowerBoundImageSa, scaledUpperBoundImageSa) = \
+                slz_compute_scaled_function(functionSa, \
+                                            lowerBoundSa, \
+                                            upperBoundSa, \
+                                            floatingPointPrecSa)
     #
-    # Scalling the image -> [1,2[.
-    flbSa = f(lowerBoundSa).n()
-    fubSa = f(upperBoundSa).n()
-    if flbSa <= fubSa: # Increasing
-        imageBinadeBottomSa = floor(flbSa.log2())
-    else: # Decreasing
-        imageBinadeBottomSa = floor(fubSa.log2())
-    print 'ff:', ff, '- Image:', flbSa, fubSa, imageBinadeBottomSa
-    imageBoundsIntervalSa = boundsIntervalRifSa(flbSa, fubSa)
-    (imageScalingExpressionSa, invImageScalingExpressionSa) = \
-        slz_interval_scaling_expression(imageBoundsIntervalSa, variableNameSa)
-    iis = invImageScalingExpressionSa.function(x)
-    fff = iis.subs({x:ff})
-    print "fff:", fff,
-    print " - Image:", fff(scaledLowerBoundSa), fff(scaledUpperBoundSa)
-    #
     resultArray = []
     #
     print "Approximation precision: ", RR(approxPrecSa)
@@ -208,7 +188,7 @@
     return(resultArray)
     # End slz_get_intervals_and_polynomials
 
-def slz_interval_scaling_expression(boundsInterval, varName):
+def slz_interval_scaling_expression(boundsInterval, expVar):
     """
     Compute the scaling expression to map an interval that span only
     a binade to [1, 2) and the inverse expression as well.
@@ -219,27 +199,27 @@
         if boundsInterval.endpoints()[0] >= 0:
             scalingCoeff = 2^floor(boundsInterval.endpoints()[0].log2())
             invScalingCoeff = 1/scalingCoeff
-            return((scalingCoeff * eval(varName), 
-                    invScalingCoeff * eval(varName)))
+            return((scalingCoeff * expVar, 
+                    invScalingCoeff * expVar))
         else:
             scalingCoeff = \
                 2^(floor((-boundsInterval.endpoints()[0]).log2()) - 1)
             scalingOffset = -3 * scalingCoeff
-            return((scalingCoeff * eval(varName) + scalingOffset,
-                    1/scalingCoeff * eval(varName) + 3))
+            return((scalingCoeff * expVar + scalingOffset,
+                    1/scalingCoeff * expVar + 3))
     else: 
         if boundsInterval.endpoints()[0] >= 0:
             scalingCoeff = 2^floor(boundsInterval.endpoints()[0].log2())
             scalingOffset = 0
-            return((scalingCoeff * eval(varName), 
-                    1/scalingCoeff * eval(varName)))
+            return((scalingCoeff * expVar, 
+                    1/scalingCoeff * expVar))
         else:
             scalingCoeff = \
                 2^(floor((-boundsInterval.endpoints()[1]).log2()))
             scalingOffset =  -3 * scalingCoeff
             #scalingOffset = 0
-            return((scalingCoeff * eval(varName) + scalingOffset,
-                    1/scalingCoeff * eval(varName) + 3))
+            return((scalingCoeff * expVar + scalingOffset,
+                    1/scalingCoeff * expVar + 3))
 
    
 def slz_polynomial_and_interval_to_sage(polyRangeCenterErrorSo):
@@ -269,9 +249,50 @@
     return((polynomialSa, polynomialChangedVarSa, intervalSa, centerSa, errorSa))
     # End slz_polynomial_and_interval_to_sage
 
-def slz_rat_poly_of_int_to_int_poly_of_int(ratPolyOfInt):
-    pass
-# End slz_ratPoly_of_int_to_int_poly_of_int
+def slz_rat_poly_of_int_to_poly_for_coppersmith(ratPolyOfInt, 
+                                                precision,
+                                                targetHardnessToRound,
+                                                variable1,
+                                                variable2):
+    """
+    Creates a new polynomial with integer coefficients for use with the
+    Coppersmith method.
+    A the same time it computes :
+    - 2^K (N);
+    - 2^k
+    - lcm
+    """
+    # Create a new integer polynomial ring.
+    IP = PolynomialRing(ZZ, name=str(variable1) + "," + str(variable2))
+    # Coefficients are issued in the increasing power order.
+    ratPolyCoefficients = ratPolyOfInt.coefficients()
+    # Build the list of number we compute the lcmm of.
+    coefficientDenominators = sro_denominators(ratPolyCoefficients)
+    coefficientDenominators.append(2^precision)
+    coefficientDenominators.append(2^(targetHardnessToRound + 1))
+    leastCommonMultiple = sro_lcmm(coefficientDenominators)
+    # Compute the lcm
+    leastCommonMultiple = sro_lcmm(coefficientDenominators)
+    # Compute the expression corresponding to the new polynomial
+    coefficientNumerators =  sro_numerators(ratPolyCoefficients)
+    print coefficientNumerators
+    polynomialExpression = 0
+    power = 0
+    # Iterate over two lists at the same time, stop when the shorter is
+    # exhausted.
+    for numerator, denominator in \
+                            zip(coefficientNumerators, coefficientDenominators):
+        multiplicator = leastCommonMultiple / denominator 
+        newCoefficient = numerator * multiplicator
+        polynomialExpression += newCoefficient * variable1^power
+        power +=1
+    polynomialExpression += - variable2
+    return (IP(polynomialExpression),
+            leastCommonMultiple / 2^precision, # 2^K or N.
+            leastCommonMultiple / 2 ^(targetHardnessToRound + 1), # tBound
+            leastCommonMultiple)
+        
+# End slz_ratPoly_of_int_to_poly_for_coppersmith
 
 def slz_rat_poly_of_rat_to_rat_poly_of_int(ratPolyOfRat, 
                                           precision):
Index: pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage	(revision 79)
+++ pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage	(revision 80)
@@ -6,7 +6,7 @@
 - Serge Torres: first operations set (2013-04) 
 """
 
-def denominators(rationalList = None):
+def sro_denominators(rationalList = None):
     """
     Compute the list of the denominators of a rational numbers list.
     """
@@ -37,8 +37,9 @@
                     "has no \"denominator()\" member." 
             return([])
     return(denominatorsList)
+# End sro_denominators
 
-def lcmm(rationalList = None):
+def sro_lcmm(rationalList = None):
     """ 
     Compute the lcm of an sequence (list, tuple) of rational numbers.
     """
@@ -62,8 +63,9 @@
     except Exception:
         print "Exception raised in lcmm!"
         return(0)
-    
-def numerators(rationalList = None):
+# End sro_lcmm
+
+def sro_numerators(rationalList = None):
     """
     Compute the list of the numerators of a rational numbers list.
     """
@@ -93,4 +95,5 @@
             print "numerators:", rationalList[i], \
                     "has no \"numerator()\" member." 
             return([])
-    return(numeratorsList)
\ No newline at end of file
+    return(numeratorsList)
+# End sro_numerators
\ No newline at end of file
