Statistiques
| Révision :

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

Historique | Voir | Annoter | Télécharger (4,6 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 252 storres
x         = var('x')
48 252 storres
func(x)   = exp(x)
49 252 storres
precision = 53
50 252 storres
emin      = -1022
51 252 storres
emax      = 1023
52 252 storres
RRR       = RealField(precision)
53 252 storres
degree    = 0
54 252 storres
alpha     = 0
55 252 storres
htrn      = 0
56 252 storres
binade    = 0
57 252 storres
debugMode = False
58 252 storres
## Local functions
59 252 storres
#
60 252 storres
def usage():
61 252 storres
    write = sys.stderr.write
62 252 storres
    write("\nUsage:\n")
63 252 storres
    write("  " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
64 252 storres
    write("               <numberOfNumbers> [debug]\n")
65 252 storres
    write("\nArguments:\n")
66 252 storres
    write("  degree          the degree of the polynomial (integer)\n")
67 252 storres
    write("  alpha           alpha (integer)\n")
68 252 storres
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
69 252 storres
    write("  binade          the binade we want to  explore\n")
70 252 storres
    write("                  as a positive integral expression\n")
71 252 storres
    write("  debug           debug mode (\"debug\", in any case)\n\n")
72 252 storres
    sys.exit(2)
73 252 storres
# End usage.
74 252 storres
#
75 252 storres
argsCount = len(sys.argv)
76 252 storres
scriptName = os.path.basename(__file__)
77 252 storres
if argsCount < 5:
78 252 storres
    usage()
79 252 storres
for index in xrange(1,argsCount):
80 252 storres
    if index == 1:
81 252 storres
        degree = int(sys.argv[index])
82 252 storres
    elif index == 2:
83 252 storres
        alpha = int(sys.argv[index])
84 252 storres
    elif index == 3:
85 252 storres
        htrn = int(eval(sys.argv[index]))
86 252 storres
    elif index == 4:
87 252 storres
        binade = int(eval(sys.argv[index]))
88 252 storres
        ## The number must be strictly positive.
89 252 storres
    elif index == 5:
90 252 storres
        debugMode = sys.argv[index].upper()
91 252 storres
        debugMode = (debugMode == "DEBUG")
92 252 storres
# Done with command line arguments collection.
93 252 storres
#
94 252 storres
## Debug printing
95 252 storres
print "degree         :", degree
96 252 storres
print "alpha          :", alpha
97 252 storres
print "htrn           :", htrn
98 252 storres
print "binade         :", binade
99 252 storres
print "debug mode     :", debugMode
100 252 storres
print
101 252 storres
#
102 252 storres
## Set the terminal window title.
103 252 storres
terminalWindowTitle = ['stt',
104 252 storres
                        str(degree),
105 252 storres
                        str(alpha),
106 252 storres
                        str(htrn),
107 252 storres
                        str(binade)]
108 252 storres
call(terminalWindowTitle)
109 252 storres
#
110 252 storres
binadeUlp  = 2^(binade - precision + 1)
111 252 storres
lowerBound = RRR(2^binade)
112 252 storres
upperBound = RRR(2^(binade+1)) - binadeUlp
113 252 storres
srs_run_SLZ_v05_proj(inputFunction=func,
114 252 storres
                     inputLowerBound         = lowerBound,
115 252 storres
                     inputUpperBound         = upperBound,
116 252 storres
                     alpha                   = alpha,
117 252 storres
                     degree                  = degree,
118 252 storres
                     precision               = precision,
119 252 storres
                     emin                    = emin,
120 252 storres
                     emax                    = emax,
121 252 storres
                     targetHardnessToRound   = htrn,
122 252 storres
                     debug                   = debugMode)