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