Statistiques
| Révision :

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

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

1 252 storres
#! /opt/sage/sage
2 252 storres
# @file runSLZ-113proj.sage
3 252 storres
#
4 252 storres
#@par Changes from runSLZ-113.sage
5 252 storres
# LLL reduction is not performed on the matrix itself but rather on the
6 252 storres
# product of the matrix with a uniform random matrix.
7 252 storres
# The reduced matrix obtained is discarded but the transformation matrix
8 252 storres
# obtained is used to multiply the original matrix in order to reduced it.
9 252 storres
# If a sufficient level of reduction is obtained, we stop here. If not
10 252 storres
# the product matrix obtained above is LLL reduced. But as it has been
11 252 storres
# pre-reduced at the above step, reduction is supposed to be much faster.
12 252 storres
#
13 252 storres
# Both reductions combined should hopefully be faster than a straight single
14 252 storres
# reduction.
15 252 storres
#
16 252 storres
# Run SLZ for p=113
17 252 storres
#from scipy.constants.codata import precision
18 252 storres
def initialize_env():
19 252 storres
    """
20 252 storres
    Load all necessary modules.
21 252 storres
    """
22 252 storres
    compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx"
23 252 storres
    if compiledSpyxDir not in sys.path:
24 252 storres
        sys.path.append(compiledSpyxDir)
25 252 storres
    if not 'mpfi' in sage.misc.cython.standard_libs:
26 252 storres
        sage.misc.cython.standard_libs.append('mpfi')
27 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
28 252 storres
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
29 252 storres
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
30 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
31 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
32 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
33 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
34 252 storres
    # Matrix operations are loaded by polynomial operations.
35 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
36 252 storres
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
37 252 storres
38 252 storres
39 252 storres
print "Running SLZ..."
40 252 storres
initialize_env()
41 252 storres
from sageMpfr import *
42 252 storres
from sageGMP  import *
43 252 storres
import sys
44 252 storres
from subprocess import call
45 252 storres
#
46 252 storres
## Main variables and parameters.
47 254 storres
x            = var('x')
48 254 storres
func(x)      = exp(x)
49 254 storres
precision    = 53
50 254 storres
emin         = -1022
51 254 storres
emax         = 1023
52 254 storres
RRR          = RealField(precision)
53 254 storres
degree       = 0
54 254 storres
alpha        = 0
55 254 storres
htrn         = 0
56 254 storres
signAsString = ""
57 254 storres
binade       = 0
58 254 storres
debugMode    = False
59 252 storres
## Local functions
60 252 storres
#
61 252 storres
def usage():
62 252 storres
    write = sys.stderr.write
63 252 storres
    write("\nUsage:\n")
64 252 storres
    write("  " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
65 252 storres
    write("               <numberOfNumbers> [debug]\n")
66 252 storres
    write("\nArguments:\n")
67 252 storres
    write("  degree          the degree of the polynomial (integer)\n")
68 252 storres
    write("  alpha           alpha (integer)\n")
69 252 storres
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
70 252 storres
    write("  binade          the binade we want to  explore\n")
71 252 storres
    write("                  as a positive integral expression\n")
72 254 storres
    write("  sign            the sign of the interval we want to expolore\n")
73 254 storres
    write("                  either \"pos\" or \"neg\"\n")
74 252 storres
    write("  debug           debug mode (\"debug\", in any case)\n\n")
75 252 storres
    sys.exit(2)
76 252 storres
# End usage.
77 252 storres
#
78 252 storres
argsCount = len(sys.argv)
79 252 storres
scriptName = os.path.basename(__file__)
80 254 storres
if argsCount < 6:
81 252 storres
    usage()
82 252 storres
for index in xrange(1,argsCount):
83 252 storres
    if index == 1:
84 252 storres
        degree = int(sys.argv[index])
85 252 storres
    elif index == 2:
86 252 storres
        alpha = int(sys.argv[index])
87 252 storres
    elif index == 3:
88 252 storres
        htrn = int(eval(sys.argv[index]))
89 252 storres
    elif index == 4:
90 252 storres
        binade = int(eval(sys.argv[index]))
91 252 storres
    elif index == 5:
92 254 storres
        signAsString = sys.argv[index]
93 254 storres
        signAsString = signAsString.lower()
94 254 storres
    elif index == 6:
95 252 storres
        debugMode = sys.argv[index].upper()
96 252 storres
        debugMode = (debugMode == "DEBUG")
97 252 storres
# Done with command line arguments collection.
98 252 storres
#
99 254 storres
## Set the terminal window title.
100 254 storres
terminalWindowTitle = ['stt',
101 254 storres
                        str(degree),
102 254 storres
                        str(alpha),
103 254 storres
                        str(htrn),
104 254 storres
                        str(binade),
105 254 storres
                        signAsString]
106 254 storres
call(terminalWindowTitle)
107 254 storres
#
108 254 storres
binadeUlp    = 2^(binade - precision + 1)
109 254 storres
if signAsString == "pos":
110 254 storres
    lowerBound   = RRR(2^binade)
111 254 storres
    upperBound   = RRR(2^(binade+1)) - binadeUlp
112 254 storres
elif signAsString == "neg":
113 254 storres
    lowerBound  = -RRR(2^(binade+1)) + binadeUlp
114 254 storres
    upperBound  =  -RRR(2^binade)
115 254 storres
    print lowerBound
116 254 storres
    print upperBound
117 254 storres
else:
118 254 storres
    exceptionErrorMess = "\"" + signAsString + "\" is an invalid sign." \
119 254 storres
    ". Aborting!\n"
120 254 storres
    raise Exception(exceptionErrorMess)
121 254 storres
#
122 252 storres
## Debug printing
123 252 storres
print "degree         :", degree
124 252 storres
print "alpha          :", alpha
125 252 storres
print "htrn           :", htrn
126 252 storres
print "binade         :", binade
127 254 storres
print "lower bound    :", lowerBound.str(truncate=False)
128 254 storres
print "upper bound    :", upperBound.str(truncate=False)
129 254 storres
print "sign           :", signAsString
130 252 storres
print "debug mode     :", debugMode
131 252 storres
print
132 252 storres
#
133 252 storres
srs_run_SLZ_v05_proj(inputFunction=func,
134 252 storres
                     inputLowerBound         = lowerBound,
135 252 storres
                     inputUpperBound         = upperBound,
136 252 storres
                     alpha                   = alpha,
137 252 storres
                     degree                  = degree,
138 252 storres
                     precision               = precision,
139 252 storres
                     emin                    = emin,
140 252 storres
                     emax                    = emax,
141 252 storres
                     targetHardnessToRound   = htrn,
142 252 storres
                     debug                   = debugMode)