Révision 254 pobysoPythonSage/src/sageSLZ/runSLZ-53proj-binade.sage

runSLZ-53proj-binade.sage (revision 254)
44 44
from subprocess import call
45 45
#
46 46
## Main variables and parameters.
47
x         = var('x')
48
func(x)   = exp(x)
49
precision = 53
50
emin      = -1022
51
emax      = 1023 
52
RRR       = RealField(precision)
53
degree    = 0
54
alpha     = 0
55
htrn      = 0
56
binade    = 0
57
debugMode = False          
47
x            = var('x')
48
func(x)      = exp(x)
49
precision    = 53
50
emin         = -1022
51
emax         = 1023 
52
RRR          = RealField(precision)
53
degree       = 0
54
alpha        = 0
55
htrn         = 0
56
signAsString = ""
57
binade       = 0
58
debugMode    = False          
58 59
## Local functions
59 60
#
60 61
def usage():
......
68 69
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
69 70
    write("  binade          the binade we want to  explore\n")
70 71
    write("                  as a positive integral expression\n")
72
    write("  sign            the sign of the interval we want to expolore\n")
73
    write("                  either \"pos\" or \"neg\"\n")
71 74
    write("  debug           debug mode (\"debug\", in any case)\n\n")
72 75
    sys.exit(2)
73 76
# End usage.
74 77
#
75 78
argsCount = len(sys.argv)
76 79
scriptName = os.path.basename(__file__)
77
if argsCount < 5:
80
if argsCount < 6:
78 81
    usage()
79 82
for index in xrange(1,argsCount):
80 83
    if index == 1:
......
85 88
        htrn = int(eval(sys.argv[index]))
86 89
    elif index == 4:
87 90
        binade = int(eval(sys.argv[index]))
88
        ## The number must be strictly positive.
89 91
    elif index == 5:
92
        signAsString = sys.argv[index]
93
        signAsString = signAsString.lower()
94
    elif index == 6:
90 95
        debugMode = sys.argv[index].upper()
91 96
        debugMode = (debugMode == "DEBUG")
92 97
# Done with command line arguments collection.
93 98
#
99
## Set the terminal window title.
100
terminalWindowTitle = ['stt', 
101
                        str(degree), 
102
                        str(alpha), 
103
                        str(htrn), 
104
                        str(binade),
105
                        signAsString]
106
call(terminalWindowTitle)
107
#
108
binadeUlp    = 2^(binade - precision + 1)
109
if signAsString == "pos": 
110
    lowerBound   = RRR(2^binade)
111
    upperBound   = RRR(2^(binade+1)) - binadeUlp
112
elif signAsString == "neg":
113
    lowerBound  = -RRR(2^(binade+1)) + binadeUlp
114
    upperBound  =  -RRR(2^binade)
115
    print lowerBound
116
    print upperBound
117
else:
118
    exceptionErrorMess = "\"" + signAsString + "\" is an invalid sign." \
119
    ". Aborting!\n"
120
    raise Exception(exceptionErrorMess)
121
#
94 122
## Debug printing
95 123
print "degree         :", degree
96 124
print "alpha          :", alpha
97 125
print "htrn           :", htrn
98 126
print "binade         :", binade
127
print "lower bound    :", lowerBound.str(truncate=False)
128
print "upper bound    :", upperBound.str(truncate=False)
129
print "sign           :", signAsString
99 130
print "debug mode     :", debugMode
100 131
print
101 132
#
102
## Set the terminal window title.
103
terminalWindowTitle = ['stt', 
104
                        str(degree), 
105
                        str(alpha), 
106
                        str(htrn), 
107
                        str(binade)]
108
call(terminalWindowTitle)
109
#
110
binadeUlp  = 2^(binade - precision + 1)
111
lowerBound = RRR(2^binade)
112
upperBound = RRR(2^(binade+1)) - binadeUlp
113 133
srs_run_SLZ_v05_proj(inputFunction=func, 
114 134
                     inputLowerBound         = lowerBound, 
115 135
                     inputUpperBound         = upperBound, 

Formats disponibles : Unified diff