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,486 @@
1
+ extern "C"
2
+ {
3
+ #include "scs.h"
4
+ }
5
+ #include <stdlib.h>
6
+ #include <stdio.h>
7
+ #include <math.h>
8
+ #include <iostream.h>
9
+
10
+ #ifndef SCS_WRAPPER_CPP
11
+ #define SCS_WRAPPER_CPP 1
12
+
13
+ extern "C" int scs_cmp_mant(scs_ptr , scs_ptr);
14
+
15
+ class Scs{
16
+ private:
17
+ scs scsnb;
18
+
19
+ public:
20
+ /* Constructors */
21
+ Scs(){}
22
+ Scs(double &d){scs_set_d(&scsnb, d);}
23
+ Scs(int &i){scs_set_si(&scsnb, i);}
24
+ Scs(const Scs& nb);
25
+ ~Scs(){};
26
+
27
+ /* Mutators */
28
+ void scs_set_sign (int i) {this->scsnb.sign = i;}
29
+ void scs_set_index(int i) {this->scsnb.index = i;}
30
+ void scs_set_excep(double d) {this->scsnb.exception.d = d;}
31
+ void scs_set_words(unsigned int word[SCS_NB_WORDS]){for(int i=0; i<SCS_NB_WORDS; i++) this->scsnb.h_word[i] = word[i];}
32
+
33
+ /* Cast */
34
+ operator double();
35
+ operator int();
36
+
37
+
38
+ /* Negation */
39
+ Scs operator-() const;
40
+ friend Scs fabs(const Scs &a);
41
+
42
+ /* Assignment */
43
+ Scs &operator=(const Scs &nb1);
44
+ Scs &operator=(const double nb1);
45
+ Scs &operator=(const int i){scs_set_si(&scsnb, i);}
46
+
47
+ /* Addition */
48
+ friend Scs operator+(Scs &nb1,Scs &nb2);
49
+ friend Scs operator+(Scs &nb1, const double &nb2);
50
+ friend Scs operator+(const double &nb1,Scs &nb2);
51
+ void operator+=(Scs &nb);
52
+ void operator+=(const double nb);
53
+
54
+ /* Subtraction */
55
+ friend Scs operator-(Scs &nb1,Scs &nb2);
56
+ friend Scs operator-(Scs &nb1, const double &nb2);
57
+ friend Scs operator-(const double &nb1,Scs &nb2);
58
+ void operator-=(Scs &nb);
59
+ void operator-=(const double nb);
60
+
61
+ /* Multiplication */
62
+ friend Scs operator*(Scs &nb1,Scs &nb2);
63
+ friend Scs operator*(Scs &nb1, const double &nb2);
64
+ friend Scs operator*(const double &nb1,Scs &nb2);
65
+ friend Scs operator*(Scs &nb1, const int &nb2);
66
+ friend Scs operator*(const int &nb1,Scs &nb2);
67
+ void operator*=(Scs &nb);
68
+ void operator*=(const double nb);
69
+ void operator*=(const int nb);
70
+
71
+ /* Multiplication */
72
+ friend Scs operator/(Scs &nb1,Scs &nb2);
73
+ friend Scs operator/(Scs &nb1, const double &nb2);
74
+ friend Scs operator/(const double &nb1,Scs &nb2);
75
+ void operator/=(Scs &nb);
76
+ void operator/=(const double nb);
77
+
78
+ /* Comparisons */
79
+ friend bool operator==(Scs &nb1,Scs &nb2);
80
+ friend bool operator!=(Scs &nb1,Scs &nb2);
81
+ friend bool operator<=(Scs &nb1,Scs &nb2);
82
+ friend bool operator>=(Scs &nb1,Scs &nb2);
83
+ friend bool operator<(Scs &nb1,Scs &nb2);
84
+ friend bool operator>(Scs &nb1,Scs &nb2);
85
+
86
+ /* Random Number */
87
+ Scs rand(void);
88
+
89
+ /* Input/Output */
90
+ friend ostream& operator<<(ostream &s, const Scs &a);
91
+ friend istream& operator>>(istream &s, Scs &a);
92
+
93
+ };
94
+
95
+
96
+
97
+
98
+ /**************
99
+ * CONSTRUCTOR
100
+ **************/
101
+ Scs::Scs(const Scs& nb){
102
+ unsigned int i;
103
+
104
+ for(i=0; i<SCS_NB_WORDS; i++)
105
+ this->scsnb.h_word[i] = nb.scsnb.h_word[i];
106
+
107
+ this->scsnb.exception.d = nb.scsnb.exception.d;
108
+ this->scsnb.index = nb.scsnb.index;
109
+ this->scsnb.sign = nb.scsnb.sign;
110
+ }
111
+
112
+ /**************
113
+ * CAST
114
+ **************/
115
+ inline Scs::operator double() {
116
+ double d;
117
+ scs_get_d(&d, &(this->scsnb));
118
+ return d;
119
+ }
120
+ inline Scs::operator int() {
121
+ double d;
122
+ scs_get_d(&d, &(this->scsnb));
123
+ return ((int)d);
124
+ }
125
+
126
+
127
+
128
+ /**************
129
+ * ASSIGNATION
130
+ **************/
131
+ inline Scs &Scs::operator=(const Scs& nb){
132
+ unsigned int i;
133
+
134
+ for(i=0; i<SCS_NB_WORDS; i++)
135
+ scsnb.h_word[i] = nb.scsnb.h_word[i];
136
+
137
+ scsnb.exception.d = nb.scsnb.exception.d;
138
+ scsnb.index = nb.scsnb.index;
139
+ scsnb.sign = nb.scsnb.sign;
140
+
141
+ return *this;
142
+ }
143
+ inline Scs &Scs::operator=(const double nb){
144
+ scs_set_d(&(this->scsnb), nb);
145
+ return *this;
146
+ }
147
+ inline Scs fabs(const Scs &a){
148
+ Scs res(a);
149
+ res.scsnb.sign = 1;
150
+ return res;
151
+ }
152
+
153
+
154
+ /************
155
+ * ADDITION
156
+ ************/
157
+ inline Scs operator+(Scs &nb1,Scs &nb2){
158
+ Scs res; scs_add(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
159
+ return res;
160
+ }
161
+ inline Scs operator+(Scs &nb1,const double &nb2){
162
+ Scs res, op;
163
+ scs_set_d(&(op.scsnb), nb2);
164
+ scs_add(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
165
+ return res;
166
+ }
167
+ inline Scs operator+(const double &nb1, Scs &nb2){
168
+ Scs res, op;
169
+ scs_set_d(&(op.scsnb), nb1);
170
+ scs_add(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
171
+ return res;
172
+ }
173
+ void inline Scs::operator+=(Scs &nb) {
174
+ scs_add(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
175
+ }
176
+ void inline Scs::operator+=(const double nb) {
177
+ Scs op;
178
+ scs_set_d(&(op.scsnb), nb);
179
+ scs_add(&(this->scsnb), &(this->scsnb), &(op.scsnb));
180
+ }
181
+
182
+
183
+
184
+
185
+ /**************
186
+ * SUBTRACTION
187
+ **************/
188
+ inline Scs operator-(Scs &nb1,Scs &nb2){
189
+ Scs res; scs_sub(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
190
+ return res;
191
+ }
192
+ inline Scs operator-(Scs &nb1,const double &nb2){
193
+ Scs res, op;
194
+ scs_set_d(&(op.scsnb), nb2);
195
+ scs_sub(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
196
+ return res;
197
+ }
198
+ inline Scs operator-(const double &nb1, Scs &nb2){
199
+ Scs res, op;
200
+ scs_set_d(&(op.scsnb), nb1);
201
+ scs_sub(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
202
+ return res;
203
+ }
204
+ void inline Scs::operator-=(Scs &nb) {
205
+ scs_sub(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
206
+ }
207
+ void inline Scs::operator-=(const double nb) {
208
+ Scs op;
209
+ scs_set_d(&(op.scsnb), nb);
210
+ scs_sub(&(this->scsnb), &(this->scsnb), &(op.scsnb));
211
+ }
212
+
213
+
214
+
215
+ /*****************
216
+ * MULTIPLICATION
217
+ *****************/
218
+ inline Scs operator*(Scs &nb1,Scs &nb2){
219
+ Scs res; scs_mul(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
220
+ return res;
221
+ }
222
+ inline Scs operator*(Scs &nb1,const double &nb2){
223
+ Scs res, op;
224
+ scs_set_d(&(op.scsnb), nb2);
225
+ scs_mul(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
226
+ return res;
227
+ }
228
+ inline Scs operator*(const double &nb1, Scs &nb2){
229
+ Scs res, op;
230
+ scs_set_d(&(op.scsnb), nb1);
231
+ scs_mul(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
232
+ return res;
233
+ }
234
+ inline Scs operator*(Scs &nb1, const int &nb2){
235
+ Scs res;
236
+ scs_set(&(res.scsnb), &(nb1.scsnb));
237
+ scs_mul_ui(&(res.scsnb), nb2);
238
+ return res;
239
+ }
240
+ inline Scs operator*(const int &nb1, Scs &nb2){
241
+ Scs res;
242
+ scs_set(&(res.scsnb), &(nb2.scsnb));
243
+ scs_mul_ui(&(res.scsnb), nb1);
244
+ return res;
245
+ }
246
+ void inline Scs::operator*=(Scs &nb) {
247
+ scs_mul(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
248
+ }
249
+ void inline Scs::operator*=(const double nb) {
250
+ Scs op;
251
+ scs_set_d(&(op.scsnb), nb);
252
+ scs_mul(&(this->scsnb), &(this->scsnb), &(op.scsnb));
253
+ }
254
+ void inline Scs::operator*=(const int nb) {
255
+ scs_mul_ui(&(this->scsnb), nb);
256
+ }
257
+
258
+
259
+
260
+ /*****************
261
+ * DIVISION
262
+ *****************/
263
+ inline Scs operator/(Scs &nb1,Scs &nb2){
264
+ Scs res; scs_div(&(res.scsnb), &(nb1.scsnb), &(nb2.scsnb));
265
+ return res;
266
+ }
267
+ inline Scs operator/(Scs &nb1, const double &nb2){
268
+ Scs res, op;
269
+ scs_set_d(&(op.scsnb), nb2);
270
+ scs_div(&(res.scsnb), &(nb1.scsnb), &(op.scsnb));
271
+ return res;
272
+ }
273
+ inline Scs operator/(const double &nb1, Scs &nb2){
274
+ Scs res, op;
275
+ scs_set_d(&(op.scsnb), nb1);
276
+ scs_div(&(res.scsnb), &(nb2.scsnb), &(op.scsnb));
277
+ return res;
278
+ }
279
+ void inline Scs::operator/=(Scs &nb) {
280
+ scs_div(&(this->scsnb), &(this->scsnb), &(nb.scsnb));
281
+ }
282
+ void inline Scs::operator/=(const double nb) {
283
+ Scs op;
284
+ scs_set_d(&(op.scsnb), nb);
285
+ scs_div(&(this->scsnb), &(this->scsnb), &(op.scsnb));
286
+ }
287
+
288
+
289
+
290
+ /*************
291
+ * COMPARISON
292
+ *************/
293
+ inline bool operator==(Scs &nb1, Scs &nb2){
294
+ unsigned int i;
295
+ bool b=1;
296
+
297
+ for(i=0; i<SCS_NB_WORDS; i++)
298
+ if (nb1.scsnb.h_word[i] == nb2.scsnb.h_word[i]) b=0;
299
+
300
+ return ((nb1.scsnb.exception.d == nb2.scsnb.exception.d)&&
301
+ (nb1.scsnb.index == nb2.scsnb.index)&&
302
+ (nb1.scsnb.sign == nb2.scsnb.sign)&& b);
303
+ }
304
+ inline bool operator!=(Scs &nb1, Scs &nb2){
305
+ return !(nb1==nb2);
306
+ }
307
+ inline bool operator<=(Scs &nb1, Scs &nb2){
308
+ return ((nb1.scsnb.exception.d <= nb2.scsnb.exception.d)&&
309
+ (nb1.scsnb.sign <= nb2.scsnb.sign)&&
310
+ ((nb1.scsnb.index < nb2.scsnb.index)||
311
+ ((nb1.scsnb.index == nb2.scsnb.index)&&
312
+ (scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))<=0))));
313
+ }
314
+ inline bool operator>=(Scs &nb1, Scs &nb2){
315
+ return ((nb1.scsnb.exception.d >= nb2.scsnb.exception.d)&&
316
+ (nb1.scsnb.sign >= nb2.scsnb.sign)&&
317
+ ((nb1.scsnb.index > nb2.scsnb.index)||
318
+ ((nb1.scsnb.index == nb2.scsnb.index)&&
319
+ (scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))>=0))));
320
+ }
321
+ inline bool operator<(Scs &nb1, Scs &nb2){
322
+ return ((nb1.scsnb.exception.d <= nb2.scsnb.exception.d)&&
323
+ (nb1.scsnb.sign <= nb2.scsnb.sign)&&
324
+ ((nb1.scsnb.index < nb2.scsnb.index)||
325
+ ((nb1.scsnb.index == nb2.scsnb.index)&&
326
+ (scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))<0))));
327
+ }
328
+ inline bool operator>(Scs &nb1, Scs &nb2){
329
+ return ((nb1.scsnb.exception.d >= nb2.scsnb.exception.d)&&
330
+ (nb1.scsnb.sign >= nb2.scsnb.sign)&&
331
+ ((nb1.scsnb.index > nb2.scsnb.index)||
332
+ ((nb1.scsnb.index == nb2.scsnb.index)&&
333
+ (scs_cmp_mant(&(nb1.scsnb), &(nb2.scsnb))>0))));
334
+ }
335
+
336
+
337
+
338
+
339
+ /****************
340
+ * RANDOM NUMBER
341
+ ****************/
342
+ inline Scs Scs::rand(void){
343
+ scs_rand(&(this->scsnb), 200);
344
+ return *this;
345
+ }
346
+
347
+
348
+
349
+
350
+ /***************
351
+ * OUTPUT (in hexadecimal)
352
+ ***************/
353
+ ostream &operator<<(ostream &os, const Scs &a){
354
+ Scs aa, p, zer;
355
+ double d;
356
+ char buffer[10];
357
+ int e, exposant;
358
+ bool bb;
359
+
360
+ if (a.scsnb.exception.d != 1.){
361
+ os << (double)a.scsnb.exception.d;
362
+ }else {
363
+ if (a.scsnb.sign == -1)
364
+ os << '-';
365
+
366
+ aa = fabs(a);
367
+
368
+ /* Compute the exposant in radix 16 */
369
+ d = ((a.scsnb.index)*SCS_NB_BITS)/4;
370
+ e = 4*(int)floor(d);
371
+
372
+ p = 1;
373
+ p.scsnb.index = (int)floor(((double)e)/SCS_NB_BITS);
374
+ p.scsnb.h_word[0] = 1 << e - p.scsnb.index*SCS_NB_BITS;
375
+ exposant = (int)floor(d);
376
+ p /= 16;
377
+ exposant--;
378
+ while(p <= aa){
379
+ p *= 16;
380
+ exposant++;
381
+ }
382
+ p /= 16;
383
+ exposant--;
384
+
385
+ /* Extract digits */
386
+ aa = aa / p;
387
+ sprintf(buffer,"%x", aa.scsnb.h_word[0]);
388
+ os << buffer << ".";
389
+ aa.scsnb.h_word[0] = 0;
390
+ aa *= 16;
391
+
392
+ bb = 1;
393
+ while(bb){
394
+ sprintf(buffer,"%x", aa.scsnb.h_word[0]);
395
+ os << buffer;
396
+ aa.scsnb.h_word[0] = 0;
397
+ aa *= 16;
398
+
399
+ bb = 0;
400
+ for(int i=0; i<SCS_NB_WORDS; i++)
401
+ if (aa.scsnb.h_word[i] != 0) bb=1;
402
+ }
403
+
404
+ /* Write the exponent */
405
+ os << " x16^(" << exposant <<")";
406
+ }
407
+
408
+ return os;
409
+ }
410
+
411
+
412
+ /***************
413
+ * INPUT (in decimal)
414
+ ***************/
415
+ istream& operator>>(istream &is, Scs &a){
416
+ char c;
417
+ int nd = 0;
418
+ int point = -1;
419
+ int ex;
420
+ bool done = false;
421
+ Scs r;
422
+
423
+ r = 0;
424
+
425
+ /* Skip any leading spaces */
426
+ do{
427
+ is>>c;
428
+ }while (c == ' ');
429
+
430
+ /* Read sign, digits, and exponent */
431
+ while (!done && (c != '\0')) {
432
+ if (c >= '0' && c <= '9') {
433
+ int d = c - '0';
434
+ r *= 10.0;
435
+ r += d;
436
+ nd++;
437
+ } else {
438
+ switch (c) {
439
+ case '.':
440
+ point = nd;
441
+ break;
442
+ case '-':
443
+ case '+':
444
+ if (nd > 0){
445
+ a = 0;
446
+ done = true;
447
+ point = -1;
448
+ ex = 0;
449
+ }
450
+ a.scsnb.sign = (c == '-') ? -1 : 1;
451
+ break;
452
+ case 'E':
453
+ case 'e':
454
+ is >> ex;
455
+ done = true;
456
+ break;
457
+ default:
458
+ a = 0;
459
+ done = true;
460
+ point = -1;
461
+ ex = 0;
462
+ }
463
+ }
464
+ is>>c;
465
+ }
466
+
467
+ if (point >= 0)
468
+ ex -= (nd - point);
469
+
470
+
471
+ if (ex != 0) {
472
+ if (ex > 0)
473
+ for(int i=0; i<ex; i++)
474
+ r *= 10;
475
+ if (ex < 0){
476
+ Scs inv_ten, ten;
477
+ ten = 10;
478
+ scs_inv(&(inv_ten.scsnb), &(ten.scsnb) );
479
+ for(int i=0; i>ex; i--)
480
+ r *= inv_ten;
481
+ }
482
+ }
483
+ }
484
+ #endif
485
+
486
+
@@ -0,0 +1,52 @@
1
+ /** Function for setting an SCS number to zero
2
+ @file zero_scs.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
+
29
+
30
+ #include "scs.h"
31
+ #include "scs_private.h"
32
+
33
+
34
+ /** Set a SCS number to zero.
35
+ There should be a few simple functions in this library.
36
+ */
37
+
38
+
39
+
40
+ void inline scs_zero(scs_ptr result) {
41
+ int i;
42
+
43
+ for(i=0; i<SCS_NB_WORDS; i++)
44
+ R_HW[i] = 0;
45
+
46
+ R_EXP = 0;
47
+ R_IND = 0;
48
+ R_SGN = 1;
49
+ }
50
+
51
+
52
+