Statistiques
| Révision :

root / pobysoPythonSage / src / sageSLZ / runSLZ-53-binade.sage @ 274

Historique | Voir | Annoter | Télécharger (5,31 ko)

1
#! /opt/sage/sage
2
# @file runSLZ-113proj.sage
3
#
4
#@par Changes from runSLZ-113.sage
5
# LLL reduction is not performed on the matrix itself but rather on the
6
# product of the matrix with a uniform random matrix.
7
# The reduced matrix obtained is discarded but the transformation matrix 
8
# obtained is used to multiply the original matrix in order to reduced it.
9
# If a sufficient level of reduction is obtained, we stop here. If not
10
# the product matrix obtained above is LLL reduced. But as it has been
11
# pre-reduced at the above step, reduction is supposed to be much faster.
12
#
13
# Both reductions combined should hopefully be faster than a straight single
14
# reduction.
15
#
16
# Run SLZ for p=113
17
#from scipy.constants.codata import precision
18
def initialize_env():
19
    """
20
    Load all necessary modules.
21
    """
22
    compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx"
23
    if compiledSpyxDir not in sys.path:
24
        sys.path.append(compiledSpyxDir)
25
    if not 'mpfi' in sage.misc.cython.standard_libs:
26
        sage.misc.cython.standard_libs.append('mpfi')
27
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
28
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
29
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
30
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
31
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
32
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
33
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
34
    # Matrix operations are loaded by polynomial operations.
35
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
36
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
37

    
38

    
39
print "Running SLZ..."
40
initialize_env()
41
from sageMpfr import *
42
from sageGMP  import *
43
import sys
44
from subprocess import call
45
#
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
signAsString = ""
57
binade       = 0
58
debugMode    = False          
59
## Local functions
60
#
61
def usage():
62
    write = sys.stderr.write
63
    write("\nUsage:\n")
64
    write("  " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
65
    write("               <numberOfNumbers> [debug]\n")
66
    write("\nArguments:\n")
67
    write("  degree          the degree of the polynomial (integer)\n")
68
    write("  alpha           alpha (integer)\n")
69
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
70
    write("  binade          the binade we want to  explore\n")
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")
74
    write("  debug           debug mode (\"debug\", in any case)\n\n")
75
    sys.exit(2)
76
# End usage.
77
#
78
argsCount = len(sys.argv)
79
scriptName = os.path.basename(__file__)
80
if argsCount < 6:
81
    usage()
82
for index in xrange(1,argsCount):
83
    if index == 1:
84
        degree = int(sys.argv[index])
85
    elif index == 2:
86
        alpha = int(sys.argv[index])
87
    elif index == 3:
88
        htrn = int(eval(sys.argv[index]))
89
    elif index == 4:
90
        binade = int(eval(sys.argv[index]))
91
    elif index == 5:
92
        signAsString = sys.argv[index]
93
        signAsString = signAsString.lower()
94
    elif index == 6:
95
        debugMode = sys.argv[index].upper()
96
        debugMode = (debugMode == "DEBUG")
97
# Done with command line arguments collection.
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
else:
116
    exceptionErrorMess = "\"" + signAsString + "\" is an invalid sign." \
117
    ". Aborting!\n"
118
    raise Exception(exceptionErrorMess)
119
#
120
## Debug printing
121
print "degree         :", degree
122
print "alpha          :", alpha
123
print "htrn           :", htrn
124
print "binade         :", binade
125
print "lower bound    :", lowerBound.str(truncate=False)
126
print "upper bound    :", upperBound.str(truncate=False)
127
print "sign           :", signAsString
128
print "debug mode     :", debugMode
129
print
130
#
131
srs_run_SLZ_v05(inputFunction=func, 
132
                     inputLowerBound         = lowerBound, 
133
                     inputUpperBound         = upperBound, 
134
                     alpha                   = alpha, 
135
                     degree                  = degree, 
136
                     precision               = precision, 
137
                     emin                    = emin, 
138
                     emax                    = emax, 
139
                     targetHardnessToRound   = htrn, 
140
                     debug                   = debugMode)
141