crmf 0.1.1 → 0.1.3

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 +105 -3
  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 +117 -20
  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 +108 -10
  111. data/ext/crlibm-1.0beta4.tar.gz +0 -0
@@ -0,0 +1,110 @@
1
+ /** Functions for SCS inverse and division
2
+
3
+ @file division_scs.c
4
+
5
+ @author Defour David David.Defour@ens-lyon.fr
6
+ @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
7
+
8
+ This file is part of the SCS library.
9
+
10
+
11
+ */
12
+
13
+ /*
14
+ Copyright (C) 2002 David Defour and Florent de Dinechin
15
+
16
+ This library is free software; you can redistribute it and/or
17
+ modify it under the terms of the GNU Lesser General Public
18
+ License as published by the Free Software Foundation; either
19
+ version 2.1 of the License, or (at your option) any later version.
20
+
21
+ This library is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
+ Lesser General Public License for more details.
25
+
26
+ You should have received a copy of the GNU Lesser General Public
27
+ License along with this library; if not, write to the Free Software
28
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
+
30
+ */
31
+ #include "scs.h"
32
+ #include "scs_private.h"
33
+
34
+
35
+ void scs_div_2(scs_ptr num) {
36
+ /* small function to divide by 2 any SCS number */
37
+ unsigned int carry, mask, old_value;
38
+ int i;
39
+ carry = 0x00000000;
40
+ mask = (unsigned int)(((0x1) << SCS_NB_BITS)-1);/*we now have a mask for the used bits in a word*/
41
+ /* if it's a normal number, i.e. not zero nor NaN */
42
+ if( (num->exception).d == (double) 1) {
43
+ /* first, a loop to rotate all numbers to the right*/
44
+ for(i = 0; i < SCS_NB_WORDS; i++) {
45
+ old_value = num->h_word[i];
46
+ num->h_word[i] = (old_value & !mask) | carry | ((old_value >> 1) & mask);
47
+ carry = old_value & 0x00000001;/* it can be interesting to keep the last bit of each number =) */
48
+ carry = carry << (SCS_NB_BITS-1);
49
+ }
50
+ /* In the SCS format, the first number can't be zero, so we must handle this particular case */
51
+ if (num->h_word[0] == 0){
52
+ num->index = num->index - 1;
53
+ for(i = 1; i < SCS_NB_WORDS; i++) {
54
+ num->h_word[i-1] = num->h_word[i];
55
+ }
56
+ num->h_word[SCS_NB_WORDS-1] = 0;
57
+ }
58
+ }
59
+ else {
60
+ (num->exception).d = (num->exception).d / 2;/* zero, NaN, ... */
61
+ }
62
+ }
63
+
64
+
65
+
66
+
67
+ /*
68
+ * Compute 1/x with a Newton scheme
69
+ */
70
+ void scs_inv(scs_ptr result, scs_ptr x){
71
+ scs_t tmp, res, res1, scstwo;
72
+ double app_x, inv;
73
+
74
+ scs_set(tmp, x); tmp->index = 0; scs_get_d(&app_x, tmp);
75
+
76
+ scs_set_si(scstwo, 2);
77
+ /* inv is a 53-bit approximation of 1/x */
78
+ inv = 1/app_x;
79
+
80
+ scs_set_d(res, inv);
81
+ res->index -= x->index;
82
+
83
+ /* First Newton Iteration */
84
+ scs_mul(res1, x, res);
85
+ scs_sub(res1, scstwo, res1);
86
+ scs_mul(res, res, res1);
87
+
88
+ /* Second Newton Iteration */
89
+ scs_mul(res1, x, res);
90
+ scs_sub(res1, scstwo, res1);
91
+ scs_mul(result, res, res1);
92
+
93
+ return;
94
+ }
95
+
96
+ /*
97
+ * Compute result = x/y;
98
+ */
99
+ void scs_div(scs_ptr result, scs_ptr x, scs_ptr y){
100
+ scs_t res;
101
+
102
+ if (X_EXP != 1){
103
+ R_EXP = X_EXP / Y_EXP;
104
+ return;
105
+ }
106
+
107
+ scs_inv(res, y);
108
+ scs_mul(result, res, x);
109
+ return;
110
+ }
@@ -0,0 +1,174 @@
1
+ /** Conversion of floating-point double to SCS
2
+ @file double2scs.c
3
+
4
+ @author Defour David David.Defour@ens-lyon.fr
5
+ @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
6
+
7
+ This file is part of the SCS library.
8
+ */
9
+
10
+ /*
11
+ Copyright (C) 2002 David Defour and Florent de Dinechin
12
+
13
+ This library is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU Lesser General Public
15
+ License as published by the Free Software Foundation; either
16
+ version 2.1 of the License, or (at your option) any later version.
17
+
18
+ This library is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ Lesser General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public
24
+ License along with this library; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+
27
+ */
28
+ #include "scs.h"
29
+ #include "scs_private.h"
30
+
31
+
32
+ /** Convert a double precision number in it SCS multiprecision
33
+ representation
34
+ */
35
+
36
+ void scs_set_d(scs_ptr result, double x){
37
+ db_number nb, mantissa;
38
+ int exponent, exponent_remainder;
39
+ int ind, i;
40
+
41
+ if(x>=0){R_SGN = 1; nb.d = x;}
42
+ else {R_SGN = -1; nb.d = -x;}
43
+
44
+ exponent = nb.i[HI] & 0x7ff00000 ;
45
+
46
+ if (exponent == 0x7ff00000) {
47
+ /*
48
+ * x = +/- Inf, s/qNAN
49
+ */
50
+ R_EXP = x;
51
+ for(i=0; i<SCS_NB_WORDS; i++)
52
+ R_HW[i] = 0;
53
+
54
+ R_IND = 0;
55
+ R_SGN = 1;
56
+ }
57
+
58
+ else { /* Normals, denormals, +/- 0. */
59
+
60
+ /* This number is not an exception */
61
+ R_EXP = 1;
62
+
63
+ #if 1
64
+
65
+ if (exponent == 0){
66
+ /* x is a denormal number : bring it back to the normal range */
67
+ nb.d = nb.d * SCS_RADIX_TWO_DOUBLE; /* 2^(2.SCS_NB_BITS) */
68
+ exponent = nb.i[HI] & 0x7ff00000 ;
69
+ R_IND = -2;
70
+ }else {
71
+ R_IND = 0;
72
+ }
73
+
74
+ exponent = exponent >> 20; /* get the actual value */
75
+
76
+ ind = ((exponent +((100*SCS_NB_BITS)-1023))/SCS_NB_BITS) - 100 ;
77
+ /* means : = (exponent -1023 + 100*SCS_NB_BITS)/SCS_NB_BITS -100
78
+ The business with 100*SCS_NB_BITS is to stay within the positive
79
+ range for exponent_remainder between 1 and SCS_NB_BITS */
80
+
81
+ exponent_remainder = exponent - 1022 - (SCS_NB_BITS*ind);
82
+
83
+ R_IND += ind;
84
+
85
+ /* now get the mantissa and add the implicit 1 in fp. format*/
86
+ mantissa.l = (nb.l & ULL(000fffffffffffff)) | ULL(0010000000000000);
87
+
88
+
89
+ /* and spread it over the structure
90
+ Everything here is 64-bit arithmetic */
91
+ R_HW[0] = (unsigned int) (mantissa.l >> (53 - exponent_remainder) );
92
+
93
+ /* 11 = 64-53 */
94
+ mantissa.l = (mantissa.l << (exponent_remainder+11));
95
+ R_HW[1] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
96
+ mantissa.l = (mantissa.l << SCS_NB_BITS);
97
+ R_HW[2] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
98
+ #if SCS_NB_BITS < 27
99
+ mantissa.l = (mantissa.l << SCS_NB_BITS);
100
+ R_HW[3] = (mantissa.i[HI] >> (32 - SCS_NB_BITS))& SCS_MASK_RADIX ;
101
+ #else
102
+ R_HW[3] = 0 ;
103
+ #endif
104
+
105
+ #if (SCS_NB_WORDS==8)
106
+ R_HW[4] = 0; R_HW[5] = 0; R_HW[6] = 0; R_HW[7] = 0;
107
+ #else
108
+ for(i=4; i<SCS_NB_WORDS; i++)
109
+ R_HW[i] = 0;
110
+ #endif
111
+
112
+
113
+
114
+ #else /* Other algorithm as in the research report. Slower */
115
+ R_IND = 0;
116
+
117
+ while(nb.d>SCS_RADIX_ONE_DOUBLE) {
118
+ R_IND++;
119
+ nb.d *= SCS_RADIX_MONE_DOUBLE;
120
+ }
121
+
122
+ while(nb.d<1) {
123
+ R_IND--;
124
+ nb.d *= SCS_RADIX_ONE_DOUBLE;
125
+ }
126
+
127
+ i=0;
128
+ while(nb.d != 0){
129
+ R_HW[i] = (unsigned int) nb.d;
130
+ nb.d = (nb.d - (double)R_HW[i]) * SCS_RADIX_ONE_DOUBLE;
131
+ i++;
132
+ }
133
+ for(; i<SCS_NB_WORDS; i++)
134
+ R_HW[i] = 0;
135
+
136
+ #endif
137
+
138
+ } /* end if test NaN etc */
139
+
140
+ return;
141
+ }
142
+
143
+
144
+ /**
145
+ Convert an integer number in it scs multiprecision
146
+ representation
147
+ */
148
+ void scs_set_si(scs_ptr result, int x){
149
+ unsigned int ux;
150
+ int i;
151
+
152
+ if(x>=0){R_SGN = 1; ux = (unsigned int)x;}
153
+ else {R_SGN = -1; ux = (unsigned int)-x;}
154
+
155
+
156
+ if (ux > SCS_RADIX){
157
+ R_IND = 1;
158
+ R_HW[0] = (ux - SCS_RADIX) >> SCS_NB_BITS;
159
+ R_HW[1] = ux - (R_HW[0] << SCS_NB_BITS);
160
+ }else {
161
+ R_IND = 0;
162
+ R_HW[0] = ux;
163
+ R_HW[1] = 0;
164
+ }
165
+
166
+ for(i=2; i<SCS_NB_WORDS; i++)
167
+ R_HW[i] = 0;
168
+
169
+ if (x != 0) R_EXP = 1;
170
+ else R_EXP = 0;
171
+
172
+ return;
173
+ }
174
+
@@ -0,0 +1,104 @@
1
+ /* What goes on the main page of SCSLib as generated by doxygen. */
2
+
3
+ /**@mainpage SCSLib, the Software Carry-Save multiple-precision library
4
+
5
+
6
+ @section intro Introduction
7
+
8
+ SCSLib is a fast and lightweight multiple-precision library developped
9
+ in the Arénaire project at ENS Lyon. It was developed as a building
10
+ block for evaluating elementary functions with correct rounding. Its
11
+ interesting features are:
12
+
13
+ - Compile-time selected precision: SCSLib is a fixed-precision
14
+ library, where precision is selected at compile-time for
15
+ performance. Out-of-the-box, the library ensures 210 bits of precision
16
+ (quad-double). It is easily configurable to do any precision between
17
+ twice or half that, and with a little bit more work it can in
18
+ principle ensure up to a few thousand bits.
19
+
20
+ - Floating-point format: The SCS format is a floating-point format
21
+ where exponents are machine integers (usually 32-bit numbers), which
22
+ ensures a huge exponent range.
23
+
24
+ - Supported operations: SCSLib currently offers addition/subtraction,
25
+ multiplication, and an experimental division, plus all the useful
26
+ conversion functions.
27
+
28
+ - IEEE-754 compatibility: The range of SCS numbers include the range
29
+ of IEEE double-precision numbers, including denormals and exceptional
30
+ cases. Conversions between SCS format and IEEE-754 doubles, as well as
31
+ arithmetic operations, follow the IEEE rules concerning the
32
+ exceptional cases. SCS doesn't ensure correct rounding, but provides
33
+ conversions to doubles in the four IEEE-754 rounding modes.
34
+
35
+ - Performance: SCSLib is designed to be fast. With 210 bits, it
36
+ outperforms MPF for most operations on most architectures.
37
+
38
+ - Licence: This library is distributed under the LGPL. See inside the
39
+ archive for details.
40
+
41
+
42
+ SCSLib is still under development and hasn't been tested on all
43
+ possible combinations of architecture and environment. If you think
44
+ you have found a bug, please investigate and report it.
45
+
46
+ All you need to build SCSLib is a C compiler compliant with the ANSI
47
+ C99 standard. So far we have successfully tested the following compilers:
48
+ - gcc-2.95x
49
+ - gcc-3.0x
50
+
51
+
52
+
53
+
54
+ @section install Installation
55
+
56
+ Standard installation should only require
57
+ - ./configure
58
+ - make
59
+
60
+ Compile-time options may be passed to configure
61
+ - to change the precision (default is 200 bits)
62
+ - to link with the GNU multiple-precision package MPFR
63
+ (for testing and debugging purpose)
64
+
65
+ See the INSTALL file and configure --help for details
66
+
67
+
68
+
69
+
70
+ @section using Linking with the SCS library
71
+
72
+ To use SCSLib you need to include the header file
73
+ scs.h. See the documentation of this file for details. Then you need
74
+ to link with libscs.a.
75
+
76
+ For C++ users we provide a wrapper class wrapper_scs.h that
77
+ overloads the basic arithmetic operators with SCS operations. It
78
+ hasn't been tested extensively.
79
+
80
+
81
+
82
+ @section bugs Reporting bugs
83
+
84
+ Please report bugs at the following address: scslib@ens-lyon.fr
85
+
86
+
87
+ @section copyleft Copyright and license
88
+
89
+ Copyright (C) 2002 Catherine Daramy, David Defour and Florent de Dinechin
90
+
91
+ This library is free software; you can redistribute it and/or
92
+ modify it under the terms of the GNU Lesser General Public
93
+ License as published by the Free Software Foundation; either
94
+ version 2.1 of the License, or (at your option) any later version.
95
+
96
+ This library is distributed in the hope that it will be useful,
97
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
98
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
99
+ Lesser General Public License for more details.
100
+
101
+ You should have received a copy of the GNU Lesser General Public
102
+ License along with this library; if not, write to the Free Software
103
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
104
+ */