Index: pobyso.py
===================================================================
--- pobyso.py	(revision 283)
+++ pobyso.py	(revision 284)
@@ -36,10 +36,11 @@
 from sage.symbolic.expression_conversions import polynomial
 from sage.symbolic.expression_conversions import PolynomialConverter
 """
-Create the equivalent to an enum for the Sollya function types.
+Create the equivalent to an enum for the Sollya function types and other
+common types (error types...).
 """
 (SOLLYA_BASE_FUNC_ABS,
-SOLLYA_BASE_FUNC_ACOS,
+    SOLLYA_BASE_FUNC_ACOS,
     SOLLYA_BASE_FUNC_ACOSH,
     SOLLYA_BASE_FUNC_ADD,
     SOLLYA_BASE_FUNC_ASIN,
@@ -81,7 +82,10 @@
     SOLLYA_BASE_FUNC_SUB,
     SOLLYA_BASE_FUNC_TAN,
     SOLLYA_BASE_FUNC_TANH,
-SOLLYA_BASE_FUNC_TRIPLEDOUBLE) = map(int,xrange(44))
+    SOLLYA_BASE_FUNC_TRIPLEDOUBLE,
+    SOLLYA_ABSOLUTE,
+    SOLLYA_RELATIVE) = map(int,xrange(46))
+sys.stderr.write("SOLLYA_RELATIVE = " + str(SOLLYA_RELATIVE) + "\n")
 sys.stderr.write("Superficial pobyso check...\n")
 #print "First constant - SOLLYA_BASE_FUNC_ABS: ", SOLLYA_BASE_FUNC_ABS
 #print "Last constant  - SOLLYA_BASE_FUNC_TRIPLEDOUBLE: ", SOLLYA_BASE_FUNC_TRIPLEDOUBLE
@@ -376,9 +380,15 @@
     with the same precision as the source.
     """
     ## Precision stuff. If one wants to change precisions,
-    #  everything takes place in Sage. That only makes
+    #  everything takes place in Sage. This only makes
     #  sense if one wants to reduce the precision.
     # TODO: revisit precision stuff with new technique.
+    # Check that rnArgSa is a realFiedl element.
+    try:
+        rnArgSa.ulp()
+    except AttributeError:
+        return pobyso_error_so()
+    # If a different precision is wanted modify it.
     if not precisionSa is None:
         RRR = RealField(precisionSa)
         rnArgSa = RRR(rnArgSa)
@@ -759,7 +769,7 @@
 
 def pobyso_get_constant_so_sa(rnArgSa, constSo):
     """
-    Set the value of rnArgSo to the value of constSo in MPFR_RNDN mode.
+    Set the value of rnArgSa to the value of constSo in MPFR_RNDN mode.
     rnArg must already exist and belong to some RealField.
     We assume that constSo points to a Sollya constant.
     """
@@ -2096,15 +2106,115 @@
     sollya_lib_set_prec(newPrecSo)
 # End pobyso_set_prec_so_so.
 #   
-def pobyso_supnorm_sa_sa(poly):
+def pobyso_supnorm_sa_sa(polySa, 
+                         funcSa, 
+                         intervalSa, 
+                         errorTypeSa=SOLLYA_ABSOLUTE, 
+                         accuracySa=RR(2^-40)):
     """
