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