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,316 @@
|
|
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 := 120:
|
7
|
+
|
8
|
+
interface(quiet=true):
|
9
|
+
|
10
|
+
read "common-procedures.mpl":
|
11
|
+
read "triple-double.mpl":
|
12
|
+
mkdir("TEMPLOG"):
|
13
|
+
|
14
|
+
|
15
|
+
# We want log2h + log2m + log2l + delta = log(2) such that
|
16
|
+
# log2h and log2m have at least 11 trailing zeros
|
17
|
+
# in order to have an exact multiplication with E, which is lower than 1024 in
|
18
|
+
# magnitude
|
19
|
+
# The resting accuracy is enough for both quick and accurate phases.
|
20
|
+
|
21
|
+
log2acc := log(2):
|
22
|
+
log2h := round(log2acc * 2**(floor(-log[2](abs(log2acc))) + (53 - 11))) / 2**(floor(-log[2](abs(log2acc))) + (53 - 11)):
|
23
|
+
log2m := round((log2acc - log2h) * 2**(floor(-log[2](abs((log2acc - log2h)))) + (53 - 11))) / 2**(floor(-log[2](abs((log2acc - log2h)))) + (53 - 11)):
|
24
|
+
log2l := log2acc - (log2h + log2m):
|
25
|
+
|
26
|
+
|
27
|
+
L := 7: # number of bits used to address the table
|
28
|
+
|
29
|
+
MAXINDEX := round(2^L * (sqrt(2)-1)):
|
30
|
+
|
31
|
+
for i from 0 to MAXINDEX-1 do
|
32
|
+
center[i] := 1 + i*2^(-L): # center[i] in [1, 2[
|
33
|
+
t := evalf(1/center[i]):
|
34
|
+
r[i] := round(t * 2**(floor(-log[2](abs(t))) + 23)) / 2**(floor(-log[2](abs(t))) + 23):
|
35
|
+
(logih[i], logim[i], logil[i]) := hi_mi_lo(evalf(-log(r[i]))):
|
36
|
+
od:
|
37
|
+
for i from MAXINDEX to 2^L do
|
38
|
+
# y has been divided by two, center[i] in [0.5, 1[
|
39
|
+
center[i]:=(1 + i*2^(-L)) / 2:
|
40
|
+
t := evalf(1/center[i]):
|
41
|
+
r[i] := round(t * 2**(floor(-log[2](abs(t))) + 23)) / 2**(floor(-log[2](abs(t))) + 23):
|
42
|
+
(logih[i], logim[i], logil[i]) := hi_mi_lo(evalf(-log(r[i]))):
|
43
|
+
od:
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#Computation of ZMax.
|
49
|
+
for i from 0 to MAXINDEX-1 do
|
50
|
+
__x := center[i] + 2^(-L-1) :
|
51
|
+
zmax[i] := (__x*r[i]-1) :
|
52
|
+
__x := center[i] - 2^(-L-1) :
|
53
|
+
zmin[i] := (__x*r[i]-1) :
|
54
|
+
od:
|
55
|
+
for i from MAXINDEX to 2^L do
|
56
|
+
__x := center[i] + 2^(-L-2) :
|
57
|
+
zmax[i] := (__x*r[i]-1) :
|
58
|
+
__x := center[i] - 2^(-L-2) :
|
59
|
+
zmin[i] := (__x*r[i]-1) :
|
60
|
+
od:
|
61
|
+
|
62
|
+
zmaxmax:=0:
|
63
|
+
zminmin:=0:
|
64
|
+
for i from 0 to 2^L do
|
65
|
+
tabulated_value := logih[i] + logim[i] + logil[i]:
|
66
|
+
poly_approx_min := evalf(log(1+zmin[i])):
|
67
|
+
poly_approx_max := evalf(log(1+zmax[i])):
|
68
|
+
|
69
|
+
# Test if we have a case where we cancellate a lot
|
70
|
+
# i.e. the polynomial approximation value is greater than half the tabulated value
|
71
|
+
# the tabulated value is not exactly zero and we are of opposite sign
|
72
|
+
|
73
|
+
if ((abs(poly_approx_min) > 0.75*abs(tabulated_value)) and (tabulated_value <> 0.0) and (poly_approx_min * tabulated_value < 0)) then
|
74
|
+
printf("Polynomial approximation is greater in magnitude in zmin[%d] than half the tabluated value\n",i):
|
75
|
+
|
76
|
+
printf("The tabulated value is %1.50e\n",tabulated_value):
|
77
|
+
if (tabulated_value <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(tabulated_value)))) fi:
|
78
|
+
printf("The value of polynomial in zmin[%d] is %1.50e\n",i,poly_approx_min):
|
79
|
+
if (poly_approx_min <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(poly_approx_min)))) fi:
|
80
|
+
|
81
|
+
summe := poly_approx_min + tabulated_value:
|
82
|
+
printf("The exponent of the sum of both is %d\n",floor(log2(abs(summe)))):
|
83
|
+
|
84
|
+
|
85
|
+
fi:
|
86
|
+
|
87
|
+
if ((abs(poly_approx_max) > 0.75*abs(tabulated_value)) and (tabulated_value <> 0.0) and (poly_approx_max * tabulated_value <0)) then
|
88
|
+
printf("Polynomial approximation is greater in magnitude in zmax[%d] than half the tabluated value\n",i):
|
89
|
+
|
90
|
+
printf("The tabulated value is %1.50e\n",tabulated_value):
|
91
|
+
if (tabulated_value <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(tabulated_value)))) fi:
|
92
|
+
printf("The value of polynomial in zmax[%d] is %1.50e\n",i,poly_approx_max):
|
93
|
+
if (poly_approx_max <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(poly_approx_max)))) fi:
|
94
|
+
|
95
|
+
summe := poly_approx_max + tabulated_value:
|
96
|
+
printf("The exponent of the sum of both is %d\n",floor(log2(abs(summe)))):
|
97
|
+
|
98
|
+
|
99
|
+
fi:
|
100
|
+
|
101
|
+
|
102
|
+
if zmax[i] > zmaxmax then zmaxmax := zmax[i]: fi:
|
103
|
+
if zmin[i] < zminmin then zminmin := zmin[i]: fi:
|
104
|
+
od:
|
105
|
+
printf("zminmin = -2^(%2f) zmaxmax = 2^(%2f)\n", log2(-zminmin), log2(zmaxmax) ) :
|
106
|
+
|
107
|
+
PolyDegreeQuick:=7:
|
108
|
+
|
109
|
+
printf(" degree of the polynomial used in the quick phase is %d\n",PolyDegreeQuick);
|
110
|
+
|
111
|
+
DDNumberQuick:=3:
|
112
|
+
|
113
|
+
printf(" number of double doubles used for the coefficients is %d\n",DDNumberQuick);
|
114
|
+
|
115
|
+
#Keep -zmaxmax..zmaxmax to keep c1=1, which is useful in the proof
|
116
|
+
#and constrain the first two coefficients to 1 and -1/2 in order to save up a full multiplication and a rounding error
|
117
|
+
polyQuick:= poly_exact2(x*(1+x*(-0.5+x*(numapprox[minimax]((((log(1+x)/x)-1)/x+0.5)/x,
|
118
|
+
x=-zmaxmax..zmaxmax, [PolyDegreeQuick-3,0], 1 , 'deltaApprox')))), DDNumberQuick):
|
119
|
+
|
120
|
+
#Try to verify the bound for using double double arithmetic.
|
121
|
+
#Idea: compare the maximum absolute value of the polynomial in zmaxmax (the polynomial has its maxima at the limits)
|
122
|
+
#with the maximum value of the first term which is calculated in double precision only
|
123
|
+
|
124
|
+
p := unapply(polyQuick,x):
|
125
|
+
printf(" using only %d double doubles should be fine since the hi z ulp should affect the result starting from bit %f\n",
|
126
|
+
DDNumberQuick,evalf(53 + log2(p(zmaxmax)) - log2(zmaxmax^(DDNumberQuick)),5)):
|
127
|
+
|
128
|
+
|
129
|
+
epsilonApproxQuick := numapprox[infnorm]( 1-polyQuick/log(1+x), x=zminmin..zmaxmax):
|
130
|
+
printf(" approximation rel error for the quick phase is 2^(%2f)\n", log2(epsilonApproxQuick) ) :
|
131
|
+
deltaApproxQuick := numapprox[infnorm]( polyQuick-log(1+x), x=zminmin..zmaxmax):
|
132
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxQuick) ) :
|
133
|
+
|
134
|
+
|
135
|
+
PolyDegreeAccurate:=14:
|
136
|
+
|
137
|
+
printf(" degree of the polynomial used in the accurate phase is %d\n",PolyDegreeAccurate);
|
138
|
+
|
139
|
+
DDNumberAccu:=7:
|
140
|
+
TDNumberAccu:=3:
|
141
|
+
|
142
|
+
printf(" number of triple doubles used for the coefficients is %d\n",TDNumberAccu);
|
143
|
+
printf(" number of double doubles used for the coefficients is %d\n",DDNumberAccu);
|
144
|
+
|
145
|
+
|
146
|
+
#Keep -zmaxmax..zmaxmax to keep c1=1, which is useful in the proof
|
147
|
+
polyAccurate:= poly_exact32(x*(1+x*(-0.5+x*(numapprox[minimax]((((log(1+x)/x)-1)/x+0.5)/x,
|
148
|
+
x=-zmaxmax..zmaxmax, [PolyDegreeAccurate-3,0], 1 , 'deltaApprox')))),
|
149
|
+
TDNumberAccu, DDNumberAccu):
|
150
|
+
|
151
|
+
#Try to verify the bound for using double double arithmetic.
|
152
|
+
#Idea: compare the maximum absolute value of the polynomial in zmaxmax (the polynomial has its maxima at the limits)
|
153
|
+
#with the maximum value of the first term which is calculated in double precision only
|
154
|
+
|
155
|
+
pp := unapply(polyAccurate,x):
|
156
|
+
printf(" using only %d triple doubles should be fine since the mi z ulp should affect the result starting from bit %f\n",
|
157
|
+
TDNumberAccu,evalf(106 + log2(p(zmaxmax)) - log2(zmaxmax^(TDNumberAccu)),5)):
|
158
|
+
printf(" using only %d double doubles should be fine since the hi z ulp should affect the result starting from bit %f\n",
|
159
|
+
DDNumberAccu,evalf(53 + log2(p(zmaxmax)) - log2(zmaxmax^(TDNumberAccu + DDNumberAccu)),5)):
|
160
|
+
|
161
|
+
|
162
|
+
epsilonApproxAccurate := numapprox[infnorm]( 1-polyAccurate/log(1+x), x=zminmin..zmaxmax):
|
163
|
+
printf(" approximation rel error for the accurate phase is 2^(%2f)\n", log2(epsilonApproxAccurate) ) :
|
164
|
+
deltaApproxAccurate := numapprox[infnorm]( polyAccurate-log(1+x), x=zminmin..zmaxmax):
|
165
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxAccurate) ) :
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
#-------------------------------------------------------------------
|
170
|
+
# Output
|
171
|
+
|
172
|
+
|
173
|
+
filename:="TEMPLOG/log-td.h":
|
174
|
+
fd:=fopen(filename, WRITE, TEXT):
|
175
|
+
|
176
|
+
fprintf(fd, "#include \"crlibm.h\"\n#include \"crlibm_private.h\"\n"):
|
177
|
+
|
178
|
+
fprintf(fd, "\n/*File generated by maple/log-td.mpl*/\n"):
|
179
|
+
|
180
|
+
fprintf(fd, "\n\#define L %d\n\n",L):
|
181
|
+
fprintf(fd, "\#define MAXINDEX %d\n\n", MAXINDEX):
|
182
|
+
fprintf(fd, "\#define INDEXMASK %d\n", 2^L-1):
|
183
|
+
fprintf(fd, "\#define two52 %1.50e\n", 2^(52)):
|
184
|
+
fprintf(fd, "\#define log2h %1.50e\n", log2h):
|
185
|
+
fprintf(fd, "\#define log2m %1.50e\n", log2m):
|
186
|
+
fprintf(fd, "\#define log2l %1.50e\n", log2l):
|
187
|
+
|
188
|
+
epsilon_quick_1 := 2^(-62.5): # The Gappa proof will show this bound
|
189
|
+
epsilon_quick_2 := 2^(-62.5): # The Gappa proof will show this bound
|
190
|
+
fprintf(fd, "\#define ROUNDCST1 %1.50e\n", compute_rn_constant(epsilon_quick_1)):
|
191
|
+
fprintf(fd, "\#define ROUNDCST2 %1.50e\n", compute_rn_constant(epsilon_quick_2)):
|
192
|
+
fprintf(fd, "\#define RDROUNDCST1 %1.50e\n", epsilon_quick_1):
|
193
|
+
fprintf(fd, "\#define RDROUNDCST2 %1.50e\n", epsilon_quick_2):
|
194
|
+
|
195
|
+
|
196
|
+
fprintf(fd, "\n\n"):
|
197
|
+
|
198
|
+
|
199
|
+
# Print the defines for the define statements
|
200
|
+
|
201
|
+
for i from 3 to PolyDegreeQuick do
|
202
|
+
fprintf(fd, "\#define c%d %1.50e\n",i,coeff(polyQuick,x,i)):
|
203
|
+
od:
|
204
|
+
|
205
|
+
fprintf(fd, "\n\n"):
|
206
|
+
|
207
|
+
for i from 3 to (DDNumberAccu + TDNumberAccu -1) do
|
208
|
+
(hi,lo) := hi_lo(coeff(polyAccurate,x,i)):
|
209
|
+
fprintf(fd, "\#define accPolyC%dh %1.50e\n",i,hi):
|
210
|
+
fprintf(fd, "\#define accPolyC%dl %1.50e\n",i,lo):
|
211
|
+
od:
|
212
|
+
|
213
|
+
for i from (DDNumberAccu + TDNumberAccu) to PolyDegreeAccurate do
|
214
|
+
fprintf(fd, "\#define accPolyC%d %1.50e\n",i,coeff(polyAccurate,x,i)):
|
215
|
+
od:
|
216
|
+
|
217
|
+
fprintf(fd, "\n\n"):
|
218
|
+
|
219
|
+
# Print the table
|
220
|
+
fprintf(fd, "typedef struct rri_tag {float ri; double logih; double logim; double logil;} rri; \n"):
|
221
|
+
fprintf(fd, "static const rri argredtable[%d] = {\n", 2^L):
|
222
|
+
for i from 0 to 2^L-1 do
|
223
|
+
fprintf(fd, " { \n"):
|
224
|
+
fprintf(fd, " %1.50e, /* r[%d] */ \n", r[i], i):
|
225
|
+
fprintf(fd, " %1.50e, /* logih[%d] */ \n", logih[i], i):
|
226
|
+
fprintf(fd, " %1.50e, /* logim[%d] */ \n", logim[i], i):
|
227
|
+
fprintf(fd, " %1.50e, /* logil[%d] */ \n", logil[i], i):
|
228
|
+
fprintf(fd, " } "):
|
229
|
+
if(i<2^L-1) then fprintf(fd, ", \n"): fi
|
230
|
+
od:
|
231
|
+
fprintf(fd, "}; \n \n"):
|
232
|
+
|
233
|
+
fclose(fd):
|
234
|
+
|
235
|
+
for j from 0 to 2^L-1 do
|
236
|
+
filename:=cat("TEMPLOG/log-td_",j,".sed"):
|
237
|
+
fd:=fopen(filename, WRITE, TEXT):
|
238
|
+
fprintf(fd, " s/_log2h/%1.50e/g\n", log2h):
|
239
|
+
fprintf(fd, " s/_log2m/%1.50e/g\n", log2m):
|
240
|
+
fprintf(fd, " s/_log2l/%1.50e/g\n", log2l):
|
241
|
+
fprintf(fd, " s/_logih/%1.50e/g\n", logih[j]):
|
242
|
+
fprintf(fd, " s/_logim/%1.50e/g\n", logim[j]):
|
243
|
+
fprintf(fd, " s/_logil/%1.50e/g\n", logil[j]):
|
244
|
+
fprintf(fd, " s/_zmin/%1.50e/g\n", zmin[j]):
|
245
|
+
fprintf(fd, " s/_zmax/%1.50e/g\n", zmax[j]):
|
246
|
+
for i from 3 to PolyDegreeQuick do
|
247
|
+
fprintf(fd, " s/_c%d/%1.50e/g\n", i, coeff(polyQuick,x,i)):
|
248
|
+
od:
|
249
|
+
fprintf(fd, " s/_epsilonApproxQuick/%1.50e/g\n", epsilonApproxQuick):
|
250
|
+
fclose(fd):
|
251
|
+
od:
|
252
|
+
|
253
|
+
for j from 0 to 2^L-1 do
|
254
|
+
filename:=cat("TEMPLOG/log-td-accurate_",j,".sed"):
|
255
|
+
fd:=fopen(filename, WRITE, TEXT):
|
256
|
+
fprintf(fd, " s/_log2h/%1.50e/g\n", log2h):
|
257
|
+
fprintf(fd, " s/_log2m/%1.50e/g\n", log2m):
|
258
|
+
fprintf(fd, " s/_log2l/%1.50e/g\n", log2l):
|
259
|
+
fprintf(fd, " s/_logih/%1.50e/g\n", logih[j]):
|
260
|
+
fprintf(fd, " s/_logim/%1.50e/g\n", logim[j]):
|
261
|
+
fprintf(fd, " s/_logil/%1.50e/g\n", logil[j]):
|
262
|
+
fprintf(fd, " s/_zmin/%1.50e/g\n", zmin[j]):
|
263
|
+
fprintf(fd, " s/_zmax/%1.50e/g\n", zmax[j]):
|
264
|
+
for i from 3 to (DDNumberAccu + TDNumberAccu -1) do
|
265
|
+
(hi,lo) := hi_lo(coeff(polyAccurate,x,i)):
|
266
|
+
fprintf(fd, " s/_accPolyC%dh/%1.50e/g\n", i, hi):
|
267
|
+
fprintf(fd, " s/_accPolyC%dl/%1.50e/g\n", i, lo):
|
268
|
+
od:
|
269
|
+
for i from (DDNumberAccu + TDNumberAccu) to PolyDegreeAccurate do
|
270
|
+
fprintf(fd, " s/_accPolyC%d/%1.50e/g\n", i, coeff(polyAccurate,x,i)):
|
271
|
+
od:
|
272
|
+
fprintf(fd, " s/_epsilonApproxAccurate/%1.50e/g\n", epsilonApproxAccurate):
|
273
|
+
fclose(fd):
|
274
|
+
od:
|
275
|
+
|
276
|
+
# A shell script to use them
|
277
|
+
filename:="run-log-td-proof.sh":
|
278
|
+
fd:=fopen(filename, WRITE, TEXT):
|
279
|
+
fprintf(fd, "#!/bin/sh\n"):
|
280
|
+
fprintf(fd, "# You probably need to edit the path to the gappa executable\n"):
|
281
|
+
fprintf(fd, "GAPPA=~/sangria/gappa-0.4.7/src/gappa\n"):
|
282
|
+
fprintf(fd, "# Test all the possible table value for E=1\n"):
|
283
|
+
fprintf(fd, "for num in `seq 0 %d`; do\n", 2^L-1):
|
284
|
+
fprintf(fd, " echo $num, E=1:\n"):
|
285
|
+
fprintf(fd, " sed -f ./TEMPLOG/log-td_$num.sed log-td.gappa | $GAPPA > /dev/null\n"):
|
286
|
+
fprintf(fd, " echo\n"):
|
287
|
+
fprintf(fd, "done\n"):
|
288
|
+
fprintf(fd, "# For the case E=0 we first handle the cases 0 and %d using log-td-E0-logir0.gappa\n", 2^L):
|
289
|
+
fprintf(fd, "echo 0 and %d, E=0:\n", 2^L):
|
290
|
+
fprintf(fd, "sed -f log-td_0.sed log-td-E0-logir0.gappa | $GAPPA > /dev/null\n"):
|
291
|
+
fprintf(fd, "# then the other cases where logirh <> 0\n"):
|
292
|
+
fprintf(fd, "for num in `seq 1 %d`; do\n", 2^L-1):
|
293
|
+
fprintf(fd, " echo $num, E=0:\n"):
|
294
|
+
fprintf(fd, " sed -f ./TEMPLOG/log-td_$num.sed log-td-E0.gappa | $GAPPA > /dev/null\n"):
|
295
|
+
fprintf(fd, " echo\n"):
|
296
|
+
fprintf(fd, "done\n"):
|
297
|
+
fprintf(fd, "# Accurate phase: Test all the possible table value for E=1\n"):
|
298
|
+
fprintf(fd, "for num in `seq 0 %d`; do\n", 2^L-1):
|
299
|
+
fprintf(fd, " echo Accurate phase: $num, E=1:\n"):
|
300
|
+
fprintf(fd, " sed -f ./TEMPLOG/log-td-accurate_$num.sed log-td-accurate.gappa | $GAPPA > /dev/null\n"):
|
301
|
+
fprintf(fd, " echo\n"):
|
302
|
+
fprintf(fd, "done\n"):
|
303
|
+
fprintf(fd, "# Accurate phase: For the case E=0 we first handle the cases 0 and %d using log-td-accurate-E0-logir0.gappa\n", 2^L):
|
304
|
+
fprintf(fd, "echo 0 and %d, E=0:\n", 2^L):
|
305
|
+
fprintf(fd, "sed -f ./TEMPLOG/log-td-accurate_0.sed log-td-accurate-E0-logir0.gappa | $GAPPA > /dev/null\n"):
|
306
|
+
fprintf(fd, "# Accurate phase: then the other cases where logirh <> 0\n"):
|
307
|
+
fprintf(fd, "for num in `seq 1 %d`; do\n", 2^L-1):
|
308
|
+
fprintf(fd, " echo $num, E=0:\n"):
|
309
|
+
fprintf(fd, " sed -f ./TEMPLOG/log-td-accurate_$num.sed log-td-accurate-E0.gappa | $GAPPA > /dev/null\n"):
|
310
|
+
fprintf(fd, " echo\n"):
|
311
|
+
fprintf(fd, "done\n"):
|
312
|
+
fclose(fd):
|
313
|
+
|
314
|
+
printf("----DONE---\n") :
|
315
|
+
|
316
|
+
|
@@ -0,0 +1,345 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# This file is part of the crlibm library, and is distributed under
|
3
|
+
# the LGPL.
|
4
|
+
# To use:
|
5
|
+
# restart; read "log2-td.mpl";
|
6
|
+
Digits := 120:
|
7
|
+
|
8
|
+
interface(quiet=true):
|
9
|
+
|
10
|
+
read "common-procedures.mpl":
|
11
|
+
read "triple-double.mpl":
|
12
|
+
mkdir("TEMPLOG"):
|
13
|
+
|
14
|
+
|
15
|
+
# We want log2h + log2m + log2l + delta = log(2) such that
|
16
|
+
# log2h and log2m have at least 11 trailing zeros
|
17
|
+
# in order to have an exact multiplication with E, which is lower than 1024 in
|
18
|
+
# magnitude
|
19
|
+
# The resting accuracy is enough for both quick and accurate phases.
|
20
|
+
|
21
|
+
log2acc := log(2):
|
22
|
+
log2h := round(log2acc * 2**(floor(-log[2](abs(log2acc))) + (53 - 11))) / 2**(floor(-log[2](abs(log2acc))) + (53 - 11)):
|
23
|
+
log2m := round((log2acc - log2h) * 2**(floor(-log[2](abs((log2acc - log2h)))) + (53 - 11))) / 2**(floor(-log[2](abs((log2acc - log2h)))) + (53 - 11)):
|
24
|
+
log2l := log2acc - (log2h + log2m):
|
25
|
+
|
26
|
+
|
27
|
+
L := 7: # number of bits used to address the table
|
28
|
+
|
29
|
+
MAXINDEX := round(2^L * (sqrt(2)-1)):
|
30
|
+
|
31
|
+
for i from 0 to MAXINDEX-1 do
|
32
|
+
center[i] := 1 + i*2^(-L): # center[i] in [1, 2[
|
33
|
+
t := evalf(1/center[i]):
|
34
|
+
r[i] := round(t * 2**(floor(-log[2](abs(t))) + 23)) / 2**(floor(-log[2](abs(t))) + 23):
|
35
|
+
(logih[i], logim[i], logil[i]) := hi_mi_lo(evalf(-log(r[i]))):
|
36
|
+
od:
|
37
|
+
for i from MAXINDEX to 2^L do
|
38
|
+
# y has been divided by two, center[i] in [0.5, 1[
|
39
|
+
center[i]:=(1 + i*2^(-L)) / 2:
|
40
|
+
t := evalf(1/center[i]):
|
41
|
+
r[i] := round(t * 2**(floor(-log[2](abs(t))) + 23)) / 2**(floor(-log[2](abs(t))) + 23):
|
42
|
+
(logih[i], logim[i], logil[i]) := hi_mi_lo(evalf(-log(r[i]))):
|
43
|
+
od:
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#Computation of ZMax.
|
49
|
+
for i from 0 to MAXINDEX-1 do
|
50
|
+
__x := center[i] + 2^(-L-1) :
|
51
|
+
zmax[i] := (__x*r[i]-1) :
|
52
|
+
__x := center[i] - 2^(-L-1) :
|
53
|
+
zmin[i] := (__x*r[i]-1) :
|
54
|
+
od:
|
55
|
+
for i from MAXINDEX to 2^L do
|
56
|
+
__x := center[i] + 2^(-L-2) :
|
57
|
+
zmax[i] := (__x*r[i]-1) :
|
58
|
+
__x := center[i] - 2^(-L-2) :
|
59
|
+
zmin[i] := (__x*r[i]-1) :
|
60
|
+
od:
|
61
|
+
|
62
|
+
zmaxmax:=0:
|
63
|
+
zminmin:=0:
|
64
|
+
for i from 0 to 2^L do
|
65
|
+
tabulated_value := logih[i] + logim[i] + logil[i]:
|
66
|
+
poly_approx_min := evalf(log(1+zmin[i])):
|
67
|
+
poly_approx_max := evalf(log(1+zmax[i])):
|
68
|
+
|
69
|
+
# Test if we have a case where we cancellate a lot
|
70
|
+
# i.e. the polynomial approximation value is greater than half the tabulated value
|
71
|
+
# the tabulated value is not exactly zero and we are of opposite sign
|
72
|
+
|
73
|
+
if ((abs(poly_approx_min) > 0.75*abs(tabulated_value)) and (tabulated_value <> 0.0) and (poly_approx_min * tabulated_value < 0)) then
|
74
|
+
printf("Polynomial approximation is greater in magnitude in zmin[%d] than half the tabluated value\n",i):
|
75
|
+
|
76
|
+
printf("The tabulated value is %1.50e\n",tabulated_value):
|
77
|
+
if (tabulated_value <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(tabulated_value)))) fi:
|
78
|
+
printf("The value of polynomial in zmin[%d] is %1.50e\n",i,poly_approx_min):
|
79
|
+
if (poly_approx_min <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(poly_approx_min)))) fi:
|
80
|
+
|
81
|
+
summe := poly_approx_min + tabulated_value:
|
82
|
+
printf("The exponent of the sum of both is %d\n",floor(log2(abs(summe)))):
|
83
|
+
|
84
|
+
|
85
|
+
fi:
|
86
|
+
|
87
|
+
if ((abs(poly_approx_max) > 0.75*abs(tabulated_value)) and (tabulated_value <> 0.0) and (poly_approx_max * tabulated_value <0)) then
|
88
|
+
printf("Polynomial approximation is greater in magnitude in zmax[%d] than half the tabluated value\n",i):
|
89
|
+
|
90
|
+
printf("The tabulated value is %1.50e\n",tabulated_value):
|
91
|
+
if (tabulated_value <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(tabulated_value)))) fi:
|
92
|
+
printf("The value of polynomial in zmax[%d] is %1.50e\n",i,poly_approx_max):
|
93
|
+
if (poly_approx_max <> 0.0) then printf("i.e. the value has the exponent %d\n",floor(log2(abs(poly_approx_max)))) fi:
|
94
|
+
|
95
|
+
summe := poly_approx_max + tabulated_value:
|
96
|
+
printf("The exponent of the sum of both is %d\n",floor(log2(abs(summe)))):
|
97
|
+
|
98
|
+
|
99
|
+
fi:
|
100
|
+
|
101
|
+
|
102
|
+
if zmax[i] > zmaxmax then zmaxmax := zmax[i]: fi:
|
103
|
+
if zmin[i] < zminmin then zminmin := zmin[i]: fi:
|
104
|
+
od:
|
105
|
+
printf("zminmin = -2^(%2f) zmaxmax = 2^(%2f)\n", log2(-zminmin), log2(zmaxmax) ) :
|
106
|
+
|
107
|
+
PolyDegreeQuick:=7:
|
108
|
+
|
109
|
+
printf(" degree of the polynomial used in the quick phase is %d\n",PolyDegreeQuick);
|
110
|
+
|
111
|
+
DDNumberQuick:=3:
|
112
|
+
|
113
|
+
printf(" number of double doubles used for the coefficients is %d\n",DDNumberQuick);
|
114
|
+
|
115
|
+
#Keep -zmaxmax..zmaxmax to keep c1=1, which is useful in the proof
|
116
|
+
#and constrain the first two coefficients to 1 and -1/2 in order to save up a full multiplication and a rounding error
|
117
|
+
polyQuick:= poly_exact2(x*(1+x*(-0.5+x*(numapprox[minimax]((((log(1+x)/x)-1)/x+0.5)/x,
|
118
|
+
x=-zmaxmax..zmaxmax, [PolyDegreeQuick-3,0], 1 , 'deltaApprox')))), DDNumberQuick):
|
119
|
+
|
120
|
+
#Try to verify the bound for using double double arithmetic.
|
121
|
+
#Idea: compare the maximum absolute value of the polynomial in zmaxmax (the polynomial has its maxima at the limits)
|
122
|
+
#with the maximum value of the first term which is calculated in double precision only
|
123
|
+
|
124
|
+
p := unapply(polyQuick,x):
|
125
|
+
printf(" using only %d double doubles should be fine since the hi z ulp should affect the result starting from bit %f\n",
|
126
|
+
DDNumberQuick,evalf(53 + log2(p(zmaxmax)) - log2(zmaxmax^(DDNumberQuick)),5)):
|
127
|
+
|
128
|
+
|
129
|
+
epsilonApproxQuick := numapprox[infnorm]( 1-polyQuick/log(1+x), x=zminmin..zmaxmax):
|
130
|
+
printf(" approximation rel error for the quick phase is 2^(%2f)\n", log2(epsilonApproxQuick) ) :
|
131
|
+
deltaApproxQuick := numapprox[infnorm]( polyQuick-log(1+x), x=zminmin..zmaxmax):
|
132
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxQuick) ) :
|
133
|
+
|
134
|
+
|
135
|
+
PolyDegreeAccurate:=14:
|
136
|
+
|
137
|
+
printf(" degree of the polynomial used in the accurate phase is %d\n",PolyDegreeAccurate);
|
138
|
+
|
139
|
+
DDNumberAccu:=7:
|
140
|
+
TDNumberAccu:=3:
|
141
|
+
|
142
|
+
printf(" number of triple doubles used for the coefficients is %d\n",TDNumberAccu);
|
143
|
+
printf(" number of double doubles used for the coefficients is %d\n",DDNumberAccu);
|
144
|
+
|
145
|
+
|
146
|
+
#Keep -zmaxmax..zmaxmax to keep c1=1, which is useful in the proof
|
147
|
+
polyAccurate:= poly_exact32(x*(1+x*(-0.5+x*(numapprox[minimax]((((log(1+x)/x)-1)/x+0.5)/x,
|
148
|
+
x=-zmaxmax..zmaxmax, [PolyDegreeAccurate-3,0], 1 , 'deltaApprox')))),
|
149
|
+
TDNumberAccu, DDNumberAccu):
|
150
|
+
|
151
|
+
#Try to verify the bound for using double double arithmetic.
|
152
|
+
#Idea: compare the maximum absolute value of the polynomial in zmaxmax (the polynomial has its maxima at the limits)
|
153
|
+
#with the maximum value of the first term which is calculated in double precision only
|
154
|
+
|
155
|
+
pp := unapply(polyAccurate,x):
|
156
|
+
printf(" using only %d triple doubles should be fine since the mi z ulp should affect the result starting from bit %f\n",
|
157
|
+
TDNumberAccu,evalf(106 + log2(p(zmaxmax)) - log2(zmaxmax^(TDNumberAccu)),5)):
|
158
|
+
printf(" using only %d double doubles should be fine since the hi z ulp should affect the result starting from bit %f\n",
|
159
|
+
DDNumberAccu,evalf(53 + log2(p(zmaxmax)) - log2(zmaxmax^(TDNumberAccu + DDNumberAccu)),5)):
|
160
|
+
|
161
|
+
|
162
|
+
epsilonApproxAccurate := numapprox[infnorm]( 1-polyAccurate/log(1+x), x=zminmin..zmaxmax):
|
163
|
+
printf(" approximation rel error for the accurate phase is 2^(%2f)\n", log2(epsilonApproxAccurate) ) :
|
164
|
+
deltaApproxAccurate := numapprox[infnorm]( polyAccurate-log(1+x), x=zminmin..zmaxmax):
|
165
|
+
printf(" approximation abs error for the quick phase is 2^(%2f)\n", log2(deltaApproxAccurate) ) :
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
#Compute now the inverse of ln(10) for the final multiplication of ln(x) with this constant for obtaining log10(x)
|
170
|
+
#Compute also the relative error of the constant stored as a triple double.
|
171
|
+
Log10inv := evalf(1 / log(10)):
|
172
|
+
|
173
|
+
(log10invh, log10invm, log10invl) := hi_mi_lo(Log10inv):
|
174
|
+
|
175
|
+
Log10invhml := log10invh + log10invm + log10invl:
|
176
|
+
|
177
|
+
epsilonLog10invhml := evalf(abs((Log10invhml - Log10inv) / Log10inv)):
|
178
|
+
|
179
|
+
printf(" Log10inv = 1 / ln(10) stored as a triple-double is exact with a relative error of 2^(%2f)\n",
|
180
|
+
evalf(log[2](epsilonLog10invhml))):
|
181
|
+
|
182
|
+
|
183
|
+
#Compute now the constant needed for the unfiltered directed final rounding of the triple-double result
|
184
|
+
#This constant is supposed to be the reciprocal of the critical accuracy of the function.
|
185
|
+
#We suppose this critical accuracy to be 2^(-120) because the worst case (for RD) we know of is x = 403ce41d 8fa665fa
|
186
|
+
#We can easily spend some guard bits since we want simply filter out cases with a theoretical worst case accuracy
|
187
|
+
#of -infty (exact floating point images) and as we know that we are exact to at least 122 bits.
|
188
|
+
|
189
|
+
wca := 2^(122):
|
190
|
+
|
191
|
+
|
192
|
+
#-------------------------------------------------------------------
|
193
|
+
# Output
|
194
|
+
|
195
|
+
|
196
|
+
filename:="TEMPLOG/log10-td.h":
|
197
|
+
fd:=fopen(filename, WRITE, TEXT):
|
198
|
+
|
199
|
+
fprintf(fd, "#include \"crlibm.h\"\n#include \"crlibm_private.h\"\n"):
|
200
|
+
|
201
|
+
fprintf(fd, "\n/*File generated by maple/log10-td.mpl*/\n"):
|
202
|
+
|
203
|
+
fprintf(fd, "\n\#define L %d\n\n",L):
|
204
|
+
fprintf(fd, "\#define MAXINDEX %d\n\n", MAXINDEX):
|
205
|
+
fprintf(fd, "\#define INDEXMASK %d\n", 2^L-1):
|
206
|
+
fprintf(fd, "\#define two52 %1.50e\n", 2^(52)):
|
207
|
+
fprintf(fd, "\#define log2h %1.50e\n", log2h):
|
208
|
+
fprintf(fd, "\#define log2m %1.50e\n", log2m):
|
209
|
+
fprintf(fd, "\#define log2l %1.50e\n", log2l):
|
210
|
+
fprintf(fd, "\#define log10invh %1.50e\n",log10invh):
|
211
|
+
fprintf(fd, "\#define log10invm %1.50e\n",log10invm):
|
212
|
+
fprintf(fd, "\#define log10invl %1.50e\n",log10invl):
|
213
|
+
fprintf(fd, "\#define WORSTCASEACCURACY %1.50e\n",wca):
|
214
|
+
|
215
|
+
epsilon_quick_1 := 2^(-61): # The Gappa proof will show this bound
|
216
|
+
epsilon_quick_2 := 2^(-61): # The Gappa proof will show this bound
|
217
|
+
fprintf(fd, "\#define ROUNDCST1 %1.50e\n", compute_rn_constant(epsilon_quick_1)):
|
218
|
+
fprintf(fd, "\#define ROUNDCST2 %1.50e\n", compute_rn_constant(epsilon_quick_2)):
|
219
|
+
fprintf(fd, "\#define RDROUNDCST1 %1.50e\n", epsilon_quick_1):
|
220
|
+
fprintf(fd, "\#define RDROUNDCST2 %1.50e\n", epsilon_quick_2):
|
221
|
+
|
222
|
+
|
223
|
+
fprintf(fd, "\n\n"):
|
224
|
+
|
225
|
+
|
226
|
+
# Print the defines for the define statements
|
227
|
+
|
228
|
+
for i from 3 to PolyDegreeQuick do
|
229
|
+
fprintf(fd, "\#define c%d %1.50e\n",i,coeff(polyQuick,x,i)):
|
230
|
+
od:
|
231
|
+
|
232
|
+
fprintf(fd, "\n\n"):
|
233
|
+
|
234
|
+
for i from 3 to (DDNumberAccu + TDNumberAccu -1) do
|
235
|
+
(hi,lo) := hi_lo(coeff(polyAccurate,x,i)):
|
236
|
+
fprintf(fd, "\#define accPolyC%dh %1.50e\n",i,hi):
|
237
|
+
fprintf(fd, "\#define accPolyC%dl %1.50e\n",i,lo):
|
238
|
+
od:
|
239
|
+
|
240
|
+
for i from (DDNumberAccu + TDNumberAccu) to PolyDegreeAccurate do
|
241
|
+
fprintf(fd, "\#define accPolyC%d %1.50e\n",i,coeff(polyAccurate,x,i)):
|
242
|
+
od:
|
243
|
+
|
244
|
+
fprintf(fd, "\n\n"):
|
245
|
+
|
246
|
+
# Print the table
|
247
|
+
fprintf(fd, "typedef struct rri_tag {float ri; double logih; double logim; double logil;} rri; \n"):
|
248
|
+
fprintf(fd, "static const rri argredtable[%d] = {\n", 2^L):
|
249
|
+
for i from 0 to 2^L-1 do
|
250
|
+
fprintf(fd, " { \n"):
|
251
|
+
fprintf(fd, " %1.50e, /* r[%d] */ \n", r[i], i):
|
252
|
+
fprintf(fd, " %1.50e, /* logih[%d] */ \n", logih[i], i):
|
253
|
+
fprintf(fd, " %1.50e, /* logim[%d] */ \n", logim[i], i):
|
254
|
+
fprintf(fd, " %1.50e, /* logil[%d] */ \n", logil[i], i):
|
255
|
+
fprintf(fd, " } "):
|
256
|
+
if(i<2^L-1) then fprintf(fd, ", \n"): fi
|
257
|
+
od:
|
258
|
+
fprintf(fd, "}; \n \n"):
|
259
|
+
|
260
|
+
fclose(fd):
|
261
|
+
|
262
|
+
for j from 0 to 2^L-1 do
|
263
|
+
filename:=cat("TEMPLOG/log10-td_",j,".sed"):
|
264
|
+
fd:=fopen(filename, WRITE, TEXT):
|
265
|
+
fprintf(fd, " s/_log2h/%1.50e/g\n", log2h):
|
266
|
+
fprintf(fd, " s/_log2m/%1.50e/g\n", log2m):
|
267
|
+
fprintf(fd, " s/_log2l/%1.50e/g\n", log2l):
|
268
|
+
fprintf(fd, " s/_logih/%1.50e/g\n", logih[j]):
|
269
|
+
fprintf(fd, " s/_logim/%1.50e/g\n", logim[j]):
|
270
|
+
fprintf(fd, " s/_logil/%1.50e/g\n", logil[j]):
|
271
|
+
fprintf(fd, " s/_zmin/%1.50e/g\n", zmin[j]):
|
272
|
+
fprintf(fd, " s/_zmax/%1.50e/g\n", zmax[j]):
|
273
|
+
for i from 3 to PolyDegreeQuick do
|
274
|
+
fprintf(fd, " s/_c%d/%1.50e/g\n", i, coeff(polyQuick,x,i)):
|
275
|
+
od:
|
276
|
+
fprintf(fd, " s/_epsilonApproxQuick/%1.50e/g\n", epsilonApproxQuick):
|
277
|
+
fprintf(fd, " s/_epsilonLog10invhml/%1.50e/g\n", epsilonLog10invhml):
|
278
|
+
fclose(fd):
|
279
|
+
od:
|
280
|
+
|
281
|
+
for j from 0 to 2^L-1 do
|
282
|
+
filename:=cat("TEMPLOG/log10-td-accurate_",j,".sed"):
|
283
|
+
fd:=fopen(filename, WRITE, TEXT):
|
284
|
+
fprintf(fd, " s/_log2h/%1.50e/g\n", log2h):
|
285
|
+
fprintf(fd, " s/_log2m/%1.50e/g\n", log2m):
|
286
|
+
fprintf(fd, " s/_log2l/%1.50e/g\n", log2l):
|
287
|
+
fprintf(fd, " s/_logih/%1.50e/g\n", logih[j]):
|
288
|
+
fprintf(fd, " s/_logim/%1.50e/g\n", logim[j]):
|
289
|
+
fprintf(fd, " s/_logil/%1.50e/g\n", logil[j]):
|
290
|
+
fprintf(fd, " s/_zmin/%1.50e/g\n", zmin[j]):
|
291
|
+
fprintf(fd, " s/_zmax/%1.50e/g\n", zmax[j]):
|
292
|
+
for i from 3 to (DDNumberAccu + TDNumberAccu -1) do
|
293
|
+
(hi,lo) := hi_lo(coeff(polyAccurate,x,i)):
|
294
|
+
fprintf(fd, " s/_accPolyC%dh/%1.50e/g\n", i, hi):
|
295
|
+
fprintf(fd, " s/_accPolyC%dl/%1.50e/g\n", i, lo):
|
296
|
+
od:
|
297
|
+
for i from (DDNumberAccu + TDNumberAccu) to PolyDegreeAccurate do
|
298
|
+
fprintf(fd, " s/_accPolyC%d/%1.50e/g\n", i, coeff(polyAccurate,x,i)):
|
299
|
+
od:
|
300
|
+
fprintf(fd, " s/_epsilonApproxAccurate/%1.50e/g\n", epsilonApproxAccurate):
|
301
|
+
fprintf(fd, " s/_epsilonLog10invhml/%1.50e/g\n", epsilonLog10invhml):
|
302
|
+
fclose(fd):
|
303
|
+
od:
|
304
|
+
|
305
|
+
# A shell script to use them
|
306
|
+
filename:="run-log10-td-proof.sh":
|
307
|
+
fd:=fopen(filename, WRITE, TEXT):
|
308
|
+
fprintf(fd, "#!/bin/sh\n"):
|
309
|
+
fprintf(fd, "# You probably need to edit the path to the gappa executable\n"):
|
310
|
+
fprintf(fd, "GAPPA=~/ble/gappa-0.4.5/src/gappa\n"):
|
311
|
+
fprintf(fd, "# Test all the possible table value for E=1\n"):
|
312
|
+
fprintf(fd, "for num in `seq 0 %d`; do\n", 2^L-1):
|
313
|
+
fprintf(fd, " echo $num, E=1:\n"):
|
314
|
+
fprintf(fd, " sed -f ./TEMPLOG/log10-td_$num.sed log10-td.gappa | $GAPPA > /dev/null\n"):
|
315
|
+
fprintf(fd, " echo\n"):
|
316
|
+
fprintf(fd, "done\n"):
|
317
|
+
fprintf(fd, "# For the case E=0 we first handle the cases 0 and %d using log10-td-E0-logir0.gappa\n", 2^L):
|
318
|
+
fprintf(fd, "echo 0 and %d, E=0:\n", 2^L):
|
319
|
+
fprintf(fd, "sed -f log10-td_0.sed log10-td-E0-logir0.gappa | $GAPPA > /dev/null\n"):
|
320
|
+
fprintf(fd, "# then the other cases where logirh <> 0\n"):
|
321
|
+
fprintf(fd, "for num in `seq 1 %d`; do\n", 2^L-1):
|
322
|
+
fprintf(fd, " echo $num, E=0:\n"):
|
323
|
+
fprintf(fd, " sed -f ./TEMPLOG/log10-td_$num.sed log10-td-E0.gappa | $GAPPA > /dev/null\n"):
|
324
|
+
fprintf(fd, " echo\n"):
|
325
|
+
fprintf(fd, "done\n"):
|
326
|
+
fprintf(fd, "# Accurate phase: Test all the possible table value for E=1\n"):
|
327
|
+
fprintf(fd, "for num in `seq 0 %d`; do\n", 2^L-1):
|
328
|
+
fprintf(fd, " echo Accurate phase: $num, E=1:\n"):
|
329
|
+
fprintf(fd, " sed -f ./TEMPLOG/log10-td-accurate_$num.sed log10-td-accurate.gappa | $GAPPA > /dev/null\n"):
|
330
|
+
fprintf(fd, " echo\n"):
|
331
|
+
fprintf(fd, "done\n"):
|
332
|
+
fprintf(fd, "# Accurate phase: For the case E=0 we first handle the cases 0 and %d using log10-td-accurate-E0-logir0.gappa\n", 2^L):
|
333
|
+
fprintf(fd, "echo 0 and %d, E=0:\n", 2^L):
|
334
|
+
fprintf(fd, "sed -f ./TEMPLOG/log10-td-accurate_0.sed log10-td-accurate-E0-logir0.gappa | $GAPPA > /dev/null\n"):
|
335
|
+
fprintf(fd, "# Accurate phase: then the other cases where logirh <> 0\n"):
|
336
|
+
fprintf(fd, "for num in `seq 1 %d`; do\n", 2^L-1):
|
337
|
+
fprintf(fd, " echo $num, E=0:\n"):
|
338
|
+
fprintf(fd, " sed -f ./TEMPLOG/log10-td-accurate_$num.sed log10-td-accurate-E0.gappa | $GAPPA > /dev/null\n"):
|
339
|
+
fprintf(fd, " echo\n"):
|
340
|
+
fprintf(fd, "done\n"):
|
341
|
+
fclose(fd):
|
342
|
+
|
343
|
+
printf("----DONE---\n") :
|
344
|
+
|
345
|
+
|