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,269 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# install - install a program, script, or datafile
|
4
|
+
#
|
5
|
+
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
6
|
+
# later released in X11R6 (xc/config/util/install.sh) with the
|
7
|
+
# following copyright and license.
|
8
|
+
#
|
9
|
+
# Copyright (C) 1994 X Consortium
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
|
+
# of this software and associated documentation files (the "Software"), to
|
13
|
+
# deal in the Software without restriction, including without limitation the
|
14
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
15
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
16
|
+
# furnished to do so, subject to the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be included in
|
19
|
+
# all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
+
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
25
|
+
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
26
|
+
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
+
#
|
28
|
+
# Except as contained in this notice, the name of the X Consortium shall not
|
29
|
+
# be used in advertising or otherwise to promote the sale, use or other deal-
|
30
|
+
# ings in this Software without prior written authorization from the X Consor-
|
31
|
+
# tium.
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# FSF changes to this file are in the public domain.
|
35
|
+
#
|
36
|
+
# Calling this script install-sh is preferred over install.sh, to prevent
|
37
|
+
# `make' implicit rules from creating a file called install from it
|
38
|
+
# when there is no Makefile.
|
39
|
+
#
|
40
|
+
# This script is compatible with the BSD install script, but was written
|
41
|
+
# from scratch. It can only install one file at a time, a restriction
|
42
|
+
# shared with many OS's install programs.
|
43
|
+
|
44
|
+
|
45
|
+
# set DOITPROG to echo to test this script
|
46
|
+
|
47
|
+
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
48
|
+
doit="${DOITPROG-}"
|
49
|
+
|
50
|
+
|
51
|
+
# put in absolute paths if you don't have them in your path; or use env. vars.
|
52
|
+
|
53
|
+
mvprog="${MVPROG-mv}"
|
54
|
+
cpprog="${CPPROG-cp}"
|
55
|
+
chmodprog="${CHMODPROG-chmod}"
|
56
|
+
chownprog="${CHOWNPROG-chown}"
|
57
|
+
chgrpprog="${CHGRPPROG-chgrp}"
|
58
|
+
stripprog="${STRIPPROG-strip}"
|
59
|
+
rmprog="${RMPROG-rm}"
|
60
|
+
mkdirprog="${MKDIRPROG-mkdir}"
|
61
|
+
|
62
|
+
transformbasename=""
|
63
|
+
transform_arg=""
|
64
|
+
instcmd="$mvprog"
|
65
|
+
chmodcmd="$chmodprog 0755"
|
66
|
+
chowncmd=""
|
67
|
+
chgrpcmd=""
|
68
|
+
stripcmd=""
|
69
|
+
rmcmd="$rmprog -f"
|
70
|
+
mvcmd="$mvprog"
|
71
|
+
src=""
|
72
|
+
dst=""
|
73
|
+
dir_arg=""
|
74
|
+
|
75
|
+
while [ x"$1" != x ]; do
|
76
|
+
case $1 in
|
77
|
+
-c) instcmd="$cpprog"
|
78
|
+
shift
|
79
|
+
continue;;
|
80
|
+
|
81
|
+
-d) dir_arg=true
|
82
|
+
shift
|
83
|
+
continue;;
|
84
|
+
|
85
|
+
-m) chmodcmd="$chmodprog $2"
|
86
|
+
shift
|
87
|
+
shift
|
88
|
+
continue;;
|
89
|
+
|
90
|
+
-o) chowncmd="$chownprog $2"
|
91
|
+
shift
|
92
|
+
shift
|
93
|
+
continue;;
|
94
|
+
|
95
|
+
-g) chgrpcmd="$chgrpprog $2"
|
96
|
+
shift
|
97
|
+
shift
|
98
|
+
continue;;
|
99
|
+
|
100
|
+
-s) stripcmd="$stripprog"
|
101
|
+
shift
|
102
|
+
continue;;
|
103
|
+
|
104
|
+
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
105
|
+
shift
|
106
|
+
continue;;
|
107
|
+
|
108
|
+
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
109
|
+
shift
|
110
|
+
continue;;
|
111
|
+
|
112
|
+
*) if [ x"$src" = x ]
|
113
|
+
then
|
114
|
+
src=$1
|
115
|
+
else
|
116
|
+
# this colon is to work around a 386BSD /bin/sh bug
|
117
|
+
:
|
118
|
+
dst=$1
|
119
|
+
fi
|
120
|
+
shift
|
121
|
+
continue;;
|
122
|
+
esac
|
123
|
+
done
|
124
|
+
|
125
|
+
if [ x"$src" = x ]
|
126
|
+
then
|
127
|
+
echo "install: no input file specified"
|
128
|
+
exit 1
|
129
|
+
else
|
130
|
+
true
|
131
|
+
fi
|
132
|
+
|
133
|
+
if [ x"$dir_arg" != x ]; then
|
134
|
+
dst=$src
|
135
|
+
src=""
|
136
|
+
|
137
|
+
if [ -d $dst ]; then
|
138
|
+
instcmd=:
|
139
|
+
chmodcmd=""
|
140
|
+
else
|
141
|
+
instcmd=mkdir
|
142
|
+
fi
|
143
|
+
else
|
144
|
+
|
145
|
+
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
146
|
+
# might cause directories to be created, which would be especially bad
|
147
|
+
# if $src (and thus $dsttmp) contains '*'.
|
148
|
+
|
149
|
+
if [ -f $src -o -d $src ]
|
150
|
+
then
|
151
|
+
true
|
152
|
+
else
|
153
|
+
echo "install: $src does not exist"
|
154
|
+
exit 1
|
155
|
+
fi
|
156
|
+
|
157
|
+
if [ x"$dst" = x ]
|
158
|
+
then
|
159
|
+
echo "install: no destination specified"
|
160
|
+
exit 1
|
161
|
+
else
|
162
|
+
true
|
163
|
+
fi
|
164
|
+
|
165
|
+
# If destination is a directory, append the input filename; if your system
|
166
|
+
# does not like double slashes in filenames, you may need to add some logic
|
167
|
+
|
168
|
+
if [ -d $dst ]
|
169
|
+
then
|
170
|
+
dst="$dst"/`basename $src`
|
171
|
+
else
|
172
|
+
true
|
173
|
+
fi
|
174
|
+
fi
|
175
|
+
|
176
|
+
## this sed command emulates the dirname command
|
177
|
+
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
178
|
+
|
179
|
+
# Make sure that the destination directory exists.
|
180
|
+
# this part is taken from Noah Friedman's mkinstalldirs script
|
181
|
+
|
182
|
+
# Skip lots of stat calls in the usual case.
|
183
|
+
if [ ! -d "$dstdir" ]; then
|
184
|
+
defaultIFS='
|
185
|
+
'
|
186
|
+
IFS="${IFS-${defaultIFS}}"
|
187
|
+
|
188
|
+
oIFS="${IFS}"
|
189
|
+
# Some sh's can't handle IFS=/ for some reason.
|
190
|
+
IFS='%'
|
191
|
+
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
192
|
+
IFS="${oIFS}"
|
193
|
+
|
194
|
+
pathcomp=''
|
195
|
+
|
196
|
+
while [ $# -ne 0 ] ; do
|
197
|
+
pathcomp="${pathcomp}${1}"
|
198
|
+
shift
|
199
|
+
|
200
|
+
if [ ! -d "${pathcomp}" ] ;
|
201
|
+
then
|
202
|
+
$mkdirprog "${pathcomp}"
|
203
|
+
else
|
204
|
+
true
|
205
|
+
fi
|
206
|
+
|
207
|
+
pathcomp="${pathcomp}/"
|
208
|
+
done
|
209
|
+
fi
|
210
|
+
|
211
|
+
if [ x"$dir_arg" != x ]
|
212
|
+
then
|
213
|
+
$doit $instcmd $dst &&
|
214
|
+
|
215
|
+
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
216
|
+
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
217
|
+
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
218
|
+
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
219
|
+
else
|
220
|
+
|
221
|
+
# If we're going to rename the final executable, determine the name now.
|
222
|
+
|
223
|
+
if [ x"$transformarg" = x ]
|
224
|
+
then
|
225
|
+
dstfile=`basename $dst`
|
226
|
+
else
|
227
|
+
dstfile=`basename $dst $transformbasename |
|
228
|
+
sed $transformarg`$transformbasename
|
229
|
+
fi
|
230
|
+
|
231
|
+
# don't allow the sed command to completely eliminate the filename
|
232
|
+
|
233
|
+
if [ x"$dstfile" = x ]
|
234
|
+
then
|
235
|
+
dstfile=`basename $dst`
|
236
|
+
else
|
237
|
+
true
|
238
|
+
fi
|
239
|
+
|
240
|
+
# Make a temp file name in the proper directory.
|
241
|
+
|
242
|
+
dsttmp=$dstdir/#inst.$$#
|
243
|
+
|
244
|
+
# Move or copy the file name to the temp name
|
245
|
+
|
246
|
+
$doit $instcmd $src $dsttmp &&
|
247
|
+
|
248
|
+
trap "rm -f ${dsttmp}" 0 &&
|
249
|
+
|
250
|
+
# and set any options; do chmod last to preserve setuid bits
|
251
|
+
|
252
|
+
# If any of these fail, we abort the whole thing. If we want to
|
253
|
+
# ignore errors from any of these, just make sure not to ignore
|
254
|
+
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
255
|
+
|
256
|
+
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
257
|
+
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
258
|
+
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
259
|
+
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
260
|
+
|
261
|
+
# Now rename the file to the real destination.
|
262
|
+
|
263
|
+
$doit $rmcmd -f $dstdir/$dstfile &&
|
264
|
+
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
265
|
+
|
266
|
+
fi &&
|
267
|
+
|
268
|
+
|
269
|
+
exit 0
|
data/ext/crlibm/log-de.c
ADDED
@@ -0,0 +1,431 @@
|
|
1
|
+
/*
|
2
|
+
*this function computes log, correctly rounded,
|
3
|
+
using experimental techniques based on double-extended arithmetic
|
4
|
+
|
5
|
+
THIS IS EXPERIMENTAL SOFTWARE
|
6
|
+
|
7
|
+
In particular it changes rounding modes all the time without warning
|
8
|
+
nor restoring.
|
9
|
+
|
10
|
+
*
|
11
|
+
* Author : Florent de Dinechin
|
12
|
+
* Florent.de.Dinechin at ens-lyon.fr
|
13
|
+
*
|
14
|
+
|
15
|
+
To have it replace the crlibm log, do:
|
16
|
+
|
17
|
+
on pentium,
|
18
|
+
gcc -DHAVE_CONFIG_H -I. -fPIC -O2 -c log-de.c; mv log-de.o log_fast.o; make
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
on itanium, use icc 8.1 or higher.
|
24
|
+
|
25
|
+
icc -DHAVE_CONFIG_H -Qoption,cpp,--extended_float_types \
|
26
|
+
-IPF_fp_speculationsafe -c log-de.c;\
|
27
|
+
mv log-de.o log-td.o; make
|
28
|
+
|
29
|
+
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
#include <stdio.h>
|
34
|
+
#include <stdlib.h>
|
35
|
+
#include "crlibm.h"
|
36
|
+
#include "crlibm_private.h"
|
37
|
+
#include "double-extended.h"
|
38
|
+
#include "log-de.h"
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
static void log_accurate(double_ext* prh, double_ext* prl, double_ext z, int E, int index) {
|
43
|
+
|
44
|
+
double_ext th, tl, eh,el, t;
|
45
|
+
|
46
|
+
#if !(defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64))
|
47
|
+
double_ext c1h,c2h,c3h,c4h,c5h,c6h,c7h,c8h,c9h,c10h,c11h,c12h,c13h,c14h,c15h;
|
48
|
+
double_ext c1l,c2l,c3l,c4l,c5l,c6l,c7l,c8l;
|
49
|
+
#endif
|
50
|
+
|
51
|
+
|
52
|
+
#if EVAL_PERF
|
53
|
+
crlibm_second_step_taken++;
|
54
|
+
#endif
|
55
|
+
|
56
|
+
/* TODO check the conditions for the double-double ops */
|
57
|
+
|
58
|
+
|
59
|
+
PREFETCH_POLY_ACCURATE;
|
60
|
+
t = c14h;
|
61
|
+
t = c13h + z*t;
|
62
|
+
t = c12h + z*t;
|
63
|
+
t = c11h + z*t;
|
64
|
+
t = c10h + z*t;
|
65
|
+
t = c9h + z*t;
|
66
|
+
t = c8h + z*t;
|
67
|
+
Mul12_ext(&th, &tl, z, t);
|
68
|
+
Add22_ext(&th, &tl, th,tl, c7h,c7l);
|
69
|
+
FMA22_ext(&th, &tl, z,0, t,0, c7h,c7l);
|
70
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c6h,c6l);
|
71
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c5h,c5l);
|
72
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c4h,c4l);
|
73
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c3h,c3l);
|
74
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c2h,c2l);
|
75
|
+
FMA22_ext(&th, &tl, z,0, th,tl, c1h,c1l);
|
76
|
+
FMA22_ext(&th, &tl, z,0, th,tl, argredtable[index].logirh, argredtable[index].logirl);
|
77
|
+
|
78
|
+
Mul22_ext(&eh, &el, log2h,log2l, E, 0);
|
79
|
+
Add22_ext(prh, prl, eh,el, th,tl);
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
double log_rn(double x) {
|
90
|
+
double_ext logirh, r, y, z, z2,z4, th, tl, p01, p23, p45, p67, p03, p47, p07, logde;
|
91
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
92
|
+
db_number xdb;
|
93
|
+
int E, index, index0, roundtestmask;
|
94
|
+
#else
|
95
|
+
int64_t E, i;
|
96
|
+
uint64_t index, roundtestmask;
|
97
|
+
double_ext c1,c2,c3,c4,c5,c6,c7;
|
98
|
+
#endif
|
99
|
+
|
100
|
+
|
101
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
102
|
+
xdb.d=x;
|
103
|
+
|
104
|
+
index0 = (xdb.i[HI] & 0x000fffff);
|
105
|
+
index = (index0 + (1<<(20-L-1))) >> (20-L);
|
106
|
+
E = (xdb.i[HI]>>20)-1023; /* extract the exponent */
|
107
|
+
|
108
|
+
/* Filter cases */
|
109
|
+
if (xdb.i[HI] < 0x00100000){ /* x < 2^(-1022) */
|
110
|
+
if (((xdb.i[HI] & 0x7fffffff)|xdb.i[LO])==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
111
|
+
if (xdb.i[HI] < 0) return (x-x)/0; /* log(-x) = Nan */
|
112
|
+
/* Else subnormal number */
|
113
|
+
xdb.d *= two64; /* make x a normal number */
|
114
|
+
E = -64 + (xdb.i[HI]>>20)-1023; /* extract the exponent */
|
115
|
+
index0 = (xdb.i[HI] & 0x000fffff);
|
116
|
+
index = (index0 + (1<<(20-L-1))) >> (20-L);
|
117
|
+
}
|
118
|
+
if (xdb.i[HI] >= 0x7ff00000) return x+x; /* Inf or Nan */
|
119
|
+
|
120
|
+
DOUBLE_EXTENDED_MODE; /* This one should be overlapped with following integer computation */
|
121
|
+
|
122
|
+
/* Extract exponent and mantissa */
|
123
|
+
xdb.i[HI] = index0 | 0x3ff00000; /* do exponent = 0 */
|
124
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
125
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
126
|
+
xdb.i[HI] -= 0x00100000;
|
127
|
+
index = index & INDEXMASK;
|
128
|
+
E++;
|
129
|
+
}
|
130
|
+
y = xdb.d;
|
131
|
+
|
132
|
+
#else /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
133
|
+
/* Here come the code specific to Itanium processor */
|
134
|
+
E=0;
|
135
|
+
PREFETCH_POLY_QUICK; /* defined in log-de.h */
|
136
|
+
y=x;
|
137
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* Cast y to a 64-bit integer */
|
138
|
+
|
139
|
+
/* Filter special cases */
|
140
|
+
if (i<(int64_t)ULL(0010000000000000)){ /* equivalent to : x < 2^(-1022) */
|
141
|
+
if ((i & ULL(7fffffffffffffff))==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
142
|
+
if (i<0) return (x-x)/0; /* log(-x) = Nan */
|
143
|
+
/* Else subnormal number */
|
144
|
+
y *= two64; /* make x a normal number */
|
145
|
+
E = -64;
|
146
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* and update i */
|
147
|
+
}
|
148
|
+
if (i >= ULL(7ff0000000000000)) return x+x; /* Inf or Nan */
|
149
|
+
|
150
|
+
/* Extract exponent and mantissa */
|
151
|
+
E += (i>>52)-1023;
|
152
|
+
i = i & ULL(000fffffffffffff); /* keep only mantissa */
|
153
|
+
index = (i + (ULL(1)<<(52-L-1))) >> (52-L);
|
154
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
155
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
156
|
+
y = _Asm_setf(2/*_FR_D*/, (i | ULL(3ff0000000000000)) - ULL(0010000000000000) ); /* exponent = -1 */
|
157
|
+
index = index & INDEXMASK;
|
158
|
+
E++;
|
159
|
+
}
|
160
|
+
else
|
161
|
+
y = _Asm_setf(2/*_FR_D*/, i | ULL(3ff0000000000000) ); /* exponent = 0*/
|
162
|
+
#endif /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
/* All the previous argument reduction was exact */
|
167
|
+
/* now y holds 1+f, and E is the exponent */
|
168
|
+
|
169
|
+
r = (double_ext) (argredtable[index].r); /* approx to 1/y.d */
|
170
|
+
logirh = argredtable[index].logirh;
|
171
|
+
z = y*r - 1. ; /* even without an FMA, all exact */
|
172
|
+
|
173
|
+
if(E==0)
|
174
|
+
roundtestmask=ACCURATE_TO_61_BITS;
|
175
|
+
else
|
176
|
+
roundtestmask=ACCURATE_TO_62_BITS;
|
177
|
+
|
178
|
+
/* Estrin polynomial evaluation */
|
179
|
+
z2 = z*z; p67 = c6 + z*c7; p45 = c4 + z*c5; p23 = c2 + z*c3; p01 = logirh + z;
|
180
|
+
z4 = z2*z2; p47 = p45 + z2*p67; p03 = p01 + z2*p23;
|
181
|
+
p07 = p03 + z4*p47;
|
182
|
+
logde = p07 + E*log2h;
|
183
|
+
#if 0 /* to time the first step only */
|
184
|
+
BACK_TO_DOUBLE_MODE; return (double)t;
|
185
|
+
#endif
|
186
|
+
|
187
|
+
|
188
|
+
/* To test the second step only, comment out the following line */
|
189
|
+
DE_TEST_AND_RETURN_RN(logde, roundtestmask);
|
190
|
+
|
191
|
+
|
192
|
+
log_accurate(&th, &tl, z, E, index);
|
193
|
+
|
194
|
+
BACK_TO_DOUBLE_MODE;
|
195
|
+
|
196
|
+
return (double) (th+tl); /* The exact sum of these double-extended is rounded to the nearest */
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
double log_rd(double x) {
|
209
|
+
double_ext logirh, r, y, z, z2,z4, th, tl, p01, p23, p45, p67, p03, p47, p07, logde;
|
210
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
211
|
+
db_number xdb;
|
212
|
+
int E, index, roundtestmask;
|
213
|
+
#else
|
214
|
+
int64_t E, i;
|
215
|
+
uint64_t index, roundtestmask;
|
216
|
+
double_ext c1,c2,c3,c4,c5,c6,c7;
|
217
|
+
#endif
|
218
|
+
|
219
|
+
E=0;
|
220
|
+
|
221
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
222
|
+
xdb.d=x;
|
223
|
+
|
224
|
+
/* Filter cases */
|
225
|
+
if (xdb.i[HI] < 0x00100000){ /* x < 2^(-1022) */
|
226
|
+
if (((xdb.i[HI] & 0x7fffffff)|xdb.i[LO])==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
227
|
+
if (xdb.i[HI] < 0) return (x-x)/0; /* log(-x) = Nan */
|
228
|
+
/* Else subnormal number */
|
229
|
+
E = -64;
|
230
|
+
xdb.d *= two64; /* make x a normal number */
|
231
|
+
}
|
232
|
+
if (xdb.i[HI] >= 0x7ff00000) return x+x; /* Inf or Nan */
|
233
|
+
|
234
|
+
DOUBLE_EXTENDED_MODE; /* This one should be overlapped with following integer computation */
|
235
|
+
|
236
|
+
/* Extract exponent and mantissa */
|
237
|
+
E += (xdb.i[HI]>>20)-1023; /* extract the exponent */
|
238
|
+
index = (xdb.i[HI] & 0x000fffff);
|
239
|
+
xdb.i[HI] = index | 0x3ff00000; /* do exponent = 0 */
|
240
|
+
index = (index + (1<<(20-L-1))) >> (20-L);
|
241
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
242
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
243
|
+
xdb.i[HI] -= 0x00100000;
|
244
|
+
E++;
|
245
|
+
}
|
246
|
+
y = xdb.d;
|
247
|
+
|
248
|
+
#else /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
249
|
+
/* Here come the code specific to Itanium processor */
|
250
|
+
PREFETCH_POLY_QUICK; /* defined in log-de.h */
|
251
|
+
y=x;
|
252
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* Cast y to a 64-bit integer */
|
253
|
+
|
254
|
+
/* Filter special cases */
|
255
|
+
if (i<(int64_t)ULL(0010000000000000)){ /* equivalent to : x < 2^(-1022) */
|
256
|
+
if ((i & ULL(7fffffffffffffff))==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
257
|
+
if (i<0) return (x-x)/0; /* log(-x) = Nan */
|
258
|
+
/* Else subnormal number */
|
259
|
+
y *= two64; /* make x a normal number */
|
260
|
+
E = -64;
|
261
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* and update i */
|
262
|
+
}
|
263
|
+
if (i >= ULL(7ff0000000000000)) return x+x; /* Inf or Nan */
|
264
|
+
|
265
|
+
/* Extract exponent and mantissa */
|
266
|
+
E += (i>>52)-1023;
|
267
|
+
i = i & ULL(000fffffffffffff); /* keep only mantissa */
|
268
|
+
index = (i + (ULL(1)<<(52-L-1))) >> (52-L);
|
269
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
270
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
271
|
+
y = _Asm_setf(2/*_FR_D*/, (i | ULL(3ff0000000000000)) - ULL(0010000000000000) ); /* exponent = -1 */
|
272
|
+
E++;
|
273
|
+
}
|
274
|
+
else
|
275
|
+
y = _Asm_setf(2/*_FR_D*/, i | ULL(3ff0000000000000) ); /* exponent = 0*/
|
276
|
+
#endif /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
277
|
+
|
278
|
+
/* All the previous argument reduction was exact */
|
279
|
+
/* now y holds 1+f, and E is the exponent */
|
280
|
+
index = index & INDEXMASK;
|
281
|
+
|
282
|
+
logirh = argredtable[index].logirh;
|
283
|
+
r = (double_ext) (argredtable[index].r); /* approx to 1/y.d */
|
284
|
+
z = y*r - 1. ; /* even without an FMA, all exact */
|
285
|
+
|
286
|
+
if(E==0)
|
287
|
+
roundtestmask=ACCURATE_TO_61_BITS;
|
288
|
+
else
|
289
|
+
roundtestmask=ACCURATE_TO_62_BITS;
|
290
|
+
|
291
|
+
/* Estrin polynomial evaluation */
|
292
|
+
z2 = z*z; p67 = c6 + z*c7; p45 = c4 + z*c5; p23 = c2 + z*c3; p01 = logirh + z;
|
293
|
+
z4 = z2*z2; p47 = p45 + z2*p67; p03 = p01 + z2*p23;
|
294
|
+
p07 = p03 + z4*p47;
|
295
|
+
logde = p07 + E*log2h;
|
296
|
+
#if 0 /* to time the first step only */
|
297
|
+
BACK_TO_DOUBLE_MODE; return (double)t;
|
298
|
+
#endif
|
299
|
+
|
300
|
+
|
301
|
+
/* To test the second step only, comment out the following line */
|
302
|
+
DE_TEST_AND_RETURN_RD(logde, roundtestmask);
|
303
|
+
|
304
|
+
log_accurate(&th, &tl, z, E, index);
|
305
|
+
|
306
|
+
RETURN_SUM_ROUNDED_DOWN(th, tl);
|
307
|
+
|
308
|
+
}
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
double log_ru(double x) {
|
320
|
+
double_ext logirh, r, y, z, z2,z4, th, tl, p01, p23, p45, p67, p03, p47, p07, logde;
|
321
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
322
|
+
db_number xdb;
|
323
|
+
int E, index, roundtestmask;
|
324
|
+
#else
|
325
|
+
int64_t E, i;
|
326
|
+
uint64_t index, roundtestmask;
|
327
|
+
double_ext c1,c2,c3,c4,c5,c6,c7;
|
328
|
+
#endif
|
329
|
+
|
330
|
+
E=0;
|
331
|
+
|
332
|
+
#if defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64)
|
333
|
+
xdb.d=x;
|
334
|
+
|
335
|
+
/* Filter cases */
|
336
|
+
if (xdb.i[HI] < 0x00100000){ /* x < 2^(-1022) */
|
337
|
+
if (((xdb.i[HI] & 0x7fffffff)|xdb.i[LO])==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
338
|
+
if (xdb.i[HI] < 0) return (x-x)/0; /* log(-x) = Nan */
|
339
|
+
/* Else subnormal number */
|
340
|
+
E = -64;
|
341
|
+
xdb.d *= two64; /* make x a normal number */
|
342
|
+
}
|
343
|
+
if (xdb.i[HI] >= 0x7ff00000) return x+x; /* Inf or Nan */
|
344
|
+
|
345
|
+
DOUBLE_EXTENDED_MODE; /* This one should be overlapped with following integer computation */
|
346
|
+
|
347
|
+
/* Extract exponent and mantissa */
|
348
|
+
E += (xdb.i[HI]>>20)-1023; /* extract the exponent */
|
349
|
+
index = (xdb.i[HI] & 0x000fffff);
|
350
|
+
xdb.i[HI] = index | 0x3ff00000; /* do exponent = 0 */
|
351
|
+
index = (index + (1<<(20-L-1))) >> (20-L);
|
352
|
+
|
353
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
354
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
355
|
+
index = index & INDEXMASK;
|
356
|
+
xdb.i[HI] -= 0x00100000;
|
357
|
+
E++;
|
358
|
+
}
|
359
|
+
y = xdb.d;
|
360
|
+
|
361
|
+
#else /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
362
|
+
/* Here come the code specific to Itanium processor */
|
363
|
+
PREFETCH_POLY_QUICK; /* defined in log-de.h */
|
364
|
+
y=x;
|
365
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* Cast y to a 64-bit integer */
|
366
|
+
|
367
|
+
/* Filter special cases */
|
368
|
+
if (i<(int64_t)ULL(0010000000000000)){ /* equivalent to : x < 2^(-1022) */
|
369
|
+
if ((i & ULL(7fffffffffffffff))==0) return -1.0/0.0; /* log(+/-0) = -Inf */
|
370
|
+
if (i<0) return (x-x)/0; /* log(-x) = Nan */
|
371
|
+
/* Else subnormal number */
|
372
|
+
y *= two64; /* make x a normal number */
|
373
|
+
E = -64;
|
374
|
+
i = _Asm_getf(2/*_FR_D*/, y); /* and update i */
|
375
|
+
}
|
376
|
+
if (i >= ULL(7ff0000000000000)) return x+x; /* Inf or Nan */
|
377
|
+
|
378
|
+
/* Extract exponent and mantissa */
|
379
|
+
E += (i>>52)-1023;
|
380
|
+
i = i & ULL(000fffffffffffff); /* keep only mantissa */
|
381
|
+
index = (i + (ULL(1)<<(52-L-1))) >> (52-L);
|
382
|
+
/* reduce such that sqrt(2)/2 < xdb.d < sqrt(2) */
|
383
|
+
if (index >= MAXINDEX){ /* corresponds to y>sqrt(2)*/
|
384
|
+
y = _Asm_setf(2/*_FR_D*/, (i | ULL(3ff0000000000000)) - ULL(0010000000000000) ); /* exponent = -1 */
|
385
|
+
index = index & INDEXMASK;
|
386
|
+
E++;
|
387
|
+
}
|
388
|
+
else
|
389
|
+
y = _Asm_setf(2/*_FR_D*/, i | ULL(3ff0000000000000) ); /* exponent = 0*/
|
390
|
+
#endif /* defined(CRLIBM_TYPECPU_X86) || defined(CRLIBM_TYPECPU_AMD64) */
|
391
|
+
|
392
|
+
/* All the previous argument reduction was exact */
|
393
|
+
/* now y holds 1+f, and E is the exponent */
|
394
|
+
|
395
|
+
logirh = argredtable[index].logirh;
|
396
|
+
r = (double_ext) (argredtable[index].r); /* approx to 1/y.d */
|
397
|
+
z = y*r - 1. ; /* even without an FMA, all exact */
|
398
|
+
|
399
|
+
if(E==0)
|
400
|
+
roundtestmask=ACCURATE_TO_61_BITS;
|
401
|
+
else
|
402
|
+
roundtestmask=ACCURATE_TO_62_BITS;
|
403
|
+
|
404
|
+
/* Estrin polynomial evaluation */
|
405
|
+
z2 = z*z; p67 = c6 + z*c7; p45 = c4 + z*c5; p23 = c2 + z*c3; p01 = logirh + z;
|
406
|
+
z4 = z2*z2; p47 = p45 + z2*p67; p03 = p01 + z2*p23;
|
407
|
+
p07 = p03 + z4*p47;
|
408
|
+
logde = p07 + E*log2h;
|
409
|
+
#if 0 /* to time the first step only */
|
410
|
+
BACK_TO_DOUBLE_MODE; return (double)t;
|
411
|
+
#endif
|
412
|
+
|
413
|
+
|
414
|
+
/* To test the second step only, comment out the following line */
|
415
|
+
DE_TEST_AND_RETURN_RU(logde, roundtestmask);
|
416
|
+
|
417
|
+
log_accurate(&th, &tl, z, E, index);
|
418
|
+
|
419
|
+
RETURN_SUM_ROUNDED_UP(th, tl);
|
420
|
+
|
421
|
+
}
|
422
|
+
|
423
|
+
|
424
|
+
double log_rz(double x) {
|
425
|
+
if (x>1.0)
|
426
|
+
return log_rd(x);
|
427
|
+
else
|
428
|
+
return log_ru(x);
|
429
|
+
}
|
430
|
+
|
431
|
+
|