Statistiques
| Révision :

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

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

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