commit 9b0c03e7def0734b03411e64933f761941a3c1f7
Author: Serge Torres <Serge.Torres@ens-lyon.fr>
Date:   Thu Dec 31 21:10:38 2015 +0100

    Added: more functions.

diff --git a/src/functions_for_cvp.sage b/src/functions_for_cvp.sage
index 1db1106..b6124b3 100644
--- a/src/functions_for_cvp.sage
+++ b/src/functions_for_cvp.sage
@@ -90,7 +90,7 @@ def cvp_coefficients_bounds_projection(executablePath, arguments):
     bounds = sage_eval(otp)
     minCoeffsExpList = []
     maxCoeffsExpList = [] 
-    print "bounds:", bounds
+    #print "bounds:", bounds
     for boundsPair in bounds:
         minCoeffsExpList.append(boundsPair[0])
         maxCoeffsExpList.append(boundsPair[1])
@@ -117,9 +117,9 @@ def cvp_coefficients_bounds_projection_exps(executablePath,
         cvp_coefficients_bounds_projection(executablePath,arguments)
     for index in xrange(0, len(minCoeffsExpList)):
         minCoeffsExpList[index] = \
-            realField(minCoeffsExpList[index]).log2().floor()
+            realField(minCoeffsExpList[index]).abs().log2().floor()
         maxCoeffsExpList[index] = \
-            realField(maxCoeffsExpList[index]).log2().floor()
+            realField(maxCoeffsExpList[index]).abs().log2().floor()
     return (minCoeffsExpList, maxCoeffsExpList)
 # End cvp_coefficients_bounds_projection_exps
 
@@ -358,12 +358,15 @@ def cvp_int_basis(floatBasis,
     for rIndex in xrange(0, floatBasis.nrows()):
         for cIndex in xrange(0, floatBasis.ncols()):
             intBasis[rIndex, cIndex] = \
-            floatBasis[rIndex, cIndex] * \
-            2^(commonScalingExp + extraScalingExpsList[rIndex])
+            (floatBasis[rIndex, cIndex] * \
+            2^(commonScalingExp + extraScalingExpsList[rIndex])).round()
     return intBasis
 # End cvp_int_basis.
 #
 def cvp_int_vector_for_approx(floatVect, commonScalingExp, extraScalingExp):
+    """
+    Compute the integral version of the function vector.
+    """
     totalScalingFactor = 2^(commonScalingExp + extraScalingExp)
     intVect = vector(ZZ, len(floatVect))
     for index in xrange(0, len(floatVect)):
@@ -416,6 +419,54 @@ def cvp_polynomial_coeffs_from_vect(cvpVectInBasis,
     return polynomialCoeffsList
 # En polynomial_coeffs_from_vect.
 #
+def cvp_polynomial_from_coeffs_and_exps(coeffsList, 
+                                        expsList, 
+                                        polyField = None,
+                                        theVar = None):
+    """
+    Build a polynomial in the classical monomials (possibly lacunary) basis 
+    from a list of coefficients and a list of exponents. The polynomial is in
+    the polynomial field given as argument.
+    """
+    if len(coeffsList) != len(expsList):
+        return None
+    ## If no variable is given, "x" is used.
+    ## If no polyField is given, we fall back on a polynomial field on RR.
+    if theVar is None:
+        if polyField is None:
+            theVar = x
+            polyField = RR[theVar]
+        else:
+            theVar = var(polyField.variable_name())
+    else: # theVar is set.
+        if polyField is None:
+            polyField = RR[theVar]
+        else: # Both the polyFiled and theVar are set: create a new polyField
+            # with theVar. The original polyField is not affected by the change.
+            polyField = polyField.change_var(theVar)  
+    ## Seed the polynomial.
+    poly = polyField(0)
+    ## Append the terms.
+    for coeff, exp in zip(coeffsList, expsList):
+        poly += polyField(coeff * theVar^exp)
+    return poly
+# End cvp_polynomial_from_coeffs_and_exps.
+#
+def cvp_remez_all_poly_error_func_maxi(funct, 
+                                        maxDegree, 
+                                        lowerBound, 
+                                        upperBound,
+                                        precsList, 
+                                        realField = None,
+                                        contFracMaxErr = None):
+    pass
+    """
+    For a given function f, a degree and an interval, compute the 
+    maxima of the (f-remez_d(f)) function and those of the (f-truncRemez_d(f)) 
+    function over the interval.
+    """
+# End cvp_remez_all_poly_error_func_maxi.
+#
 def cvp_remez_all_poly_error_func_zeros(funct, 
                                         maxDegree, 
                                         lowerBound, 
@@ -428,6 +479,7 @@ def cvp_remez_all_poly_error_func_zeros(funct,
     zeros of the (f-remez_d(f)) function and those of the (f-truncRemez_d(f)) 
     function over the interval. If the (f-truncRemez_d(f)) function has very 
     few zeros, compute the zeros of the derivative instead.
+    TODO: change the final behaviour! Now!
     """
     ## If no realField argument is given try to retrieve it from the 
     #  bounds. If impossible (e.g. rational bound), fall back on RR. 
@@ -467,17 +519,17 @@ def cvp_remez_all_poly_error_func_zeros(funct,
     ## Deal with the truncated polynomial now.
     ### Create the formats list. Notice the "*" before the list variable name.
     truncFormatListSo = pobyso_build_list_of_ints_sa_so(*precsList)
-    print "Precisions list as Sollya object:", 
+    #print "Precisions list as Sollya object:", 
     pobyso_autoprint(truncFormatListSo)
     pTruncSo = pobyso_round_coefficients_so_so(pStarSo, truncFormatListSo)
-    print "Truncated polynomial:", ; pobyso_autoprint(pTruncSo)
+    #print "Truncated polynomial:", ; pobyso_autoprint(pTruncSo)
     ### Compute the error function. This time we consume both the function
     #   and the polynomial.
     errorFuncSo = sollya_lib_build_function_sub(pTruncSo, 
                                                 funcSo)
     errorFuncZerosSo = pobyso_dirty_find_zeros_so_so(errorFuncSo, intervalSo)
     pobyso_clear_obj(pStarSo)
-    print "Zeroes of the error function for the truncated polynomial from Sollya:"
+    #print "Zeroes of the error function for the truncated polynomial from Sollya:"
     pobyso_autoprint(errorFuncZerosSo)
     errorFuncTruncZerosSa = pobyso_float_list_so_sa(errorFuncZerosSo)
     pobyso_clear_obj(errorFuncZerosSo)
@@ -485,7 +537,7 @@ def cvp_remez_all_poly_error_func_zeros(funct,
     #  In this case, we are interested in the variations and we consider the
     #  derivative
     if maxDegree > 3:
-        if len(errorFuncTruncZerosSa) <= 2:
+        if len(errorFuncTruncZerosSa) <= (maxDegree / 2):
             errorFuncDiffSo = pobyso_diff_so_so(errorFuncSo)
             errorFuncZerosSo = pobyso_dirty_find_zeros_so_so(errorFuncDiffSo,
                                                              intervalSo)
