intervals 0.3.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. data/VERSION.txt +1 -0
  2. data/ext/crlibm/AUTHORS +2 -0
  3. data/ext/crlibm/COPYING +504 -0
  4. data/ext/crlibm/ChangeLog +80 -0
  5. data/ext/crlibm/INSTALL +182 -0
  6. data/ext/crlibm/Makefile.am +84 -0
  7. data/ext/crlibm/Makefile.in +530 -0
  8. data/ext/crlibm/NEWS +0 -0
  9. data/ext/crlibm/README +31 -0
  10. data/ext/crlibm/TODO +47 -0
  11. data/ext/crlibm/VERSION +1 -0
  12. data/ext/crlibm/aclocal.m4 +989 -0
  13. data/ext/crlibm/atan-itanium.c +846 -0
  14. data/ext/crlibm/atan-pentium.c +261 -0
  15. data/ext/crlibm/atan_accurate.c +244 -0
  16. data/ext/crlibm/atan_accurate.h +191 -0
  17. data/ext/crlibm/atan_fast.c +324 -0
  18. data/ext/crlibm/atan_fast.h +678 -0
  19. data/ext/crlibm/config.guess +1461 -0
  20. data/ext/crlibm/config.sub +1566 -0
  21. data/ext/crlibm/configure +7517 -0
  22. data/ext/crlibm/configure.ac +364 -0
  23. data/ext/crlibm/crlibm.h +125 -0
  24. data/ext/crlibm/crlibm_config.h +149 -0
  25. data/ext/crlibm/crlibm_config.h.in +148 -0
  26. data/ext/crlibm/crlibm_private.c +293 -0
  27. data/ext/crlibm/crlibm_private.h +658 -0
  28. data/ext/crlibm/csh_fast.c +631 -0
  29. data/ext/crlibm/csh_fast.h +771 -0
  30. data/ext/crlibm/double-extended.h +496 -0
  31. data/ext/crlibm/exp-td.c +962 -0
  32. data/ext/crlibm/exp-td.h +685 -0
  33. data/ext/crlibm/exp_accurate.c +197 -0
  34. data/ext/crlibm/exp_accurate.h +85 -0
  35. data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
  36. data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
  37. data/ext/crlibm/gappa/log-de.gappa +81 -0
  38. data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
  39. data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
  40. data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
  41. data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
  42. data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
  43. data/ext/crlibm/gappa/log-td.gappa +156 -0
  44. data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
  45. data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
  46. data/ext/crlibm/install-sh +269 -0
  47. data/ext/crlibm/log-de.c +431 -0
  48. data/ext/crlibm/log-de.h +732 -0
  49. data/ext/crlibm/log-td.c +852 -0
  50. data/ext/crlibm/log-td.h +819 -0
  51. data/ext/crlibm/log10-td.c +906 -0
  52. data/ext/crlibm/log10-td.h +823 -0
  53. data/ext/crlibm/log2-td.c +935 -0
  54. data/ext/crlibm/log2-td.h +821 -0
  55. data/ext/crlibm/maple/atan.mpl +359 -0
  56. data/ext/crlibm/maple/common-procedures.mpl +997 -0
  57. data/ext/crlibm/maple/csh.mpl +446 -0
  58. data/ext/crlibm/maple/double-extended.mpl +151 -0
  59. data/ext/crlibm/maple/exp-td.mpl +195 -0
  60. data/ext/crlibm/maple/log-de.mpl +243 -0
  61. data/ext/crlibm/maple/log-td.mpl +316 -0
  62. data/ext/crlibm/maple/log10-td.mpl +345 -0
  63. data/ext/crlibm/maple/log2-td.mpl +334 -0
  64. data/ext/crlibm/maple/trigo.mpl +728 -0
  65. data/ext/crlibm/maple/triple-double.mpl +58 -0
  66. data/ext/crlibm/missing +198 -0
  67. data/ext/crlibm/mkinstalldirs +40 -0
  68. data/ext/crlibm/rem_pio2_accurate.c +219 -0
  69. data/ext/crlibm/rem_pio2_accurate.h +53 -0
  70. data/ext/crlibm/scs_lib/AUTHORS +3 -0
  71. data/ext/crlibm/scs_lib/COPYING +504 -0
  72. data/ext/crlibm/scs_lib/ChangeLog +16 -0
  73. data/ext/crlibm/scs_lib/INSTALL +215 -0
  74. data/ext/crlibm/scs_lib/Makefile.am +18 -0
  75. data/ext/crlibm/scs_lib/Makefile.in +328 -0
  76. data/ext/crlibm/scs_lib/NEWS +0 -0
  77. data/ext/crlibm/scs_lib/README +9 -0
  78. data/ext/crlibm/scs_lib/TODO +4 -0
  79. data/ext/crlibm/scs_lib/addition_scs.c +623 -0
  80. data/ext/crlibm/scs_lib/config.guess +1461 -0
  81. data/ext/crlibm/scs_lib/config.sub +1566 -0
  82. data/ext/crlibm/scs_lib/configure +6226 -0
  83. data/ext/crlibm/scs_lib/division_scs.c +110 -0
  84. data/ext/crlibm/scs_lib/double2scs.c +174 -0
  85. data/ext/crlibm/scs_lib/install-sh +269 -0
  86. data/ext/crlibm/scs_lib/missing +198 -0
  87. data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
  88. data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
  89. data/ext/crlibm/scs_lib/poly_fct.c +112 -0
  90. data/ext/crlibm/scs_lib/print_scs.c +73 -0
  91. data/ext/crlibm/scs_lib/rand_scs.c +63 -0
  92. data/ext/crlibm/scs_lib/scs.h +353 -0
  93. data/ext/crlibm/scs_lib/scs2double.c +391 -0
  94. data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
  95. data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
  96. data/ext/crlibm/scs_lib/scs_private.c +23 -0
  97. data/ext/crlibm/scs_lib/scs_private.h +133 -0
  98. data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
  99. data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
  100. data/ext/crlibm/scs_lib/zero_scs.c +52 -0
  101. data/ext/crlibm/stamp-h.in +1 -0
  102. data/ext/crlibm/tests/Makefile.am +43 -0
  103. data/ext/crlibm/tests/Makefile.in +396 -0
  104. data/ext/crlibm/tests/blind_test.c +148 -0
  105. data/ext/crlibm/tests/generate_test_vectors.c +258 -0
  106. data/ext/crlibm/tests/soak_test.c +334 -0
  107. data/ext/crlibm/tests/test_common.c +627 -0
  108. data/ext/crlibm/tests/test_common.h +28 -0
  109. data/ext/crlibm/tests/test_perf.c +570 -0
  110. data/ext/crlibm/tests/test_val.c +249 -0
  111. data/ext/crlibm/trigo_accurate.c +500 -0
  112. data/ext/crlibm/trigo_accurate.h +331 -0
  113. data/ext/crlibm/trigo_fast.c +1219 -0
  114. data/ext/crlibm/trigo_fast.h +639 -0
  115. data/ext/crlibm/triple-double.h +878 -0
  116. data/ext/extconf.rb +31 -0
  117. data/ext/fpu.c +107 -0
  118. data/ext/jamis-mod.rb +591 -0
  119. data/lib/fpu.rb +287 -0
  120. data/lib/interval.rb +1170 -0
  121. data/lib/intervals.rb +212 -0
  122. data/lib/struct_float.rb +133 -0
  123. data/test/data_atan.txt +360 -0
  124. data/test/data_cos.txt +346 -0
  125. data/test/data_cosh.txt +3322 -0
  126. data/test/data_exp.txt +3322 -0
  127. data/test/data_log.txt +141 -0
  128. data/test/data_sin.txt +140 -0
  129. data/test/data_sinh.txt +3322 -0
  130. data/test/data_tan.txt +342 -0
  131. metadata +186 -0
