#! /opt/sage/sage
# @file runSLZ-03.sage
#
def initialize_env():
    """
    Load all necessary modules.
    """
    if not 'mpfi' in sage.misc.cython.standard_libs:
        sage.misc.cython.standard_libs.append('mpfi')
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
    # Matrix operations are loaded by polynomial operations.
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")


print "Running SLZ..."
initialize_env()
x = var('x')
func(x) = exp(x)
precision = 53
RRR = RealField(precision)
intervalCenter      = RRR("1.9E9CBBFD6080B",16)  * 2^-31
icUlp               = intervalCenter.ulp()
intervalRadiusInUlp = 2^49 + 2^45          
srs_compute_lattice_volume(inputFunction=func, 
                           inputLowerBound = RRR(1) * 2^-31, 
                           inputUpperBound = RRR(1) * 2^-30 - icUlp, 
                           alpha           = 4, 
                           degree          = 4, 
                           precision       = 53, 
                           emin            = -1022, 
                           emax            = 1023, 
                           targetHardnessToRound =  precision+50, 
                           debug           = True)
#
"""
srs_run_SLZ_v02(inputFunction=func, 
                inputLowerBound = RRR(1) * 2^-31, 
                inputUpperBound = RRR(1) * 2^-30 - icUlp, 
                alpha           = 2, 
                degree          = 2, 
                precision       = 53, 
                emin            = -1022, 
                emax            = 1023, 
                targetHardnessToRound =  precision+50, 
                debug           = True)
"""
"""
srs_run_SLZ_v01(inputFunction=func, 
                inputLowerBound = 402653184/1073741824, 
                inputUpperBound = 402653185/1073741824, 
                alpha = 2, 
                degree = 10, 
                precision = 53, 
                emin = -1022, 
                emax = 1023, 
                targetHardnessToRound =  precision+50, 
                debug = True)

#inputUpperBound = RRR(1/2) - RRR(1/4).ulp(), 
RR("1.9E9CBBFD6080B",16)  * 2^-31]
"""