intervals 0.3.56
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.txt +1 -0
- data/ext/crlibm/AUTHORS +2 -0
- data/ext/crlibm/COPYING +504 -0
- data/ext/crlibm/ChangeLog +80 -0
- data/ext/crlibm/INSTALL +182 -0
- data/ext/crlibm/Makefile.am +84 -0
- data/ext/crlibm/Makefile.in +530 -0
- data/ext/crlibm/NEWS +0 -0
- data/ext/crlibm/README +31 -0
- data/ext/crlibm/TODO +47 -0
- data/ext/crlibm/VERSION +1 -0
- data/ext/crlibm/aclocal.m4 +989 -0
- data/ext/crlibm/atan-itanium.c +846 -0
- data/ext/crlibm/atan-pentium.c +261 -0
- data/ext/crlibm/atan_accurate.c +244 -0
- data/ext/crlibm/atan_accurate.h +191 -0
- data/ext/crlibm/atan_fast.c +324 -0
- data/ext/crlibm/atan_fast.h +678 -0
- data/ext/crlibm/config.guess +1461 -0
- data/ext/crlibm/config.sub +1566 -0
- data/ext/crlibm/configure +7517 -0
- data/ext/crlibm/configure.ac +364 -0
- data/ext/crlibm/crlibm.h +125 -0
- data/ext/crlibm/crlibm_config.h +149 -0
- data/ext/crlibm/crlibm_config.h.in +148 -0
- data/ext/crlibm/crlibm_private.c +293 -0
- data/ext/crlibm/crlibm_private.h +658 -0
- data/ext/crlibm/csh_fast.c +631 -0
- data/ext/crlibm/csh_fast.h +771 -0
- data/ext/crlibm/double-extended.h +496 -0
- data/ext/crlibm/exp-td.c +962 -0
- data/ext/crlibm/exp-td.h +685 -0
- data/ext/crlibm/exp_accurate.c +197 -0
- data/ext/crlibm/exp_accurate.h +85 -0
- data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
- data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
- data/ext/crlibm/gappa/log-de.gappa +81 -0
- data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
- data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
- data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
- data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
- data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
- data/ext/crlibm/gappa/log-td.gappa +156 -0
- data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
- data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
- data/ext/crlibm/install-sh +269 -0
- data/ext/crlibm/log-de.c +431 -0
- data/ext/crlibm/log-de.h +732 -0
- data/ext/crlibm/log-td.c +852 -0
- data/ext/crlibm/log-td.h +819 -0
- data/ext/crlibm/log10-td.c +906 -0
- data/ext/crlibm/log10-td.h +823 -0
- data/ext/crlibm/log2-td.c +935 -0
- data/ext/crlibm/log2-td.h +821 -0
- data/ext/crlibm/maple/atan.mpl +359 -0
- data/ext/crlibm/maple/common-procedures.mpl +997 -0
- data/ext/crlibm/maple/csh.mpl +446 -0
- data/ext/crlibm/maple/double-extended.mpl +151 -0
- data/ext/crlibm/maple/exp-td.mpl +195 -0
- data/ext/crlibm/maple/log-de.mpl +243 -0
- data/ext/crlibm/maple/log-td.mpl +316 -0
- data/ext/crlibm/maple/log10-td.mpl +345 -0
- data/ext/crlibm/maple/log2-td.mpl +334 -0
- data/ext/crlibm/maple/trigo.mpl +728 -0
- data/ext/crlibm/maple/triple-double.mpl +58 -0
- data/ext/crlibm/missing +198 -0
- data/ext/crlibm/mkinstalldirs +40 -0
- data/ext/crlibm/rem_pio2_accurate.c +219 -0
- data/ext/crlibm/rem_pio2_accurate.h +53 -0
- data/ext/crlibm/scs_lib/AUTHORS +3 -0
- data/ext/crlibm/scs_lib/COPYING +504 -0
- data/ext/crlibm/scs_lib/ChangeLog +16 -0
- data/ext/crlibm/scs_lib/INSTALL +215 -0
- data/ext/crlibm/scs_lib/Makefile.am +18 -0
- data/ext/crlibm/scs_lib/Makefile.in +328 -0
- data/ext/crlibm/scs_lib/NEWS +0 -0
- data/ext/crlibm/scs_lib/README +9 -0
- data/ext/crlibm/scs_lib/TODO +4 -0
- data/ext/crlibm/scs_lib/addition_scs.c +623 -0
- data/ext/crlibm/scs_lib/config.guess +1461 -0
- data/ext/crlibm/scs_lib/config.sub +1566 -0
- data/ext/crlibm/scs_lib/configure +6226 -0
- data/ext/crlibm/scs_lib/division_scs.c +110 -0
- data/ext/crlibm/scs_lib/double2scs.c +174 -0
- data/ext/crlibm/scs_lib/install-sh +269 -0
- data/ext/crlibm/scs_lib/missing +198 -0
- data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
- data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
- data/ext/crlibm/scs_lib/poly_fct.c +112 -0
- data/ext/crlibm/scs_lib/print_scs.c +73 -0
- data/ext/crlibm/scs_lib/rand_scs.c +63 -0
- data/ext/crlibm/scs_lib/scs.h +353 -0
- data/ext/crlibm/scs_lib/scs2double.c +391 -0
- data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
- data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
- data/ext/crlibm/scs_lib/scs_private.c +23 -0
- data/ext/crlibm/scs_lib/scs_private.h +133 -0
- data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
- data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
- data/ext/crlibm/scs_lib/zero_scs.c +52 -0
- data/ext/crlibm/stamp-h.in +1 -0
- data/ext/crlibm/tests/Makefile.am +43 -0
- data/ext/crlibm/tests/Makefile.in +396 -0
- data/ext/crlibm/tests/blind_test.c +148 -0
- data/ext/crlibm/tests/generate_test_vectors.c +258 -0
- data/ext/crlibm/tests/soak_test.c +334 -0
- data/ext/crlibm/tests/test_common.c +627 -0
- data/ext/crlibm/tests/test_common.h +28 -0
- data/ext/crlibm/tests/test_perf.c +570 -0
- data/ext/crlibm/tests/test_val.c +249 -0
- data/ext/crlibm/trigo_accurate.c +500 -0
- data/ext/crlibm/trigo_accurate.h +331 -0
- data/ext/crlibm/trigo_fast.c +1219 -0
- data/ext/crlibm/trigo_fast.h +639 -0
- data/ext/crlibm/triple-double.h +878 -0
- data/ext/extconf.rb +31 -0
- data/ext/fpu.c +107 -0
- data/ext/jamis-mod.rb +591 -0
- data/lib/fpu.rb +287 -0
- data/lib/interval.rb +1170 -0
- data/lib/intervals.rb +212 -0
- data/lib/struct_float.rb +133 -0
- data/test/data_atan.txt +360 -0
- data/test/data_cos.txt +346 -0
- data/test/data_cosh.txt +3322 -0
- data/test/data_exp.txt +3322 -0
- data/test/data_log.txt +141 -0
- data/test/data_sin.txt +140 -0
- data/test/data_sinh.txt +3322 -0
- data/test/data_tan.txt +342 -0
- metadata +186 -0
@@ -0,0 +1,195 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# This file is part of the crlibm library, and is distributed under
|
3
|
+
# the LGPL.
|
4
|
+
# To use:
|
5
|
+
# restart; read "exp-td.mpl";
|
6
|
+
Digits := 120:
|
7
|
+
|
8
|
+
interface(quiet=true):
|
9
|
+
|
10
|
+
read "common-procedures.mpl":
|
11
|
+
read "triple-double.mpl":
|
12
|
+
mkdir("TEMPEXP"):
|
13
|
+
|
14
|
+
L := 12:
|
15
|
+
|
16
|
+
printf(" memory requirement for L = %d and two triple-double tables: %d bytes\n",L,48*2^(ceil(L/2)));
|
17
|
+
|
18
|
+
rmax := log(2) / (2^(L+1)):
|
19
|
+
|
20
|
+
printf(" maximal absolute value for rmax = 2^(%f)\n",log[2](rmax)):
|
21
|
+
|
22
|
+
|
23
|
+
MsLog2Div2L := evalf(-log(2)/(2^L)):
|
24
|
+
|
25
|
+
msLog2Div2Lh, msLog2Div2Lm, msLog2Div2Ll := hi_mi_lo(MsLog2Div2L):
|
26
|
+
|
27
|
+
epsMsLog2Div2L := evalf(((msLog2Div2Lh + msLog2Div2Lm + msLog2Div2Ll) - MsLog2Div2L)/MsLog2Div2L):
|
28
|
+
|
29
|
+
printf(" error made by storing MsLog2Div2L as a triple-double: 2^(%f)\n",log[2](epsMsLog2Div2L)):
|
30
|
+
|
31
|
+
|
32
|
+
log2InvMult2L := nearest(2^L / (log(2))):
|
33
|
+
|
34
|
+
shiftConst := 2^(52) + 2^(51):
|
35
|
+
|
36
|
+
indexmask1 := 2^(L/2) - 1:
|
37
|
+
indexmask2 := indexmask1 * 2^(L/2):
|
38
|
+
|
39
|
+
largest := 2^(1023) * ((2^(53) - 1) / 2^(52)):
|
40
|
+
smallest := 2^(-1023) * 1 * 2^(-51):
|
41
|
+
|
42
|
+
overflowbound := nearest(log(largest)):
|
43
|
+
|
44
|
+
overflowboundHex := ieeehexa(overflowbound):
|
45
|
+
overflowSimplebound := convert(overflowboundHex[1],decimal,hex):
|
46
|
+
|
47
|
+
underflowbound := nearest(log(2^(-1075))):
|
48
|
+
|
49
|
+
denormbound := nearest(log(2^(-1022) * 1)):
|
50
|
+
|
51
|
+
|
52
|
+
overUnderflowboundHex := ieeehexa(min(abs(underflowbound),min(abs(overflowbound),abs(denormbound)))):
|
53
|
+
overUnderflowSimplebound := convert(overUnderflowboundHex[1],decimal,hex):
|
54
|
+
|
55
|
+
twoPowerM1000 := 2^(-1000):
|
56
|
+
twoPower1000 := 2^(1000):
|
57
|
+
|
58
|
+
twoM52 := 2^(-52):
|
59
|
+
mTwoM53 := - 2^(-53):
|
60
|
+
|
61
|
+
for i from 0 to 2^(L/2) - 1 do
|
62
|
+
twoPowerIndex1hi[i], twoPowerIndex1mi[i], twoPowerIndex1lo[i] := hi_mi_lo(evalf(2^(i/(2^L)))):
|
63
|
+
twoPowerIndex2hi[i], twoPowerIndex2mi[i], twoPowerIndex2lo[i] := hi_mi_lo(evalf(2^(i/(2^(L/2))))):
|
64
|
+
od:
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
PolyDegreeQuick:=4:
|
69
|
+
printf(" degree of the polynomial used in the quick phase is %d\n",PolyDegreeQuick);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
polyQuick:= poly_exact(1 + x + 0.5*x^2 + x^3 * (numapprox[minimax](((exp(x) - (1 + x + 0.5*x^2))/x^3),
|
74
|
+
x=-rmax..rmax, [PolyDegreeQuick-3,0], 1 , 'deltaApprox'))):
|
75
|
+
|
76
|
+
epsilonApproxQuick := numapprox[infnorm]( (polyQuick/exp(x))-1, x=-rmax..rmax):
|
77
|
+
printf(" approximation rel error for the quick phase is 2^(%2f)\n", log2(epsilonApproxQuick) ) :
|
78
|
+
deltaApproxQuick := numapprox[infnorm]( polyQuick-exp(x), x=-rmax..rmax):
|
79
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxQuick) ) :
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
PolyDegreeAccurate:=7:
|
84
|
+
|
85
|
+
printf(" degree of the polynomial used in the accurate phase is %d\n",PolyDegreeAccurate):
|
86
|
+
|
87
|
+
DDNumberAccu:=5:
|
88
|
+
|
89
|
+
|
90
|
+
printf(" number of double doubles used for the coefficients is %d\n",DDNumberAccu):
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
polyAccurate:= poly_exact2(1 + x + 0.5*x^2 + x^3 * (numapprox[minimax](((exp(x) - (1 + x + 0.5*x^2))/x^3),
|
95
|
+
x=-rmax..rmax, [PolyDegreeAccurate-3,0], 1 , 'deltaApprox')),
|
96
|
+
DDNumberAccu):
|
97
|
+
|
98
|
+
|
99
|
+
epsilonApproxAccurate := numapprox[infnorm]( (polyAccurate/exp(x))-1, x=-rmax..rmax):
|
100
|
+
printf(" approximation rel error for the accurate phase is 2^(%2f)\n", log2(epsilonApproxAccurate) ) :
|
101
|
+
deltaApproxAccurate := numapprox[infnorm]( polyAccurate-exp(x), x=-rmax..rmax):
|
102
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxAccurate) ) :
|
103
|
+
|
104
|
+
|
105
|
+
epsilon_quick := 2^(-64): # The Gappa proof will show this bound
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
#-------------------------------------------------------------------
|
112
|
+
# Output
|
113
|
+
|
114
|
+
filename:="TEMPEXP/exp-td.h":
|
115
|
+
fd:=fopen(filename, WRITE, TEXT):
|
116
|
+
|
117
|
+
fprintf(fd, "#include \"crlibm.h\"\n#include \"crlibm_private.h\"\n"):
|
118
|
+
|
119
|
+
fprintf(fd, "\n/*File generated by maple/exp-td.mpl*/\n"):
|
120
|
+
|
121
|
+
fprintf(fd, "\#define L %d\n",L):
|
122
|
+
fprintf(fd, "\#define LHALF %d\n",L/2):
|
123
|
+
fprintf(fd, "\#define log2InvMult2L %1.50e\n",log2InvMult2L):
|
124
|
+
fprintf(fd, "\#define msLog2Div2Lh %1.50e\n",msLog2Div2Lh):
|
125
|
+
fprintf(fd, "\#define msLog2Div2Lm %1.50e\n",msLog2Div2Lm):
|
126
|
+
fprintf(fd, "\#define msLog2Div2Ll %1.50e\n",msLog2Div2Ll):
|
127
|
+
fprintf(fd, "\#define shiftConst %1.50e\n",shiftConst):
|
128
|
+
fprintf(fd, "\#define INDEXMASK1 0x%08x\n",indexmask1):
|
129
|
+
fprintf(fd, "\#define INDEXMASK2 0x%08x\n",indexmask2):
|
130
|
+
fprintf(fd, "\#define OVRUDRFLWSMPLBOUND 0x%08x\n",overUnderflowSimplebound):
|
131
|
+
fprintf(fd, "\#define OVRFLWBOUND %1.50e\n",overflowbound):
|
132
|
+
fprintf(fd, "\#define LARGEST %1.50e\n",largest):
|
133
|
+
fprintf(fd, "\#define SMALLEST %1.50e\n",smallest):
|
134
|
+
fprintf(fd, "\#define DENORMBOUND %1.50e\n",denormbound):
|
135
|
+
fprintf(fd, "\#define UNDERFLWBOUND %1.50e\n",underflowbound):
|
136
|
+
fprintf(fd, "\#define twoPowerM1000 %1.50e\n",twoPowerM1000):
|
137
|
+
fprintf(fd, "\#define twoPower1000 %1.50e\n",twoPower1000):
|
138
|
+
fprintf(fd, "\#define ROUNDCST %1.50e\n", compute_rn_constant(epsilon_quick)):
|
139
|
+
fprintf(fd, "\#define RDROUNDCST %1.50e\n", epsilon_quick):
|
140
|
+
fprintf(fd, "\#define twoM52 %1.50e\n", twoM52):
|
141
|
+
fprintf(fd, "\#define mTwoM53 %1.50e\n", mTwoM53):
|
142
|
+
|
143
|
+
fprintf(fd,"\n\n"):
|
144
|
+
|
145
|
+
for i from 3 to PolyDegreeQuick do
|
146
|
+
fprintf(fd, "\#define c%d %1.50e\n",i,coeff(polyQuick,x,i)):
|
147
|
+
od:
|
148
|
+
|
149
|
+
|
150
|
+
for i from 3 to DDNumberAccu-1 do
|
151
|
+
(hi,lo) := hi_lo(coeff(polyAccurate,x,i)):
|
152
|
+
fprintf(fd, "\#define accPolyC%dh %1.50e\n",i,hi):
|
153
|
+
fprintf(fd, "\#define accPolyC%dl %1.50e\n",i,lo):
|
154
|
+
od:
|
155
|
+
|
156
|
+
for i from DDNumberAccu to PolyDegreeAccurate do
|
157
|
+
fprintf(fd, "\#define accPolyC%d %1.50e\n",i,coeff(polyAccurate,x,i)):
|
158
|
+
od:
|
159
|
+
|
160
|
+
fprintf(fd,"\n\n"):
|
161
|
+
|
162
|
+
# Print the tables
|
163
|
+
fprintf(fd, "typedef struct tPi_t_tag {double hi; double mi; double lo;} tPi_t; \n"):
|
164
|
+
fprintf(fd, "static const tPi_t twoPowerIndex1[%d] = {\n", 2^(L/2)):
|
165
|
+
for i from 0 to 2^(L/2)-1 do
|
166
|
+
fprintf(fd, " { \n"):
|
167
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex1hi[%d] */ \n", twoPowerIndex1hi[i], i):
|
168
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex1mi[%d] */ \n", twoPowerIndex1mi[i], i):
|
169
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex1lo[%d] */ \n", twoPowerIndex1lo[i], i):
|
170
|
+
fprintf(fd, " } "):
|
171
|
+
if(i<2^(L/2)-1) then fprintf(fd, ", \n"): fi
|
172
|
+
od:
|
173
|
+
fprintf(fd, "}; \n \n"):
|
174
|
+
fprintf(fd, "static const tPi_t twoPowerIndex2[%d] = {\n", 2^(L/2)):
|
175
|
+
for i from 0 to 2^(L/2)-1 do
|
176
|
+
fprintf(fd, " { \n"):
|
177
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex2hi[%d] */ \n", twoPowerIndex2hi[i], i):
|
178
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex2mi[%d] */ \n", twoPowerIndex2mi[i], i):
|
179
|
+
fprintf(fd, " %1.50e, /* twoPowerIndex2lo[%d] */ \n", twoPowerIndex2lo[i], i):
|
180
|
+
fprintf(fd, " } "):
|
181
|
+
if(i<2^(L/2)-1) then fprintf(fd, ", \n"): fi
|
182
|
+
od:
|
183
|
+
fprintf(fd, "}; \n \n"):
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
fprintf(fd, "\n\n"):
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
printf("----DONE---\n") :
|
194
|
+
|
195
|
+
|
@@ -0,0 +1,243 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# This file is part of the crlibm library, and is distributed under
|
3
|
+
# the LGPL.
|
4
|
+
# To use:
|
5
|
+
# restart; read "log-de.mpl";
|
6
|
+
Digits := 100:
|
7
|
+
|
8
|
+
interface(quiet=true):
|
9
|
+
|
10
|
+
read "common-procedures.mpl":
|
11
|
+
read "double-extended.mpl":
|
12
|
+
mkdir("TEMPLOG"):
|
13
|
+
|
14
|
+
|
15
|
+
log2h,log2l := hiloExt(log(2)):
|
16
|
+
|
17
|
+
|
18
|
+
L := 7: # number of bits used to address the table
|
19
|
+
|
20
|
+
MAXINDEX := round(2^L * (sqrt(2)-1)):
|
21
|
+
|
22
|
+
for i from 0 to MAXINDEX-1 do
|
23
|
+
center[i] := 1 + i*2^(-L): # center[i] in [1, 2[
|
24
|
+
# We want it to fit on 11 bits of mantissa
|
25
|
+
r[i] := round(evalf( (1/center[i]) * 2^(11)) ) / 2^(11) ;
|
26
|
+
|
27
|
+
od:
|
28
|
+
for i from MAXINDEX to 2^L do
|
29
|
+
# y has been divided by two, center[i] in [0.5, 1[
|
30
|
+
center[i]:=(1 + i*2^(-L)) / 2:
|
31
|
+
# We want it to fit on 11 bits of mantissa,
|
32
|
+
r[i] := round(evalf( (1/center[i]) * 2^(10)) ) / 2^(10) ;
|
33
|
+
od:
|
34
|
+
|
35
|
+
# Note that we go up to 2^L although the case 2^L is wrapped to zero
|
36
|
+
# in the C code. It could be important for zmax (but it turns out not).
|
37
|
+
|
38
|
+
for i from 0 to 2^L do
|
39
|
+
(logirh[i], logirl[i]) := hiloExt(-log(r[i])):
|
40
|
+
od:
|
41
|
+
|
42
|
+
#Computation of ZMax.
|
43
|
+
for i from 0 to MAXINDEX-1 do
|
44
|
+
_x := center[i] + 2^(-L-1) :
|
45
|
+
zmax[i] := (_x*r[i]-1) :
|
46
|
+
_x := center[i] - 2^(-L-1) :
|
47
|
+
zmin[i] := (_x*r[i]-1) :
|
48
|
+
od:
|
49
|
+
for i from MAXINDEX to 2^L do
|
50
|
+
_x := center[i] + 2^(-L-2) :
|
51
|
+
zmax[i] := (_x*r[i]-1) :
|
52
|
+
_x := center[i] - 2^(-L-2) :
|
53
|
+
zmin[i] := (_x*r[i]-1) :
|
54
|
+
od:
|
55
|
+
|
56
|
+
zmaxmax:=0:
|
57
|
+
zminmin:=0:
|
58
|
+
for i from 0 to 2^L do
|
59
|
+
if zmax[i] > zmaxmax then zmaxmax := zmax[i]: fi:
|
60
|
+
if zmin[i] < zminmin then zminmin := zmin[i]: fi:
|
61
|
+
od:
|
62
|
+
printf("zminmin = -2^(%2f) zmaxmax = 2^(%2f)\n", log2(-zminmin), log2(zmaxmax) ) :
|
63
|
+
|
64
|
+
|
65
|
+
PolyDegreeQuick:=7:
|
66
|
+
|
67
|
+
#Keep -zmaxmax..zmaxmax to keep c1=1, which is useful in the proof
|
68
|
+
polyQuick:= polyExact2Ext(x * numapprox[minimax]( log(1+x)/x, x=-zmaxmax..zmaxmax, [PolyDegreeQuick-1,0], 1 , 'deltaApprox'), 0):
|
69
|
+
|
70
|
+
epsilonApproxQuick := numapprox[infnorm]( 1-polyQuick/log(1+x), x=zminmin..zmaxmax):
|
71
|
+
printf(" approximation rel error for the quick phase is 2^(%2f)\n", log2(epsilonApproxQuick) ) :
|
72
|
+
deltaApproxQuick := numapprox[infnorm]( polyQuick-log(1+x), x=zminmin..zmaxmax):
|
73
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxQuick) ) :
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
PolyDegreeAccurate:=14:
|
78
|
+
|
79
|
+
printf("Computing the polynomial for accurate phase (this may take some time...)\n"):
|
80
|
+
pe:= x * numapprox[minimax]( log(1+x)/x, x=-zmaxmax..zmaxmax, [PolyDegreeAccurate-1,0], 1 , 'deltaApprox'):
|
81
|
+
|
82
|
+
|
83
|
+
MaxDegreeDDE:=8: #
|
84
|
+
|
85
|
+
polyAccurate := polyExact2Ext(pe, MaxDegreeDDE):
|
86
|
+
#deltaApprox := numapprox[infnorm](polyAccurate-log(1+x), x=-zmaxmax..zmaxmax):
|
87
|
+
epsilonApproxAccurate := numapprox[infnorm]( 1-polyAccurate/log(1+x), x=-zmaxmax..zmaxmax):
|
88
|
+
printf(" approximation error for the accurate phase is 2^(%2f)\n", log2(epsilonApproxAccurate) ) :
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
filename:="TEMPLOG/log-de.h":
|
94
|
+
fd:=fopen(filename, WRITE, TEXT):
|
95
|
+
|
96
|
+
fprintf(fd, "/*File generated by maple/log-de.mpl*/\n\n"):
|
97
|
+
|
98
|
+
fprintf(fd, "#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)\n\n"):
|
99
|
+
fprintf(fd, " /* Coefficients are read directly from the array thanks to the following macros */ \n"):
|
100
|
+
for i from PolyDegreeQuick to 1 by -1 do
|
101
|
+
fprintf(fd, "#define c%d c[%d]\n", i, PolyDegreeQuick-i):
|
102
|
+
od:
|
103
|
+
for i from PolyDegreeAccurate to 1 by -1 do
|
104
|
+
fprintf(fd, "#define c%dh ch[%d]\n", i, PolyDegreeAccurate-i):
|
105
|
+
od:
|
106
|
+
|
107
|
+
for i from MaxDegreeDDE-1 to 1 by -1 do
|
108
|
+
fprintf(fd, "#define c%dl cl[%d]\n", i, MaxDegreeDDE-1-i):
|
109
|
+
od:
|
110
|
+
fprintf(fd, "#define PREFETCH_POLY_ACCURATE \n"):
|
111
|
+
fprintf(fd, "\n#else /* not(defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)),\n assuming Itanium, otherwise we shouldn't be there */ \n\n"):
|
112
|
+
fprintf(fd, "#define PREFETCH_POLY_QUICK "):
|
113
|
+
for i from PolyDegreeQuick to 1 by -1 do
|
114
|
+
fprintf(fd, "c%d=c[%d]; ", i, PolyDegreeQuick-i):
|
115
|
+
od:
|
116
|
+
fprintf(fd, "\n#define PREFETCH_POLY_ACCURATE "):
|
117
|
+
for i from PolyDegreeAccurate to 1 by -1 do
|
118
|
+
fprintf(fd, "c%dh=ch[%d]; ", i, PolyDegreeAccurate-i):
|
119
|
+
if i mod 4 =0 then fprintf(fd, "\\\n "): fi:
|
120
|
+
od:
|
121
|
+
fprintf(fd, "\\\n "):
|
122
|
+
for i from MaxDegreeDDE-1 to 1 by -1 do
|
123
|
+
fprintf(fd, "c%dl=cl[%d]; ", i, MaxDegreeDDE-1-i):
|
124
|
+
od:
|
125
|
+
|
126
|
+
fprintf(fd, "\n#endif /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */ \n\n"):
|
127
|
+
|
128
|
+
# Various constants
|
129
|
+
fprintf(fd, "#define L %d\n", L):
|
130
|
+
fprintf(fd, "#define MAXINDEX %d\n", MAXINDEX):
|
131
|
+
fprintf(fd, "#define INDEXMASK %d\n", 2^L-1):
|
132
|
+
fprintf(fd, "static const long double log2h = %1.50eL ;\n", log2h):
|
133
|
+
fprintf(fd, "static const long double log2l = %1.50eL ;\n", log2l):
|
134
|
+
fprintf(fd, "static const long double two64 = %1.50eL ;\n", evalf(2^64)):
|
135
|
+
|
136
|
+
# The polynomials
|
137
|
+
# polynomial for quick phase
|
138
|
+
# for i from PolyDegreeQuick to 1 by -1 do
|
139
|
+
# fprintf(fd, "static const long double c%d = %1.50eL ;\n", i, coeff(polyQuick,x,i)):
|
140
|
+
# od:
|
141
|
+
fprintf(fd, "static const long double c[%d] = {\n",PolyDegreeQuick):
|
142
|
+
for i from PolyDegreeQuick to 1 by -1 do
|
143
|
+
fprintf(fd, " /* c%d = */ %1.50eL, \n", i, coeff(polyQuick,x,i)):
|
144
|
+
od:
|
145
|
+
fprintf(fd, "}; \n \n"):
|
146
|
+
|
147
|
+
# polynomial for accurate phase
|
148
|
+
# polynomial for accurate phase
|
149
|
+
fprintf(fd, "static const long double ch[%d] = {\n",PolyDegreeAccurate):
|
150
|
+
for i from PolyDegreeAccurate to 1 by -1 do
|
151
|
+
(ch, cl) := hiloExt(coeff(polyAccurate,x,i)):
|
152
|
+
fprintf(fd, " /* ch%d = */ %1.50eL, \n", i, ch):
|
153
|
+
od:
|
154
|
+
fprintf(fd, "}; \n \n"):
|
155
|
+
|
156
|
+
fprintf(fd, "static const long double cl[%d] = {\n", MaxDegreeDDE):
|
157
|
+
for i from MaxDegreeDDE-1 to 1 by -1 do
|
158
|
+
(ch, cl) := hiloExt(coeff(polyAccurate,x,i)):
|
159
|
+
fprintf(fd, " /* cl%d = */ %1.50eL, \n", i, cl):
|
160
|
+
od:
|
161
|
+
fprintf(fd, "}; \n \n"):
|
162
|
+
|
163
|
+
|
164
|
+
# The tables
|
165
|
+
|
166
|
+
|
167
|
+
fprintf(fd, "typedef struct rri_tag {float r; long double logirh; long double logirl; } rri ; \n"):
|
168
|
+
fprintf(fd, "static const rri argredtable[%d] = {\n", 2^L):
|
169
|
+
for i from 0 to 2^L-1 do
|
170
|
+
fprintf(fd, " { \n"):
|
171
|
+
fprintf(fd, " %1.50eL, /* r[%d] */ \n", r[i], i):
|
172
|
+
fprintf(fd, " %1.50eL, /* logirh[%d] */ \n", logirh[i], i):
|
173
|
+
fprintf(fd, " %1.50eL, /* logirl[%d] */ \n", logirl[i], i):
|
174
|
+
fprintf(fd, " } "):
|
175
|
+
if(i<2^L-1) then fprintf(fd, ", \n"): fi
|
176
|
+
od:
|
177
|
+
fprintf(fd, "}; \n \n"):
|
178
|
+
|
179
|
+
fclose(fd):
|
180
|
+
|
181
|
+
printf("\n\n************ DONE TEMPLOG/log-de.h ************\n");
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
for j from 0 to 2^L-1 do
|
189
|
+
filename:=cat("TEMPLOG/log-de_",j,".sed"):
|
190
|
+
fd:=fopen(filename, WRITE, TEXT):
|
191
|
+
fprintf(fd, " s/_log2h/%1.40e/g\n", log2h):
|
192
|
+
fprintf(fd, " s/_log2l/%1.40e/g\n", log2l):
|
193
|
+
fprintf(fd, " s/_r/%1.40e/g\n", r[j]):
|
194
|
+
fprintf(fd, " s/_logirh/%1.40e/g\n", logirh[j]):
|
195
|
+
fprintf(fd, " s/_logirl/%1.40e/g\n", logirl[j]):
|
196
|
+
fprintf(fd, " s/_zmin/%1.40e/g\n", zmin[j]):
|
197
|
+
fprintf(fd, " s/_zmax/%1.40e/g\n", zmax[j]):
|
198
|
+
for i from PolyDegreeQuick to 1 by -1 do
|
199
|
+
fprintf(fd, " s/_c%d/%1.40e/g\n", i, coeff(polyQuick,x,i)):
|
200
|
+
od:
|
201
|
+
fprintf(fd, " s/_deltaApproxQuick/%1.40e/g\n", deltaApproxQuick):
|
202
|
+
fprintf(fd, " s/_epsilonApproxQuick/%1.40e/g\n", epsilonApproxQuick):
|
203
|
+
fclose(fd):
|
204
|
+
od:
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
printf("\n\n************ DONE TEMPLOG/log-de*.sed ************\n");
|
209
|
+
|
210
|
+
# A shell script to use them
|
211
|
+
filename:="TEMPLOG/run-log-de-proof.sh":
|
212
|
+
fd:=fopen(filename, WRITE, TEXT):
|
213
|
+
fprintf(fd, "#!/bin/sh\n"):
|
214
|
+
fprintf(fd, "# You probably need to edit the path to the gappa executable\n"):
|
215
|
+
fprintf(fd, "GAPPA=~/gappa/src/gappa\n"):
|
216
|
+
fprintf(fd, "# Test all the possible table value for E=1\n"):
|
217
|
+
fprintf(fd, "for num in `seq 0 %d`; do\n", 2^L-1):
|
218
|
+
fprintf(fd, " echo $num, E=1:\n"):
|
219
|
+
fprintf(fd, " sed -f TEMPLOG/log-de_$num.sed log-de.gappa | $GAPPA > /dev/null\n"):
|
220
|
+
fprintf(fd, " echo\n"):
|
221
|
+
fprintf(fd, "done\n"):
|
222
|
+
fprintf(fd, "# For the case E=0 we first handle the cases 0 and %d using log-de-E0-logir0.gappa\n", 2^L):
|
223
|
+
fprintf(fd, "echo 0 and %d, E=0:\n", 2^L):
|
224
|
+
fprintf(fd, "sed -f TEMPLOG/log-de_0.sed log-de-E0-logir0.gappa | $GAPPA > /dev/null\n"):
|
225
|
+
fprintf(fd, "# then the other cases where logirh <> 0\n"):
|
226
|
+
fprintf(fd, "for num in `seq 1 %d`; do\n", 2^L-1):
|
227
|
+
fprintf(fd, " echo $num, E=0:\n"):
|
228
|
+
fprintf(fd, " sed -f TEMPLOG/log-de_$num.sed log-de-E0.gappa | $GAPPA > /dev/null\n"):
|
229
|
+
fprintf(fd, " echo\n"):
|
230
|
+
fprintf(fd, "done\n"):
|
231
|
+
fclose(fd):
|
232
|
+
|
233
|
+
printf("************ DONE TEMPLOG/run-log-de-proof.sh ************\n"):
|
234
|
+
printf("Now you should run\n"):
|
235
|
+
printf(" sh TEMPLOG/run-log-de-proof.sh 2>TEMPLOG/Gappa.out\n"):
|
236
|
+
printf(" (You probably need to edit the path to the gappa executable within TEMPLOG/run-log-de-proof.sh)\n"):
|
237
|
+
printf("Then look at TEMPLOG/Gappa.out. It shouldn't contain 'no proof'.\nThis means that everything is OK.\n\n"):
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
printf("----DONE---\n") :
|
243
|
+
|