Statistiques
| Révision :

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

Historique | Voir | Annoter | Télécharger (5,23 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
    elif index == 6:
94
        debugMode = sys.argv[index].upper()
95
        debugMode = (debugMode == "DEBUG")
96
# Done with command line arguments collection.
97
#
98
## Debug printing
99
print "degree         :", degree
100
print "alpha          :", alpha
101
print "htrn           :", htrn
102
print "binade         :", binade
103
print "sign           :", signAsString
104
print "debug mode     :", debugMode
105
print
106
#
107
## Set the terminal window title.
108
terminalWindowTitle = ['stt', 
109
                        str(degree), 
110
                        str(alpha), 
111
                        str(htrn), 
112
                        str(binade),
113
                        signAsString]
114
call(terminalWindowTitle)
115
#
116
binadeUlp    = 2^(binade - precision + 1)
117
signAsString = signAsString.lower()
118
if signAsString == "pos": 
119
    lowerBound   = RRR(2^binade)
120
    upperBound   = RRR(2^(binade+1)) - binadeUlp
121
elif signAsString == "neg":
122
    lowerBound  = -RRR(2^(binade+1)) + binadeUlp
123
    upperBound  =  -RRR(2^binade)
124
    print lowerBound
125
    print upperBound
126
else:
127
    exceptionErrorMess = "\"" + signAsString + "\" is an invalid sign." \
128
    ". Aborting!\n"
129
    raise Exception(exceptionErrorMess)
130
srs_run_SLZ_v05(inputFunction=func, 
131
                     inputLowerBound         = lowerBound, 
132
                     inputUpperBound         = upperBound, 
133
                     alpha                   = alpha, 
134
                     degree                  = degree, 
135
                     precision               = precision, 
136
                     emin                    = emin, 
137
                     emax                    = emax, 
138
                     targetHardnessToRound   = htrn, 
139
                     debug                   = debugMode)
140