-    Computes the supremum norm from Sage input arguments and returns a
-    Sage floating-point number whose precision is set by the realFieldSa
-    argument.
-    TODO: complete this stub!
+    An supnorm call with Sage arguments.
     """
-    print("This function does nothing!")
-    return None
+    # Check that polySa is a univariate polynomial. We only check here at
+    # expression level, not at polynomial ring level
+    ## Make sure it is not a multivariate polynomial. The number of variables
+    #  can be zero in the case of a constant.
+    try:
+        if len(polySa.free_variables()) > 1 :
+            print "Invalid number of free variables in polySa:", polySa,
+            " -", polySa.free_variables()
+            return None
+    except AttributeError:
+        print "polySa is not a SymbolicExpression."
+        return None 
+    ## Make sure it is a polynomial.
+    if not polySa.is_polynomial(polySa.default_variable()):
+        print "polySa is not a polynomila expression."
+        return None
+    # Check that funcSa is a function.
+    if not \
+     sage.symbolic.callable.is_CallableSymbolicExpressionRing(parent(funcSa)):
+        return None
+    # Check that intervalSa is an interval.
+    try:
+        intervalSa.upper()
+    except AttributeError:
+        print "intervalSa is not an interval."
+        return None
+    # Convert the Sage polynomial into a Sollya polynomial.
+    polyAsStringSa = polySa._assume_str().replace('_SAGE_VAR_', '')
+    polySo = pobyso_parse_string_sa_so(polyAsStringSa)
+    if not pobyso_obj_is_function_so_sa(polySo):
+        sollya_lib_clear_obj(polySo)
+        print "The Sollya object created from the polynomial is not a function."
+        return None
+    #pobyso_autoprint(polySo)
+    # Convert the Sage function into a Sollya function.
+    funcAsStringSa = funcSa._assume_str().replace('_SAGE_VAR_', '')
+    funcSo = pobyso_parse_string_sa_so(funcAsStringSa)
+    if not pobyso_obj_is_function_so_sa(funcSo):
+        sollya_lib_clear_obj(polySo)
+        sollya_lib_clear_obj(funcSo)
+        print "The Sollya object created from the function is not a function."
+        return None
+    #pobyso_autoprint(funcSo)
+    # Convert the Sage interval into a Sollya range.
+    rangeSo = pobyso_interval_to_range_sa_so(intervalSa)
+    if not pobyso_is_range_so_sa(rangeSo):
+        sollya_lib_clear_obj(polySo)
+        sollya_lib_clear_obj(funcSo)
+        sollya_lib_clear_obj(rangeSo)
+        print "The Sollya object created from the interval is not a range."
+        return None
+    #pobyso_autoprint(rangeSo)
+    # Check the error type. We do not check the returned object since we
+    # trust our code and Sollya on this one.
+    if errorTypeSa != SOLLYA_ABSOLUTE and errorTypeSa != SOLLYA_RELATIVE:
+        sollya_lib_clear_obj(polySo)
+        sollya_lib_clear_obj(funcSo)
+        sollya_lib_clear_obj(rangeSo)
+        return None
+    if errorTypeSa == SOLLYA_ABSOLUTE:
+        errorTypeSo = pobyso_absolute_so_so()
+    else:
+        errorTypeSo = pobyso_relative_so_so()
+    #pobyso_autoprint(errorTypeSo)
+    # Check if accuracySa is an element of a RealField. If not, try to 
+    # convert it.
+    try:
+        accuracySa.ulp()
+    except AttributeError:
+        try:
+            accuracySa = RR(accuracySa)
+        except TypeError:
+            accuracySa = RR(str(accuracySa))
+    # Create the Sollya object
+    accuracySo = pobyso_constant_sa_so(accuracySa)
+    #pobyso_autoprint(accuracySo)
+    if pobyso_is_error_so_sa(accuracySo):
+        sollya_lib_clear_obj(polySo)
+        sollya_lib_clear_obj(funcSo)
+        sollya_lib_clear_obj(rangeSo)
+        sollya_lib_clear_obj(errorTypeSo)
+        sollya_lib_clear_obj(accuracySo)
+        return None
+    retValSo = sollya_lib_supnorm(polySo, 
+                                  funcSo, 
+                                  rangeSo, 
+                                  errorTypeSo, 
+                                  accuracySo, 
+                                  None)
+    sollya_lib_clear_obj(polySo)
+    sollya_lib_clear_obj(funcSo)
+    sollya_lib_clear_obj(rangeSo)
+    sollya_lib_clear_obj(errorTypeSo)
+    sollya_lib_clear_obj(accuracySo)
+    if pobyso_is_error_so_sa(retValSo):
+        sollya_lib_clear_obj(retValSo)
+        return None
+    #pobyso_autoprint(retValSo)
+    retValSa = pobyso_range_to_interval_so_sa(retValSo)
+    sollya_lib_clear_obj(retValSo)
+    return retValSa
 # End pobyso_supnorm_sa_sa
 
 def pobyso_supnorm_so_sa(polySo, funcSo, intervalSo, errorTypeSo = None,\