@@ -0,0 +1,58 @@
1
+
2
+ read "common-procedures.mpl":
3
+
4
+
5
+ #---------------------------------------------------------------------
6
+ # hi_mi_lo takes an arbitrary precision number x and returns three doubles such that:
7
+ # x ~ x_hi + x_mi + x_lo
8
+ hi_mi_lo:= proc(x)
9
+ local x_hi, x_mi, x_lo, res:
10
+ x_hi:= nearest(evalf(x)):
11
+ res:=x-x_hi:
12
+ if (res = 0) then
13
+ x_mi:=0:
14
+ x_lo:=0:
15
+ else
16
+ x_mi:=nearest(evalf(res)):
17
+ res:=x-(x_hi+x_mi);
18
+ if (res = 0) then
19
+ x_lo:=0:
20
+ else
21
+ x_lo:=nearest(evalf(res)):
22
+ end if:
23
+ end if:
24
+ x_hi,x_mi,x_lo:
25
+ end:
26
+
27
+
28
+ #---------------------------------------------------------------------
29
+ # same as hi_mi_lo, but returns hexadecimal strings
30
+ ieeehexa3:=proc(x)
31
+ local x_hi, x_mi, x_lo;
32
+ x_hi, x_mi, x_lo := hi_mi_lo(x):
33
+ ieeehexa(x_hi), ieeehexa(x_mi), ieeehexa(x_lo):
34
+ end proc:
35
+
36
+
37
+ #---------------------------------------------------------------------
38
+ #Like poly_exact, but the first n coefficients as triple doubles,
39
+ #the next m coefiicients as double doubles and the rest as doubles
40
+ #
41
+ poly_exact32:=proc(P,n,m)
42
+ local deg,i, coef, coef_hi, coef_mi, coef_lo, Q:
43
+ Q:= 0:
44
+ convert(Q, polynom):
45
+ deg:=degree(P,x):
46
+ for i from 0 to deg do
47
+ coef :=coeff(P,x,i):
48
+ coef_hi, coef_mi, coef_lo:=hi_mi_lo(coef):
49
+ Q:= Q + coef_hi*x^i:
50
+ if(i<m+n) then
51
+ Q := Q + coef_mi*x^i:
52
+ fi:
53
+ if(i<n) then
54
+ Q := Q + coef_lo*x^i:
55
+ fi:
56
+ od:
57
+ return(Q):
58
+ end:
@@ -0,0 +1,198 @@
1
+ #! /bin/sh
2
+ # Common stub for a few missing GNU programs while installing.
3
+ # Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
4
+ # Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
5
+
6
+ # This program is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2, or (at your option)
9
+ # any later version.
10
+
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ # 02111-1307, USA.
20
+
21
+ if test $# -eq 0; then
22
+ echo 1>&2 "Try \`$0 --help' for more information"
23
+ exit 1
24
+ fi
25
+
26
+ # In the cases where this matters, `missing' is being run in the
27
+ # srcdir already.
28
+ if test -f configure.in; then
29
+ configure_ac=configure.ac
30
+ else
31
+ configure_ac=configure.in
32
+ fi
33
+
34
+ case "$1" in
35
+
36
+ -h|--h|--he|--hel|--help)
37
+ echo "\
38
+ $0 [OPTION]... PROGRAM [ARGUMENT]...
39
+
40
+ Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
41
+ error status if there is no known handling for PROGRAM.
42
+
43
+ Options:
44
+ -h, --help display this help and exit
45
+ -v, --version output version information and exit
46
+
47
+ Supported PROGRAM values:
48
+ aclocal touch file \`aclocal.m4'
49
+ autoconf touch file \`configure'
50
+ autoheader touch file \`config.h.in'
51
+ automake touch all \`Makefile.in' files
52
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
53
+ flex create \`lex.yy.c', if possible, from existing .c
54
+ lex create \`lex.yy.c', if possible, from existing .c
55
+ makeinfo touch the output file
56
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
57
+ ;;
58
+
59
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
60
+ echo "missing - GNU libit 0.0"
61
+ ;;
62
+
63
+ -*)
64
+ echo 1>&2 "$0: Unknown \`$1' option"
65
+ echo 1>&2 "Try \`$0 --help' for more information"
66
+ exit 1
67
+ ;;
68
+
69
+ aclocal*)
70
+ echo 1>&2 "\
71
+ WARNING: \`$1' is missing on your system. You should only need it if
72
+ you modified \`acinclude.m4' or \`$configure_ac'. You might want
73
+ to install the \`Automake' and \`Perl' packages. Grab them from
74
+ any GNU archive site."
75
+ touch aclocal.m4
76
+ ;;
77
+
78
+ autoconf)
79
+ echo 1>&2 "\
80
+ WARNING: \`$1' is missing on your system. You should only need it if
81
+ you modified \`$configure_ac'. You might want to install the
82
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
83
+ archive site."
84
+ touch configure
85
+ ;;
86
+
87
+ autoheader)
88
+ echo 1>&2 "\
89
+ WARNING: \`$1' is missing on your system. You should only need it if
90
+ you modified \`acconfig.h' or \`$configure_ac'. You might want
91
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
92
+ from any GNU archive site."
93
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
94
+ test -z "$files" && files="config.h"
95
+ touch_files=
96
+ for f in $files; do
97
+ case "$f" in
98
+ *:*) touch_files="$touch_files "`echo "$f" |
99
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
100
+ *) touch_files="$touch_files $f.in";;
101
+ esac
102
+ done
103
+ touch $touch_files
104
+ ;;
105
+
106
+ automake*)
107
+ echo 1>&2 "\
108
+ WARNING: \`$1' is missing on your system. You should only need it if
109
+ you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
110
+ You might want to install the \`Automake' and \`Perl' packages.
111
+ Grab them from any GNU archive site."
112
+ find . -type f -name Makefile.am -print |
113
+ sed 's/\.am$/.in/' |
114
+ while read f; do touch "$f"; done
115
+ ;;
116
+
117
+ bison|yacc)
118
+ echo 1>&2 "\
119
+ WARNING: \`$1' is missing on your system. You should only need it if
120
+ you modified a \`.y' file. You may need the \`Bison' package
121
+ in order for those modifications to take effect. You can get
122
+ \`Bison' from any GNU archive site."
123
+ rm -f y.tab.c y.tab.h
124
+ if [ $# -ne 1 ]; then
125
+ eval LASTARG="\${$#}"
126
+ case "$LASTARG" in
127
+ *.y)
128
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
129
+ if [ -f "$SRCFILE" ]; then
130
+ cp "$SRCFILE" y.tab.c
131
+ fi
132
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
133
+ if [ -f "$SRCFILE" ]; then
134
+ cp "$SRCFILE" y.tab.h
135
+ fi
136
+ ;;
137
+ esac
138
+ fi
139
+ if [ ! -f y.tab.h ]; then
140
+ echo >y.tab.h
141
+ fi
142
+ if [ ! -f y.tab.c ]; then
143
+ echo 'main() { return 0; }' >y.tab.c
144
+ fi
145
+ ;;
146
+
147
+ lex|flex)
148
+ echo 1>&2 "\
149
+ WARNING: \`$1' is missing on your system. You should only need it if
150
+ you modified a \`.l' file. You may need the \`Flex' package
151
+ in order for those modifications to take effect. You can get
152
+ \`Flex' from any GNU archive site."
153
+ rm -f lex.yy.c
154
+ if [ $# -ne 1 ]; then
155
+ eval LASTARG="\${$#}"
156
+ case "$LASTARG" in
157
+ *.l)
158
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
159
+ if [ -f "$SRCFILE" ]; then
160
+ cp "$SRCFILE" lex.yy.c
161
+ fi
162
+ ;;
163
+ esac
164
+ fi
165
+ if [ ! -f lex.yy.c ]; then
166
+ echo 'main() { return 0; }' >lex.yy.c
167
+ fi
168
+ ;;
169
+
170
+ makeinfo)
171
+ echo 1>&2 "\
172
+ WARNING: \`$1' is missing on your system. You should only need it if
173
+ you modified a \`.texi' or \`.texinfo' file, or any other file
174
+ indirectly affecting the aspect of the manual. The spurious
175
+ call might also be the consequence of using a buggy \`make' (AIX,
176
+ DU, IRIX). You might want to install the \`Texinfo' package or
177
+ the \`GNU make' package. Grab either from any GNU archive site."
178
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
179
+ if test -z "$file"; then
180
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
181
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
182
+ fi
183
+ touch $file
184
+ ;;
185
+
186
+ *)
187
+ echo 1>&2 "\
188
+ WARNING: \`$1' is needed, and you do not seem to have it handy on your
189
+ system. You might have modified some files without having the
190
+ proper tools for further handling them. Check the \`README' file,
191
+ it often tells you about the needed prerequirements for installing
192
+ this package. You may also peek at any GNU archive site, in case
193
+ some other package would contain this missing \`$1' program."
194
+ exit 1
195
+ ;;
196
+ esac
197
+
198
+ exit 0
@@ -0,0 +1,40 @@
1
+ #! /bin/sh
2
+ # mkinstalldirs --- make directory hierarchy
3
+ # Author: Noah Friedman <friedman@prep.ai.mit.edu>
4
+ # Created: 1993-05-16
5
+ # Public domain
6
+
7
+ # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
8
+
9
+ errstatus=0
10
+
11
+ for file
12
+ do
13
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
14
+ shift
15
+
16
+ pathcomp=
17
+ for d
18
+ do
19
+ pathcomp="$pathcomp$d"
20
+ case "$pathcomp" in
21
+ -* ) pathcomp=./$pathcomp ;;
22
+ esac
23
+
24
+ if test ! -d "$pathcomp"; then
25
+ echo "mkdir $pathcomp"
26
+
27
+ mkdir "$pathcomp" || lasterr=$?
28
+
29
+ if test ! -d "$pathcomp"; then
30
+ errstatus=$lasterr
31
+ fi
32
+ fi
33
+
34
+ pathcomp="$pathcomp/"
35
+ done
36
+ done
37
+
38
+ exit $errstatus
39
+
40
+ # mkinstalldirs ends here
@@ -0,0 +1,219 @@
1
+ /*
2
+ * rem_pio2, used in correctly rounded trigonometric functions
3
+ *
4
+ * Author : Catherine Daramy, David Defour, Florent de Dinechin
5
+ *
6
+ * This file is part of the crlibm library developed by the Arenaire
7
+ * project at Ecole Normale Superieure de Lyon
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public License
20
+ * along with this program; if not, write to the Free Software
21
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
+ */
23
+
24
+ /**
25
+ * This file include functions to compute y=x-N*pi/2 and return the last two bits of N
26
+ * in order to know which quadrant we are considering.
27
+ *
28
+ * We use an scs representation to compute it by Payne and Hanek methods. For more information
29
+ * you can read K. C. Ng research report from Sun Microsystems:
30
+ * "Argument reduction for huge argument: Good to the last bit" (July 13, 1992)
31
+ *
32
+ */
33
+ #include "rem_pio2_accurate.h"
34
+
35
+
36
+ /**
37
+ * Case X_IND = -1:
38
+ * 0
39
+ * 2 ^
40
+ * X : <> |--| |--| |--| 0 0 0 0 0
41
+ * 2/Pi : <> |--| |--| |--| |--| .....
42
+ *
43
+ * Case X_IND = 0:
44
+ * 0
45
+ * 2 ^
46
+ * X : |--| <> |--| |--| 0 0 0 0 0
47
+ * 2/Pi : <> |--| |--| |--| |--| .....
48
+ *
49
+ * Case X_IND = 1:
50
+ * 0
51
+ * 2 ^
52
+ * X : |--| |--| <> |--| |--| 0 0 0 0 0
53
+ * 2/Pi : <> |--| |--| |--| |--| .....
54
+ *
55
+ * Case ...
56
+ *
57
+ * Step 1:
58
+ *
59
+ * Compute r = X . 2/Pi where:
60
+ * - r[0] hold the integer part. (if x>0 or the once complement integer part if x<0 )
61
+ * - r[1] to r[SCS_NB_WORDS+2] hold the reduced part
62
+ * the 3 extra 30 bits are here to prevent possible
63
+ * cancellation due to a number x too close to a
64
+ * multiple of Pi/2.
65
+ *
66
+ * Step 2:
67
+ * Compute result = (r[1] ... r[SCS_NB_WORDS]) . Pi/2.
68
+ *
69
+ * description of local variables :
70
+ * - ind : where to start multiplying into 2opi table
71
+ *
72
+ */
73
+
74
+ /* TODO OPTIM
75
+ better 64-bit multiplication, see in scs_mult */
76
+
77
+ int rem_pio2_scs(scs_ptr result, const scs_ptr x){
78
+ uint64_t r[SCS_NB_WORDS+3], tmp;
79
+ unsigned int N;
80
+ /* result r[0],...,r[10] could store till 300 bits of precision */
81
+ /* that is really enough for computing the reduced argument */
82
+ int sign, i, j, ind;
83
+ int *two_over_pi_pt;
84
+
85
+ if ((X_EXP != 1)||(X_IND < -1)){
86
+ scs_set(result, x);
87
+ return 0;
88
+ }
89
+
90
+
91
+
92
+ /* Compute the product |x| * 2/Pi */
93
+ if ((X_IND == -1)){
94
+ /* In this case we consider number between ]-1,+1[ */
95
+ /* we may use simpler algorithm such as Cody And Waite */
96
+ r[0] = 0; r[1] = 0;
97
+ r[2] = (uint64_t)(two_over_pi[0]) * X_HW[0];
98
+ r[3] = ((uint64_t)(two_over_pi[0]) * X_HW[1]
99
+ +(uint64_t)(two_over_pi[1]) * X_HW[0]);
100
+ if(X_HW[2] == 0){
101
+ for(i=4; i<(SCS_NB_WORDS+3); i++){
102
+ r[i] = ((uint64_t)(two_over_pi[i-3]) * X_HW[1]
103
+ +(uint64_t)(two_over_pi[i-2]) * X_HW[0]);
104
+ }}else {
105
+ for(i=4; i<(SCS_NB_WORDS+3); i++){
106
+ r[i] = ((uint64_t)(two_over_pi[i-4]) * X_HW[2]
107
+ +(uint64_t)(two_over_pi[i-3]) * X_HW[1]
108
+ +(uint64_t)(two_over_pi[i-2]) * X_HW[0]);
109
+ }
110
+ }
111
+ }else {
112
+ if (X_IND == 0){
113
+ r[0] = 0;
114
+ r[1] = (uint64_t)(two_over_pi[0]) * X_HW[0];
115
+ r[2] = ((uint64_t)(two_over_pi[0]) * X_HW[1]
116
+ +(uint64_t)(two_over_pi[1]) * X_HW[0]);
117
+ if(X_HW[2] == 0){
118
+ for(i=3; i<(SCS_NB_WORDS+3); i++){
119
+ r[i] = ((uint64_t)(two_over_pi[i-2]) * X_HW[1]
120
+ +(uint64_t)(two_over_pi[i-1]) * X_HW[0]);
121
+ }}else {
122
+ for(i=3; i<(SCS_NB_WORDS+3); i++){
123
+ r[i] = ((uint64_t)(two_over_pi[i-3]) * X_HW[2]
124
+ +(uint64_t)(two_over_pi[i-2]) * X_HW[1]
125
+ +(uint64_t)(two_over_pi[i-1]) * X_HW[0]);
126
+ }}
127
+ }else {
128
+ if (X_IND == 1){
129
+ r[0] = (uint64_t)(two_over_pi[0]) * X_HW[0];
130
+ r[1] = ((uint64_t)(two_over_pi[0]) * X_HW[1]
131
+ +(uint64_t)(two_over_pi[1]) * X_HW[0]);
132
+ if(X_HW[2] == 0){
133
+ for(i=2; i<(SCS_NB_WORDS+3); i++){
134
+ r[i] = ((uint64_t)(two_over_pi[i-1]) * X_HW[1]
135
+ +(uint64_t)(two_over_pi[ i ]) * X_HW[0]);
136
+ }}else {
137
+ for(i=2; i<(SCS_NB_WORDS+3); i++){
138
+ r[i] = ((uint64_t)(two_over_pi[i-2]) * X_HW[2]
139
+ +(uint64_t)(two_over_pi[i-1]) * X_HW[1]
140
+ +(uint64_t)(two_over_pi[ i ]) * X_HW[0]);
141
+ }}
142
+ }else {
143
+ if (X_IND == 2){
144
+ r[0] = ((uint64_t)(two_over_pi[0]) * X_HW[1]
145
+ +(uint64_t)(two_over_pi[1]) * X_HW[0]);
146
+ if(X_HW[2] == 0){
147
+ for(i=1; i<(SCS_NB_WORDS+3); i++){
148
+ r[i] = ((uint64_t)(two_over_pi[ i ]) * X_HW[1]
149
+ +(uint64_t)(two_over_pi[i+1]) * X_HW[0]);
150
+ }}else {
151
+ for(i=1; i<(SCS_NB_WORDS+3); i++){
152
+ r[i] = ((uint64_t)(two_over_pi[i-1]) * X_HW[2]
153
+ +(uint64_t)(two_over_pi[ i ]) * X_HW[1]
154
+ +(uint64_t)(two_over_pi[i+1]) * X_HW[0]);
155
+ }}
156
+ }else {
157
+ ind = (X_IND - 3);
158
+ two_over_pi_pt = (int*)&(two_over_pi[ind]);
159
+ if(X_HW[2] == 0){
160
+ for(i=0; i<(SCS_NB_WORDS+3); i++){
161
+ r[i] = ((uint64_t)(two_over_pi_pt[i+1]) * X_HW[1]
162
+ +(uint64_t)(two_over_pi_pt[i+2]) * X_HW[0]);
163
+ }}else {
164
+ for(i=0; i<(SCS_NB_WORDS+3); i++){
165
+ r[i] = ((uint64_t)(two_over_pi_pt[ i ]) * X_HW[2]
166
+ +(uint64_t)(two_over_pi_pt[i+1]) * X_HW[1]
167
+ +(uint64_t)(two_over_pi_pt[i+2]) * X_HW[0]);
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
174
+
175
+ /* Carry propagate */
176
+ r[SCS_NB_WORDS+1] += r[SCS_NB_WORDS+2]>>30;
177
+ for(i=(SCS_NB_WORDS+1); i>0; i--) {tmp=r[i]>>30; r[i-1] += tmp; r[i] -= (tmp<<30);}
178
+
179
+ /* The integer part is in r[0] */
180
+ N = (unsigned int)(r[0]);
181
+ #if 0
182
+ printf("r[0] = %d\n", N);
183
+ #endif
184
+
185
+
186
+ /* test if the reduced part is bigger than Pi/4 */
187
+ if (r[1] > (uint64_t)(SCS_RADIX)/2){
188
+ N += 1;
189
+ sign = -1;
190
+ for(i=1; i<(SCS_NB_WORDS+3); i++) { r[i]=((~(unsigned int)(r[i])) & 0x3fffffff);}
191
+ }
192
+ else
193
+ sign = 1;
194
+
195
+
196
+ /* Now we get the reduce argument and check for possible
197
+ * cancellation By Kahan algorithm we will have at most 2 digits
198
+ * of cancellations r[1] and r[2] in the worst case.
199
+ */
200
+ if (r[1] == 0)
201
+ if (r[2] == 0) i = 3;
202
+ else i = 2;
203
+ else i = 1;
204
+
205
+ for(j=0; j<SCS_NB_WORDS; j++) { R_HW[j] = (unsigned int)(r[i+j]);}
206
+
207
+
208
+ R_EXP = 1;
209
+ R_IND = -i;
210
+ R_SGN = sign*X_SGN;
211
+
212
+ /* Last step :
213
+ * Multiplication by pi/2
214
+ */
215
+ scs_mul(result, Pio2_ptr, result);
216
+ return X_SGN*N;
217
+ }
218
+
219
+
@@ -0,0 +1,53 @@
1
+ /*
2
+ * 2oPi[] store in hexadecimal 48 digits, each keeping 30 bits of
3
+ * 2/pi.
4
+ * We then store 1440 bits of 2/pi. which is for sure a bit too much ...
5
+ */
6
+
7
+ #include "crlibm.h"
8
+ #include "crlibm_private.h"
9
+
10
+
11
+ static const int two_over_pi[]=
12
+ {0x28be60db, 0x24e44152, 0x27f09d5f, 0x11f534dd,
13
+ 0x3036d8a5, 0x1993c439, 0x0107f945, 0x23abdebb,
14
+ 0x31586dc9, 0x06e3a424, 0x374b8019, 0x092eea09,
15
+ 0x3464873f, 0x21deb1cb, 0x04a69cfb, 0x288235f5,
16
+ 0x0baed121, 0x0e99c702, 0x1ad17df9, 0x013991d6,
17
+ 0x0e60d4ce, 0x1f49c845, 0x3e2ef7e4, 0x283b1ff8,
18
+ 0x25fff781, 0x1980fef2, 0x3c462d68, 0x0a6d1f6d,
19
+ 0x0d9fb3c9, 0x3cb09b74, 0x3d18fd9a, 0x1e5fea2d,
20
+ 0x1d49eeb1, 0x3ebe5f17, 0x2cf41ce7, 0x378a5292,
21
+ 0x3a9afed7, 0x3b11f8d5, 0x3421580c, 0x3046fc7b,
22
+ 0x1aeafc33, 0x3bc209af, 0x10d876a7, 0x2391615e,
23
+ 0x3986c219, 0x199855f1, 0x1281a102, 0x0dffd880};
24
+
25
+
26
+
27
+
28
+ /*
29
+ * This scs number store 211 bits of pi/2
30
+ */
31
+ static const scs Pio2=
32
+ {{0x00000001, 0x2487ed51, 0x042d1846, 0x26263314,
33
+ 0x1701b839, 0x28948127, 0x01114cf9, 0x23a0105d},
34
+ DB_ONE, 0, 1 };
35
+
36
+ #define Pio2_ptr (scs_ptr)(& Pio2)
37
+
38
+
39
+
40
+ #if 0
41
+
42
+ /*
43
+ * This scs number store 211 bits of pi/4
44
+ */
45
+ static const scs Pio4=
46
+ /* ~7.853982e-01 */
47
+ {{0x3243f6a8, 0x22168c23, 0x1313198a, 0x0b80dc1c,
48
+ 0x344a4093, 0x2088a67c, 0x31d0082e, 0x3ea63b13},
49
+ DB_ONE, -1, 1 };
50
+
51
+ #define Pio4_ptr ((scs_ptr)(& Pio4))
52
+
53
+ #endif
@@ -0,0 +1,3 @@
1
+ scslib, the Software Carry-Save multiple-precision library
2
+
3
+ Authors: David Defour, Catherine Daramy, Florent de Dinechin