root / pobysoPythonSage / src / sageSLZ / runSLZ-113.sage @ 230
Historique | Voir | Annoter | Télécharger (4,42 ko)
1 | 230 | storres | #! /opt/sage/sage |
---|---|---|---|
2 | 230 | storres | # @file runSLZ-113.sage |
3 | 230 | storres | # |
4 | 230 | storres | # Run SLZ for p=113 |
5 | 230 | storres | #from scipy.constants.codata import precision |
6 | 230 | storres | def initialize_env(): |
7 | 230 | storres | """ |
8 | 230 | storres | Load all necessary modules. |
9 | 230 | storres | """ |
10 | 230 | storres | compiledSpyxDir = "/home/storres/recherche/arithmetique/pobysoPythonSage/compiledSpyx" |
11 | 230 | storres | if compiledSpyxDir not in sys.path: |
12 | 230 | storres | sys.path.append(compiledSpyxDir) |
13 | 230 | storres | if not 'mpfi' in sage.misc.cython.standard_libs: |
14 | 230 | storres | sage.misc.cython.standard_libs.append('mpfi') |
15 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage") |
16 | 230 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx") |
17 | 230 | storres | # load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageGMP.spyx") |
18 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py") |
19 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage") |
20 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage") |
21 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage") |
22 | 230 | storres | # Matrix operations are loaded by polynomial operations. |
23 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage") |
24 | 230 | storres | load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage") |
25 | 230 | storres | |
26 | 230 | storres | |
27 | 230 | storres | print "Running SLZ..." |
28 | 230 | storres | initialize_env() |
29 | 230 | storres | from sageMpfr import * |
30 | 230 | storres | from sageGMP import * |
31 | 230 | storres | import sys |
32 | 230 | storres | from subprocess import call |
33 | 230 | storres | # |
34 | 230 | storres | ## Main variables and parameters. |
35 | 230 | storres | x = var('x') |
36 | 230 | storres | func(x) = exp(x) |
37 | 230 | storres | precision = 113 |
38 | 230 | storres | emin = -16382 |
39 | 230 | storres | emax = 16383 |
40 | 230 | storres | RRR = RealField(precision) |
41 | 230 | storres | degree = 0 |
42 | 230 | storres | alpha = 0 |
43 | 230 | storres | htrn = 0 |
44 | 230 | storres | intervalCenter = 0 |
45 | 230 | storres | intervalRadius = 0 |
46 | 230 | storres | debugMode = False |
47 | 230 | storres | ## Local functions |
48 | 230 | storres | # |
49 | 230 | storres | def usage(): |
50 | 230 | storres | write = sys.stderr.write |
51 | 230 | storres | write("\nUsage:\n") |
52 | 230 | storres | write(" " + scriptName + " <degree> <alpha> <htrn> <intervalCenter>\n") |
53 | 230 | storres | write(" <intervalRadius> [debug]\n") |
54 | 230 | storres | write("\nArguments:\n") |
55 | 230 | storres | write(" degree the degree of the polynomial (integer)\n") |
56 | 230 | storres | write(" alpha alpha (integer)\n") |
57 | 230 | storres | write(" htrn hardness-to-round - a number of bits (integer)\n") |
58 | 230 | storres | write(" intervalCenter the interval center (a floating-point number)\n") |
59 | 230 | storres | write(" intervalRadius the interval radius (a rational or floating-point number)\n") |
60 | 230 | storres | write(" debug debug mode (\"debug\", in any case)\n\n") |
61 | 230 | storres | sys.exit(2) |
62 | 230 | storres | # End usage. |
63 | 230 | storres | # |
64 | 230 | storres | argsCount = len(sys.argv) |
65 | 230 | storres | scriptName = os.path.basename(__file__) |
66 | 230 | storres | if argsCount < 5: |
67 | 230 | storres | usage() |
68 | 230 | storres | for index in xrange(1,argsCount): |
69 | 230 | storres | if index == 1: |
70 | 230 | storres | degree = int(sys.argv[index]) |
71 | 230 | storres | elif index == 2: |
72 | 230 | storres | alpha = int(sys.argv[index]) |
73 | 230 | storres | elif index == 3: |
74 | 230 | storres | htrn = int(eval(sys.argv[index])) |
75 | 230 | storres | elif index == 4: |
76 | 230 | storres | try: |
77 | 230 | storres | intervalCenter = QQ(sage_eval(sys.argv[index])) |
78 | 230 | storres | except: |
79 | 230 | storres | intervalCenter = RRR(sys.argv[index]) |
80 | 230 | storres | intervalCenter = RRR(intervalCenter) |
81 | 230 | storres | elif index == 5: |
82 | 230 | storres | try: |
83 | 230 | storres | intervalRadius = QQ(sage_eval(sys.argv[index])) |
84 | 230 | storres | except: |
85 | 230 | storres | intervalRadius = RRR(sys.argv[index]) |
86 | 230 | storres | intervalRadius = RRR(intervalRadius) |
87 | 230 | storres | elif index == 6: |
88 | 230 | storres | debugMode = sys.argv[index].upper() |
89 | 230 | storres | debugMode = (debugMode == "DEBUG") |
90 | 230 | storres | # Done with command line arguments collection. |
91 | 230 | storres | # |
92 | 230 | storres | ## Debug printing |
93 | 230 | storres | print "degree :", degree |
94 | 230 | storres | print "alpha :", alpha |
95 | 230 | storres | print "htrn :", htrn |
96 | 230 | storres | print "interval center:", intervalCenter.n(prec=10).str(truncate=False) |
97 | 230 | storres | print "interval radius:", intervalRadius.log2().n(prec=6).str(truncate=False) |
98 | 230 | storres | print "debug mode :", debugMode |
99 | 230 | storres | |
100 | 230 | storres | # |
101 | 230 | storres | ## Set the terminal window title. |
102 | 230 | storres | terminalWindowTitle = ['stt', str(degree), str(alpha), str(htrn), |
103 | 230 | storres | intervalCenter.n(prec=10).str(truncate=False), |
104 | 230 | storres | intervalRadius.log2().n(prec=6).str(truncate=False)] |
105 | 230 | storres | call(terminalWindowTitle) |
106 | 230 | storres | # |
107 | 230 | storres | srs_run_SLZ_v05(inputFunction=func, |
108 | 230 | storres | inputLowerBound = intervalCenter - intervalRadius, |
109 | 230 | storres | inputUpperBound = intervalCenter + intervalRadius, |
110 | 230 | storres | alpha = alpha, |
111 | 230 | storres | degree = degree, |
112 | 230 | storres | precision = precision, |
113 | 230 | storres | emin = emin, |
114 | 230 | storres | emax = emax, |
115 | 230 | storres | targetHardnessToRound = htrn, |
116 | 230 | storres | debug = debugMode) |