crmf 0.1.1 → 0.1.2

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/crmf.gemspec +102 -1
  4. data/ext/crlibm-1.0beta5/AUTHORS +2 -0
  5. data/ext/crlibm-1.0beta5/CMakeLists.txt +154 -0
  6. data/ext/crlibm-1.0beta5/COPYING +340 -0
  7. data/ext/crlibm-1.0beta5/COPYING.LIB +504 -0
  8. data/ext/crlibm-1.0beta5/ChangeLog +125 -0
  9. data/ext/crlibm-1.0beta5/Makefile.am +134 -0
  10. data/ext/crlibm-1.0beta5/NEWS +0 -0
  11. data/ext/crlibm-1.0beta5/README +31 -0
  12. data/ext/crlibm-1.0beta5/README.DEV +23 -0
  13. data/ext/crlibm-1.0beta5/README.md +5 -0
  14. data/ext/crlibm-1.0beta5/TODO +66 -0
  15. data/ext/crlibm-1.0beta5/VERSION +1 -0
  16. data/ext/crlibm-1.0beta5/acos-td.c +1195 -0
  17. data/ext/crlibm-1.0beta5/acos-td.h +629 -0
  18. data/ext/crlibm-1.0beta5/asin-td.c +1297 -0
  19. data/ext/crlibm-1.0beta5/asin-td.h +620 -0
  20. data/ext/crlibm-1.0beta5/asincos.c +4488 -0
  21. data/ext/crlibm-1.0beta5/asincos.h +575 -0
  22. data/ext/crlibm-1.0beta5/atan-itanium.c +846 -0
  23. data/ext/crlibm-1.0beta5/atan-pentium.c +280 -0
  24. data/ext/crlibm-1.0beta5/atan-pentium.h +343 -0
  25. data/ext/crlibm-1.0beta5/atan_accurate.c +341 -0
  26. data/ext/crlibm-1.0beta5/atan_accurate.h +198 -0
  27. data/ext/crlibm-1.0beta5/atan_fast.c +506 -0
  28. data/ext/crlibm-1.0beta5/atan_fast.h +680 -0
  29. data/ext/crlibm-1.0beta5/configure.ac +419 -0
  30. data/ext/crlibm-1.0beta5/crlibm.h +204 -0
  31. data/ext/crlibm-1.0beta5/crlibm.spec +42 -0
  32. data/ext/crlibm-1.0beta5/crlibm_private.c +397 -0
  33. data/ext/crlibm-1.0beta5/crlibm_private.h +1048 -0
  34. data/ext/crlibm-1.0beta5/csh_fast.c +721 -0
  35. data/ext/crlibm-1.0beta5/csh_fast.h +771 -0
  36. data/ext/crlibm-1.0beta5/double-extended.h +496 -0
  37. data/ext/crlibm-1.0beta5/exp-itanium.c +723 -0
  38. data/ext/crlibm-1.0beta5/exp-td-standalone.c +87 -0
  39. data/ext/crlibm-1.0beta5/exp-td.c +1363 -0
  40. data/ext/crlibm-1.0beta5/exp-td.h +685 -0
  41. data/ext/crlibm-1.0beta5/exp_build_coeffs/exp_fast_table.c +125 -0
  42. data/ext/crlibm-1.0beta5/expm1-standalone.c +119 -0
  43. data/ext/crlibm-1.0beta5/expm1.c +2515 -0
  44. data/ext/crlibm-1.0beta5/expm1.h +715 -0
  45. data/ext/crlibm-1.0beta5/interval.h +238 -0
  46. data/ext/crlibm-1.0beta5/log-de.c +480 -0
  47. data/ext/crlibm-1.0beta5/log-de.h +747 -0
  48. data/ext/crlibm-1.0beta5/log-de2.c +280 -0
  49. data/ext/crlibm-1.0beta5/log-de2.h +2352 -0
  50. data/ext/crlibm-1.0beta5/log-td.c +1158 -0
  51. data/ext/crlibm-1.0beta5/log-td.h +819 -0
  52. data/ext/crlibm-1.0beta5/log.c +2244 -0
  53. data/ext/crlibm-1.0beta5/log.h +1592 -0
  54. data/ext/crlibm-1.0beta5/log10-td.c +906 -0
  55. data/ext/crlibm-1.0beta5/log10-td.h +823 -0
  56. data/ext/crlibm-1.0beta5/log1p.c +1295 -0
  57. data/ext/crlibm-1.0beta5/log2-td.c +1521 -0
  58. data/ext/crlibm-1.0beta5/log2-td.h +821 -0
  59. data/ext/crlibm-1.0beta5/log2_accurate.c +330 -0
  60. data/ext/crlibm-1.0beta5/log2_accurate.h +261 -0
  61. data/ext/crlibm-1.0beta5/log_accurate.c +133 -0
  62. data/ext/crlibm-1.0beta5/log_accurate.h +261 -0
  63. data/ext/crlibm-1.0beta5/log_fast.c +360 -0
  64. data/ext/crlibm-1.0beta5/log_fast.h +440 -0
  65. data/ext/crlibm-1.0beta5/pow.c +1396 -0
  66. data/ext/crlibm-1.0beta5/pow.h +3101 -0
  67. data/ext/crlibm-1.0beta5/prepare +20 -0
  68. data/ext/crlibm-1.0beta5/rem_pio2_accurate.c +219 -0
  69. data/ext/crlibm-1.0beta5/rem_pio2_accurate.h +53 -0
  70. data/ext/crlibm-1.0beta5/scs_lib/AUTHORS +3 -0
  71. data/ext/crlibm-1.0beta5/scs_lib/COPYING +504 -0
  72. data/ext/crlibm-1.0beta5/scs_lib/ChangeLog +16 -0
  73. data/ext/crlibm-1.0beta5/scs_lib/Doxyfile.dev +939 -0
  74. data/ext/crlibm-1.0beta5/scs_lib/Doxyfile.user +939 -0
  75. data/ext/crlibm-1.0beta5/scs_lib/INSTALL +215 -0
  76. data/ext/crlibm-1.0beta5/scs_lib/Makefile.am +17 -0
  77. data/ext/crlibm-1.0beta5/scs_lib/NEWS +0 -0
  78. data/ext/crlibm-1.0beta5/scs_lib/README +9 -0
  79. data/ext/crlibm-1.0beta5/scs_lib/README.DEV +38 -0
  80. data/ext/crlibm-1.0beta5/scs_lib/TODO +4 -0
  81. data/ext/crlibm-1.0beta5/scs_lib/VERSION +1 -0
  82. data/ext/crlibm-1.0beta5/scs_lib/addition_scs.c +623 -0
  83. data/ext/crlibm-1.0beta5/scs_lib/division_scs.c +110 -0
  84. data/ext/crlibm-1.0beta5/scs_lib/double2scs.c +174 -0
  85. data/ext/crlibm-1.0beta5/scs_lib/main.dox +104 -0
  86. data/ext/crlibm-1.0beta5/scs_lib/multiplication_scs.c +339 -0
  87. data/ext/crlibm-1.0beta5/scs_lib/poly_fct.c +112 -0
  88. data/ext/crlibm-1.0beta5/scs_lib/print_scs.c +73 -0
  89. data/ext/crlibm-1.0beta5/scs_lib/rand_scs.c +63 -0
  90. data/ext/crlibm-1.0beta5/scs_lib/scs.h +353 -0
  91. data/ext/crlibm-1.0beta5/scs_lib/scs2double.c +411 -0
  92. data/ext/crlibm-1.0beta5/scs_lib/scs2mpf.c +58 -0
  93. data/ext/crlibm-1.0beta5/scs_lib/scs2mpfr.c +61 -0
  94. data/ext/crlibm-1.0beta5/scs_lib/scs_private.c +23 -0
  95. data/ext/crlibm-1.0beta5/scs_lib/scs_private.h +133 -0
  96. data/ext/crlibm-1.0beta5/scs_lib/wrapper_scs.h +486 -0
  97. data/ext/crlibm-1.0beta5/scs_lib/zero_scs.c +52 -0
  98. data/ext/crlibm-1.0beta5/trigo_accurate.c +501 -0
  99. data/ext/crlibm-1.0beta5/trigo_accurate.h +331 -0
  100. data/ext/crlibm-1.0beta5/trigo_fast.c +1243 -0
  101. data/ext/crlibm-1.0beta5/trigo_fast.h +639 -0
  102. data/ext/crlibm-1.0beta5/trigpi.c +1169 -0
  103. data/ext/crlibm-1.0beta5/trigpi.h +556 -0
  104. data/ext/crlibm-1.0beta5/triple-double.c +57 -0
  105. data/ext/crlibm-1.0beta5/triple-double.h +1380 -0
  106. data/ext/crmf/crmf.c +16 -16
  107. data/ext/crmf/extconf.rb +12 -8
  108. data/lib/crmf/version.rb +1 -1
  109. data/tests/perf.rb +100 -219
  110. metadata +104 -3
  111. data/ext/crlibm-1.0beta4.tar.gz +0 -0
@@ -0,0 +1,20 @@
1
+ #!/bin/sh --
2
+
3
+ # This script is inspired by the prepare script distributed with with
4
+ # mpfr, which is inspired by the prepare script distributed with Mutt.
5
+
6
+ if aclocal && autoheader && autoconf&& automake --add-missing -c && autoconf && ./configure $@
7
+ then
8
+ echo
9
+ echo "The crlibm source code was successfully prepared."
10
+ echo "Type 'make' to build crlibm."
11
+ echo
12
+ echo "Note: if you want to reconfigure crlibm, you can now use the 'configure'"
13
+ echo "script directly; you do not need the 'prepare' script any longer."
14
+ echo
15
+ else
16
+ echo
17
+ echo "Some part of the preparation process failed."
18
+ echo
19
+ exit 1
20
+ fi
@@ -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