Statistiques
| Révision :

root / pobysoPythonSage / src / sageSLZ / runSLZ-53gram.sage @ 274

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

1
#! /opt/sage/sage
2
# @file runSLZ-113gram.sage
3
#
4
#@par Changes from runSLZ-113.sage
5
# LLL reduction is not performed on the matrix itself but on its Gram matrix as
6
# an attempt for a faster reduction.
7
#
8
# Run SLZ for p=113
9
#from scipy.constants.codata import precision
10
def initialize_env():
11
    """
12
    Load all necessary modules.
13
    """
14
    compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx"
15
    if compiledSpyxDir not in sys.path:
16
        sys.path.append(compiledSpyxDir)
17
    if not 'mpfi' in sage.misc.cython.standard_libs:
18
        sage.misc.cython.standard_libs.append('mpfi')
19
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
20
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
21
#    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx")
22
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
23
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
24
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
25
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
26
    # Matrix operations are loaded by polynomial operations.
27
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
28
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")
29

    
30

    
31
print "Running SLZ..."
32
initialize_env()
33
from sageMpfr import *
34
from sageGMP  import *
35
import sys
36
from subprocess import call
37
#
38
## Main variables and parameters.
39
x         = var('x')
40
func(x)   = exp(x)
41
precision = 53
42
emin      = -1022
43
emax      = 1023 
44
RRR = RealField(precision)
45
degree              = 0
46
alpha               = 0
47
htrn                = 0
48
intervalCenter      = 0
49
intervalRadius      = 0
50
debugMode           = False          
51
## Local functions
52
#
53
def usage():
54
    write = sys.stderr.write
55
    write("\nUsage:\n")
56
    write("  " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n")
57
    write("               <numberOfNumbers> [debug]\n")
58
    write("\nArguments:\n")
59
    write("  degree          the degree of the polynomial (integer)\n")
60
    write("  alpha           alpha (integer)\n")
61
    write("  htrn            hardness-to-round - a number of bits (integer)\n")
62
    write("  intervalCenter  the interval center (a floating-point number)\n")
63
    write("  numberOfNumbers the number of floating-point numbers in the interval\n")
64
    write("                  as a positive integral expression\n")
65
    write("  debug           debug mode (\"debug\", in any case)\n\n")
66
    sys.exit(2)
67
# End usage.
68
#
69
argsCount = len(sys.argv)
70
scriptName = os.path.basename(__file__)
71
if argsCount < 5:
72
    usage()
73
for index in xrange(1,argsCount):
74
    if index == 1:
75
        degree = int(sys.argv[index])
76
    elif index == 2:
77
        alpha = int(sys.argv[index])
78
    elif index == 3:
79
        htrn = int(eval(sys.argv[index]))
80
    elif index == 4:
81
        try:
82
            intervalCenter = QQ(sage_eval(sys.argv[index]))
83
        except:
84
            intervalCenter = RRR(sys.argv[index])
85
        intervalCenter = RRR(intervalCenter)
86
    elif index == 5:
87
        ## Can be read as rational number but must end up as an integer.
88
        numberOfNumbers = QQ(sage_eval(sys.argv[index]))
89
        if numberOfNumbers != numberOfNumbers.round():
90
            raise Exception("Invalid number of numbers: " + sys.argv[index] + ".")
91
        numberOfNumbers = numberOfNumbers.round()
92
        ## The number must be strictly positive.
93
        if numberOfNumbers <= 0:
94
            raise Exception("Invalid number of numbers: " + sys.argv[index] + ".")
95
    elif index == 6:
96
        debugMode = sys.argv[index].upper()
97
        debugMode = (debugMode == "DEBUG")
98
# Done with command line arguments collection.
99
#
100
## Debug printing
101
print "degree         :", degree
102
print "alpha          :", alpha
103
print "htrn           :", htrn
104
print "interval center:", intervalCenter.n(prec=10).str(truncate=False)
105
print "num of nums    :", RR(numberOfNumbers).log2().n(prec=10).str(truncate=False)
106
print "debug mode     :", debugMode
107
print
108
#
109
## Set the terminal window title.
110
terminalWindowTitle = ['stt', str(degree), str(alpha), str(htrn), 
111
                       intervalCenter.n(prec=10).str(truncate=False), 
112
                       RRR(numberOfNumbers).log2().n(prec=10).str(truncate=False)]
113
call(terminalWindowTitle)
114
#
115
intervalCenterBinade = slz_compute_binade(intervalCenter)
116
intervalRadius       = \
117
    2^intervalCenterBinade * 2^(-precision + 1) * numberOfNumbers / 2
118
srs_run_SLZ_v05_gram(inputFunction=func, 
119
                     inputLowerBound         = intervalCenter - intervalRadius, 
120
                     inputUpperBound         = intervalCenter + intervalRadius, 
121
                     alpha                   = alpha, 
122
                     degree                  = degree, 
123
                     precision               = precision, 
124
                     emin                    = emin, 
125
                     emax                    = emax, 
126
                     targetHardnessToRound   = htrn, 
127
                     debug                   = debugMode)
128