Statistiques
| Révision :

root / pobysoPythonSage / src / sageSLZ / runSLZ-113projWeak.sage.py

Historique | Voir | Annoter | Télécharger (6,77 ko)

1
# This file was *autogenerated* from the file ./runSLZ-113projWeak.sage
2
from sage.all_cmdline import *   # import sage library
3
_sage_const_3 = Integer(3); _sage_const_2 = Integer(2); _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_6 = Integer(6); _sage_const_5 = Integer(5); _sage_const_4 = Integer(4); _sage_const_113 = Integer(113); _sage_const_10 = Integer(10); _sage_const_16383 = Integer(16383); _sage_const_16382 = Integer(16382)#! /opt/sage/sage
4
# @file runSLZ-113proj.sage
5
#
6
#@par Changes from runSLZ-113.sage
7
# LLL reduction is not performed on the matrix itself but rather on the
8
# product of the matrix with a uniform random matrix.
9
# The reduced matrix obtained is discarded but the transformation matrix 
10
# obtained is used to multiply the original matrix in order to reduced it.
11
# If a sufficient level of reduction is obtained, we stop here. If not
12
# the product matrix obtained above is LLL reduced. But as it has been
13
# pre-reduced at the above step, reduction is supposed to be much faster.
14
#
15
# Both reductions combined should hopefully be faster than a straight single
16
# reduction.
17
#
18
# Run SLZ for p=113
19
#from scipy.constants.codata import precision
20
def initialize_env():
21
    """
22
    Load all necessary modules.
23
    """
24
    if version().split()[_sage_const_2 ].replace(',','') > '6.6':
25
        compiledSpyxDir = \
26
            "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx"
27
        if compiledSpyxDir not in sys.path:
28
            sys.path.append(compiledSpyxDir)
29
    else:
30
        if not 'mpfi' in sage.misc.cython.standard_libs:
31
            sage.misc.cython.standard_libs.append('mpfi')
32
        load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
33
        load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
34
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
35
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
36
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
37
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
38
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
39
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
40
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
41
    # Matrix operations are loaded by polynomial operations.
42
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
43
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
44

    
45

    
46
print "Running SLZ..."
47
initialize_env()
48
if version().split()[_sage_const_2 ].replace(',','') > '6.6':
49
    from sageMpfr import *
50
    from sageGMP  import *
51
import sys
52
from subprocess import call
53
#
54
## Main variables and parameters.
55
x         = var('x')
56
__tmp__=var("x"); func = symbolic_expression(exp(x)).function(x)
57
precision = _sage_const_113 
58
emin      = -_sage_const_16382 
59
emax      = _sage_const_16383  
60
RRR = RealField(precision)
61
degree              = _sage_const_0 
62
alpha               = _sage_const_0 
63
htrn                = _sage_const_0 
64
intervalCenter      = _sage_const_0 
65
intervalRadius      = _sage_const_0 
66
debugMode           = False          
67
## Local functions
68
#
69
def usage():
70
    write = sys.stderr.write
71
    write("\nUsage:\n")
72
    write("  " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
73
    write("               <numberOfNumbers> [debug]\n")
74
    write("\nArguments:\n")
75
    write("  degree          the degree of the polynomial (integer)\n")
76
    write("  alpha           alpha (integer)\n")
77
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
78
    write("  intervalCenter  the interval center (a floating-point number)\n")
79
    write("  numberOfNumbers the number of floating-point numbers in the interval\n")
80
    write("                  as a positive integral expression\n")
81
    write("  debug           debug mode (\"debug\", in any case)\n\n")
82
    sys.exit(_sage_const_2 )
83
# End usage.
84
#
85
argsCount = len(sys.argv)
86
scriptName = os.path.basename(__file__)
87
if argsCount < _sage_const_5 :
88
    usage()
89
for index in xrange(_sage_const_1 ,argsCount):
90
    if index == _sage_const_1 :
91
        degree = int(sys.argv[index])
92
    elif index == _sage_const_2 :
93
        alpha = int(sys.argv[index])
94
    elif index == _sage_const_3 :
95
        htrn = int(eval(sys.argv[index]))
96
    elif index == _sage_const_4 :
97
        try:
98
            intervalCenter = QQ(sage_eval(sys.argv[index]))
99
        except:
100
            intervalCenter = RRR(sys.argv[index])
101
        intervalCenter = RRR(intervalCenter)
102
    elif index == _sage_const_5 :
103
        ## Can be read as rational number but must end up as an integer.
104
        numberOfNumbers = QQ(sage_eval(sys.argv[index]))
105
        if numberOfNumbers != numberOfNumbers.round():
106
            raise Exception("Invalid number of numbers: " + sys.argv[index] + ".")
107
        numberOfNumbers = numberOfNumbers.round()
108
        ## The number must be strictly positive.
109
        if numberOfNumbers <= _sage_const_0 :
110
            raise Exception("Invalid number of numbers: " + sys.argv[index] + ".")
111
    elif index == _sage_const_6 :
112
        debugMode = sys.argv[index].upper()
113
        debugMode = (debugMode == "DEBUG")
114
# Done with command line arguments collection.
115
#
116
## Debug printing
117
print "degree         :", degree
118
print "alpha          :", alpha
119
print "htrn           :", htrn
120
print "interval center:", intervalCenter.n(prec=_sage_const_10 ).str(truncate=False)
121
print "num of nums    :", RR(numberOfNumbers).log2().n(prec=_sage_const_10 ).str(truncate=False)
122
print "debug mode     :", debugMode
123
print
124
#
125
## Set the terminal window title.
126
terminalWindowTitle = ['stt', str(degree), str(alpha), str(htrn), 
127
                       intervalCenter.n(prec=_sage_const_10 ).str(truncate=False), 
128
                       RRR(numberOfNumbers).log2().n(prec=_sage_const_10 ).str(truncate=False)]
129
call(terminalWindowTitle)
130
#
131
intervalCenterBinade = slz_compute_binade(intervalCenter)
132
intervalRadius       = \
133
    _sage_const_2 **intervalCenterBinade * _sage_const_2 **(-precision + _sage_const_1 ) * numberOfNumbers / _sage_const_2 
134
srs_run_SLZ_v05_proj_weak(inputFunction=func, 
135
                     inputLowerBound         = intervalCenter - intervalRadius, 
136
                     inputUpperBound         = intervalCenter + intervalRadius, 
137
                     alpha                   = alpha, 
138
                     degree                  = degree, 
139
                     precision               = precision, 
140
                     emin                    = emin, 
141
                     emax                    = emax, 
142
                     targetHardnessToRound   = htrn, 
143
                     debug                   = debugMode)
144