Révision 230
pobysoPythonSage/src/pobyso.py (revision 230) | ||
---|---|---|
81 | 81 |
SOLLYA_BASE_FUNC_TANH, |
82 | 82 |
SOLLYA_BASE_FUNC_TRIPLEDOUBLE) = map(int,xrange(44)) |
83 | 83 |
print "\nSuperficial pobyso check..." |
84 |
print "First constant - SOLLYA_BASE_FUNC_ABS: ", SOLLYA_BASE_FUNC_ABS |
|
85 |
print "Last constant - SOLLYA_BASE_FUNC_TRIPLEDOUBLE: ", SOLLYA_BASE_FUNC_TRIPLEDOUBLE |
|
84 |
#print "First constant - SOLLYA_BASE_FUNC_ABS: ", SOLLYA_BASE_FUNC_ABS
|
|
85 |
#print "Last constant - SOLLYA_BASE_FUNC_TRIPLEDOUBLE: ", SOLLYA_BASE_FUNC_TRIPLEDOUBLE
|
|
86 | 86 |
|
87 | 87 |
pobyso_max_arity = 9 |
88 | 88 |
|
... | ... | |
1988 | 1988 |
# There is no simple str() method defined for p's class. |
1989 | 1989 |
return(p.__str__()) |
1990 | 1990 |
# |
1991 |
print pobyso_get_prec() |
|
1991 |
#print pobyso_get_prec()
|
|
1992 | 1992 |
pobyso_set_prec(165) |
1993 |
print pobyso_get_prec() |
|
1994 |
a=100 |
|
1995 |
print type(a) |
|
1996 |
id(a) |
|
1997 |
print "Max arity: ", pobyso_max_arity |
|
1998 |
print "Function tripleDouble (43) as a string: ", pobyso_function_type_as_string(43) |
|
1999 |
print "Function None (44) as a string: ", pobyso_function_type_as_string(44) |
|
1993 |
#print pobyso_get_prec()
|
|
1994 |
#a=100
|
|
1995 |
#print type(a)
|
|
1996 |
#id(a)
|
|
1997 |
#print "Max arity: ", pobyso_max_arity
|
|
1998 |
#print "Function tripleDouble (43) as a string: ", pobyso_function_type_as_string(43)
|
|
1999 |
#print "Function None (44) as a string: ", pobyso_function_type_as_string(44)
|
|
2000 | 2000 |
print "...Pobyso check done" |
pobysoPythonSage/src/sollya_lib.sage (revision 230) | ||
---|---|---|
178 | 178 |
sollya |
179 | 179 |
sollya.sollya_lib_init(None) |
180 | 180 |
print "\nSuperficial Sollya library check..." |
181 |
print sollya.sollya_lib_get_free_variable_name() |
|
181 |
|
|
182 |
#print sollya.sollya_lib_get_free_variable_name() |
|
182 | 183 |
sollyaExp = sollya_lib_parse_string("exp(x)") |
183 |
retc = sollya_lib_autoprint(sollyaExp, None) |
|
184 |
#retc = sollya_lib_autoprint(sollyaExp, None)
|
|
184 | 185 |
arg = sollya_lib_constant_from_int(int(1)) |
185 |
print "Type of sollya_obj_t: ",type(arg), "Value: ", arg |
|
186 |
#print "Type of sollya_obj_t: ",type(arg), "Value: ", arg
|
|
186 | 187 |
res = sollya_lib_evaluate(sollyaExp, arg) |
187 |
retc = sollya_lib_autoprint(res, None) |
|
188 |
#retc = sollya_lib_autoprint(res, None)
|
|
188 | 189 |
retc = sollya_lib_get_prec(None) |
189 | 190 |
a = c_int(0) |
190 | 191 |
sollya_lib_get_constant_as_int(byref(a), retc) |
191 |
print "Precision : ", a.value |
|
192 |
print "Address of a.value ", addressof(a) |
|
193 |
sollya_lib_close(None) |
|
192 |
b = a.value |
|
193 |
#print "Precision : ", a.value |
|
194 |
#print "Address of a.value ", addressof(a) |
|
195 |
#sollya_lib_close(None) |
|
194 | 196 |
print "...Sollya library check done." |
195 | 197 |
# |
196 | 198 |
# |
pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 230) | ||
---|---|---|
858 | 858 |
sollya_lib_clear_obj(ftpSo) |
859 | 859 |
sollya_lib_clear_obj(approxAccurSo) |
860 | 860 |
if sollyaPrecChangedSa: |
861 |
pobyso_set_prec_so_so(initialSollyaPrecSa)
|
|
862 |
sollya_lib_clear_obj(initialSollyaPrecSa)
|
|
861 |
pobyso_set_prec_so_so(initialSollyaPrecSo)
|
|
862 |
sollya_lib_clear_obj(initialSollyaPrecSo)
|
|
863 | 863 |
if debug: |
864 | 864 |
print "1: ", ; pobyso_autoprint(roundedPolySo) |
865 | 865 |
print "2: ", ; pobyso_autoprint(currentRangeSo) |
pobysoPythonSage/src/sageSLZ/runSLZ-05-06-02.sage (revision 230) | ||
---|---|---|
42 | 42 |
emin = -16382, |
43 | 43 |
emax = 16383, |
44 | 44 |
targetHardnessToRound = precision * 2, |
45 |
debug = False)
|
|
45 |
debug = True)
|
|
46 | 46 |
# |
47 | 47 |
""" |
48 | 48 |
srs_run_SLZ_v01(inputFunction=func, |
pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage (revision 230) | ||
---|---|---|
2610 | 2610 |
lb, |
2611 | 2611 |
ub, |
2612 | 2612 |
polyApproxAccur) |
2613 |
if debug: |
|
2614 |
print "Approximation polynomial computed." |
|
2613 | 2615 |
if prceSo is None: |
2614 | 2616 |
raise Exception("Could not compute an approximation polynomial.") |
2615 | 2617 |
### Convert back the data into Sage space. |
... | ... | |
2724 | 2726 |
# End if debug |
2725 | 2727 |
reductionTime = cputime() |
2726 | 2728 |
#### Compute the reduced polynomials. |
2729 |
print "Starting reduction..." |
|
2727 | 2730 |
ccReducedPolynomialsList = \ |
2728 | 2731 |
slz_compute_coppersmith_reduced_polynomials(intIntP, |
2729 | 2732 |
alpha, |
2730 | 2733 |
N, |
2731 | 2734 |
iBound, |
2732 | 2735 |
tBound) |
2736 |
print "...reduction accomplished in", cputime(reductionTime), "s." |
|
2733 | 2737 |
if ccReducedPolynomialsList is None: |
2734 | 2738 |
raise Exception("Reduction failed.") |
2735 | 2739 |
reductionsFullTime += cputime(reductionTime) |
pobysoPythonSage/src/sageSLZ/runSLZ-113.sage (revision 230) | ||
---|---|---|
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 |
|
|
0 | 118 |
Formats disponibles : Unified diff