carray 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/ca_iter_block.c +32 -30
- data/ca_iter_dimension.c +24 -22
- data/ca_iter_window.c +25 -23
- data/ca_obj_array.c +58 -56
- data/ca_obj_bitarray.c +27 -27
- data/ca_obj_bitfield.c +46 -45
- data/ca_obj_block.c +77 -72
- data/ca_obj_fake.c +20 -20
- data/ca_obj_farray.c +22 -22
- data/ca_obj_field.c +31 -30
- data/ca_obj_grid.c +63 -62
- data/ca_obj_mapping.c +35 -32
- data/ca_obj_object.c +54 -54
- data/ca_obj_reduce.c +13 -13
- data/ca_obj_refer.c +42 -39
- data/ca_obj_repeat.c +50 -47
- data/ca_obj_select.c +24 -24
- data/ca_obj_shift.c +61 -58
- data/ca_obj_transpose.c +52 -51
- data/ca_obj_unbound_repeat.c +28 -27
- data/ca_obj_window.c +77 -72
- data/carray.gemspec +0 -2
- data/carray.h +190 -163
- data/carray_access.c +137 -136
- data/carray_attribute.c +24 -13
- data/carray_call_cfunc.c +21 -21
- data/carray_cast.c +106 -110
- data/carray_cast_func.rb +17 -17
- data/carray_class.c +3 -3
- data/carray_conversion.c +15 -15
- data/carray_copy.c +27 -27
- data/carray_core.c +22 -21
- data/carray_element.c +55 -47
- data/carray_generate.c +32 -32
- data/carray_iterator.c +36 -35
- data/carray_loop.c +37 -37
- data/carray_mask.c +21 -21
- data/carray_math.rb +18 -18
- data/carray_numeric.c +1 -1
- data/carray_operator.c +19 -18
- data/carray_order.c +30 -30
- data/carray_random.c +34 -32
- data/carray_sort_addr.c +12 -12
- data/carray_stat.c +127 -127
- data/carray_stat_proc.rb +152 -141
- data/carray_test.c +16 -16
- data/carray_utils.c +58 -56
- data/ext/calculus/carray_calculus.c +19 -20
- data/ext/calculus/carray_interp.c +12 -11
- data/ext/fortio/lib/fortio/fortran_sequential.rb +2 -2
- data/ext/fortio/ruby_fortio.c +1 -1
- data/ext/imagemap/carray_imagemap.c +14 -14
- data/ext/narray/ca_wrap_narray.c +30 -21
- data/extconf.rb +5 -0
- data/lib/carray/base/basic.rb +4 -3
- data/lib/carray/base/serialize.rb +3 -3
- data/lib/carray/graphics/gnuplot.rb +10 -7
- data/lib/carray/io/csv.rb +14 -9
- data/lib/carray/io/imagemagick.rb +7 -0
- data/lib/carray/io/sqlite3.rb +6 -4
- data/mkmath.rb +20 -20
- data/ruby_carray.c +2 -0
- data/ruby_ccomplex.c +3 -3
- data/test/test_130.rb +23 -0
- data/test/test_ALL.rb +2 -1
- data/test/test_order.rb +3 -3
- data/test/test_stat.rb +2 -2
- data/version.h +4 -4
- metadata +4 -37
- data/examples/ex001.rb +0 -10
- data/examples/test-int.rb +0 -13
- data/lib/carray/autoload/autoload_io_excel.rb +0 -5
- data/lib/carray/io/excel.rb +0 -26
data/carray_random.c
CHANGED
@@ -85,11 +85,11 @@ bit_width (uint32_t max)
|
|
85
85
|
}
|
86
86
|
|
87
87
|
static void
|
88
|
-
ca_monop_random_boolean8_t (
|
88
|
+
ca_monop_random_boolean8_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
89
89
|
{
|
90
90
|
boolean8_t *q1 = (boolean8_t *) ptr1, *p1;
|
91
91
|
uint32_t val;
|
92
|
-
|
92
|
+
ca_size_t k;
|
93
93
|
|
94
94
|
if ( max > 1 ) {
|
95
95
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -100,19 +100,19 @@ ca_monop_random_boolean8_t (int n, char *ptr1, int i1, uint32_t max)
|
|
100
100
|
#endif
|
101
101
|
for (k=0; k<n; k++) {
|
102
102
|
p1 = q1 + k*i1;
|
103
|
-
val = genrand_int32();
|
103
|
+
val = (uint32_t) genrand_int32();
|
104
104
|
val >>= 31;
|
105
105
|
*(int8_t*)p1 = (int8_t) val;
|
106
106
|
}
|
107
107
|
}
|
108
108
|
|
109
109
|
static void
|
110
|
-
ca_monop_random_int8_t (
|
110
|
+
ca_monop_random_int8_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
111
111
|
{
|
112
112
|
int8_t *q1 = (int8_t *) ptr1, *p1;
|
113
113
|
uint32_t val;
|
114
114
|
int shift;
|
115
|
-
|
115
|
+
ca_size_t k;
|
116
116
|
|
117
117
|
if ( max > 0x80 ) {
|
118
118
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -126,7 +126,7 @@ ca_monop_random_int8_t (int n, char *ptr1, int i1, uint32_t max)
|
|
126
126
|
for (k=0; k<n; k++) {
|
127
127
|
p1 = q1 + k*i1;
|
128
128
|
do {
|
129
|
-
val = genrand_int32();
|
129
|
+
val = (uint32_t) genrand_int32();
|
130
130
|
val >>= shift;
|
131
131
|
} while ( val >= max );
|
132
132
|
*(int8_t*)p1 = (int8_t) val;
|
@@ -134,12 +134,12 @@ ca_monop_random_int8_t (int n, char *ptr1, int i1, uint32_t max)
|
|
134
134
|
}
|
135
135
|
|
136
136
|
static void
|
137
|
-
ca_monop_random_uint8_t (
|
137
|
+
ca_monop_random_uint8_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
138
138
|
{
|
139
139
|
uint8_t *q1 = (uint8_t *) ptr1, *p1;
|
140
140
|
uint32_t val;
|
141
141
|
int shift;
|
142
|
-
|
142
|
+
ca_size_t k;
|
143
143
|
|
144
144
|
if ( max > 0x100 ) {
|
145
145
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -153,7 +153,7 @@ ca_monop_random_uint8_t (int n, char *ptr1, int i1, uint32_t max)
|
|
153
153
|
for (k=0; k<n; k++) {
|
154
154
|
p1 = q1 + k*i1;
|
155
155
|
do {
|
156
|
-
val = genrand_int32();
|
156
|
+
val = (uint32_t) genrand_int32();
|
157
157
|
val >>= shift;
|
158
158
|
} while ( val >= max );
|
159
159
|
*(uint8_t*)p1 = (uint8_t) val;
|
@@ -161,12 +161,12 @@ ca_monop_random_uint8_t (int n, char *ptr1, int i1, uint32_t max)
|
|
161
161
|
}
|
162
162
|
|
163
163
|
static void
|
164
|
-
ca_monop_random_int16_t (
|
164
|
+
ca_monop_random_int16_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
165
165
|
{
|
166
166
|
int16_t *q1 = (int16_t *) ptr1, *p1;
|
167
167
|
uint32_t val;
|
168
168
|
int shift;
|
169
|
-
|
169
|
+
ca_size_t k;
|
170
170
|
|
171
171
|
if ( max > 0x8000 ) {
|
172
172
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -180,7 +180,7 @@ ca_monop_random_int16_t (int n, char *ptr1, int i1, uint32_t max)
|
|
180
180
|
for (k=0; k<n; k++) {
|
181
181
|
p1 = q1 + k*i1;
|
182
182
|
do {
|
183
|
-
val = genrand_int32();
|
183
|
+
val = (uint32_t) genrand_int32();
|
184
184
|
val >>= shift;
|
185
185
|
} while ( val >= max );
|
186
186
|
*(int16_t*)p1 = (int16_t) val;
|
@@ -188,12 +188,12 @@ ca_monop_random_int16_t (int n, char *ptr1, int i1, uint32_t max)
|
|
188
188
|
}
|
189
189
|
|
190
190
|
static void
|
191
|
-
ca_monop_random_uint16_t (
|
191
|
+
ca_monop_random_uint16_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
192
192
|
{
|
193
193
|
uint16_t *q1 = (uint16_t *) ptr1, *p1;
|
194
194
|
uint32_t val;
|
195
195
|
int shift;
|
196
|
-
|
196
|
+
ca_size_t k;
|
197
197
|
|
198
198
|
if ( max > 0x10000 ) {
|
199
199
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -207,7 +207,7 @@ ca_monop_random_uint16_t (int n, char *ptr1, int i1, uint32_t max)
|
|
207
207
|
for (k=0; k<n; k++) {
|
208
208
|
p1 = q1 + k*i1;
|
209
209
|
do {
|
210
|
-
val = genrand_int32();
|
210
|
+
val = (uint32_t) genrand_int32();
|
211
211
|
val >>= shift;
|
212
212
|
} while ( val >= max );
|
213
213
|
*(uint16_t*)p1 = (uint16_t) val;
|
@@ -216,12 +216,12 @@ ca_monop_random_uint16_t (int n, char *ptr1, int i1, uint32_t max)
|
|
216
216
|
|
217
217
|
|
218
218
|
static void
|
219
|
-
ca_monop_random_int32_t (
|
219
|
+
ca_monop_random_int32_t (ca_size_t n, char *ptr1, int i1, uint32_t max)
|
220
220
|
{
|
221
221
|
int32_t *q1 = (int32_t *) ptr1, *p1;
|
222
222
|
uint32_t val;
|
223
223
|
int shift;
|
224
|
-
|
224
|
+
ca_size_t k;
|
225
225
|
|
226
226
|
if ( max > 0x80000000 ) {
|
227
227
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -235,7 +235,7 @@ ca_monop_random_int32_t (int n, char *ptr1, int i1, uint32_t max)
|
|
235
235
|
for (k=0; k<n; k++) {
|
236
236
|
p1 = q1 + k*i1;
|
237
237
|
do {
|
238
|
-
val = genrand_int32();
|
238
|
+
val = (uint32_t) genrand_int32();
|
239
239
|
val >>= shift;
|
240
240
|
} while ( val >= max );
|
241
241
|
*(int32_t*)p1 = (int32_t) val;
|
@@ -243,12 +243,12 @@ ca_monop_random_int32_t (int n, char *ptr1, int i1, uint32_t max)
|
|
243
243
|
}
|
244
244
|
|
245
245
|
static void
|
246
|
-
ca_monop_random_uint32_t (
|
246
|
+
ca_monop_random_uint32_t (ca_size_t n, char *ptr1, int i1, double max)
|
247
247
|
{
|
248
248
|
uint32_t *q1 = (uint32_t *) ptr1, *p1;
|
249
249
|
uint32_t val;
|
250
250
|
int shift;
|
251
|
-
|
251
|
+
ca_size_t k;
|
252
252
|
|
253
253
|
if ( max > 4294967296.0 ) { /* 0x100000000 */
|
254
254
|
rb_raise(rb_eArgError, "given maximum number is out of range");
|
@@ -267,7 +267,7 @@ ca_monop_random_uint32_t (int n, char *ptr1, int i1, double max)
|
|
267
267
|
for (k=0; k<n; k++) {
|
268
268
|
p1 = q1 + k*i1;
|
269
269
|
do {
|
270
|
-
val = genrand_int32();
|
270
|
+
val = (uint32_t) genrand_int32();
|
271
271
|
val >>= shift;
|
272
272
|
} while ( val >= max );
|
273
273
|
*(uint32_t*)p1 = (uint32_t) val;
|
@@ -275,10 +275,10 @@ ca_monop_random_uint32_t (int n, char *ptr1, int i1, double max)
|
|
275
275
|
}
|
276
276
|
|
277
277
|
static void
|
278
|
-
ca_monop_random_float32_t(
|
278
|
+
ca_monop_random_float32_t(ca_size_t n, char *ptr1, int i1, double rmax)
|
279
279
|
{
|
280
280
|
float32_t *q1 = (float32_t *) ptr1, *p1;
|
281
|
-
|
281
|
+
ca_size_t k;
|
282
282
|
#ifdef _OPENMP
|
283
283
|
#pragma omp parallel for private(p1)
|
284
284
|
#endif
|
@@ -289,10 +289,10 @@ ca_monop_random_float32_t(int n, char *ptr1, int i1, double rmax)
|
|
289
289
|
}
|
290
290
|
|
291
291
|
static void
|
292
|
-
ca_monop_random_float64_t(
|
292
|
+
ca_monop_random_float64_t(ca_size_t n, char *ptr1, int i1, double rmax)
|
293
293
|
{
|
294
294
|
float64_t *q1 = (float64_t *) ptr1, *p1;
|
295
|
-
|
295
|
+
ca_size_t k;
|
296
296
|
#ifdef _OPENMP
|
297
297
|
#pragma omp parallel for private(p1)
|
298
298
|
#endif
|
@@ -305,10 +305,10 @@ ca_monop_random_float64_t(int n, char *ptr1, int i1, double rmax)
|
|
305
305
|
#ifdef HAVE_COMPLEX_H
|
306
306
|
|
307
307
|
static void
|
308
|
-
ca_monop_random_cmplx64_t(
|
308
|
+
ca_monop_random_cmplx64_t(ca_size_t n, char *ptr1, int i1, double rmax, double imax)
|
309
309
|
{
|
310
310
|
cmplx64_t *q1 = (cmplx64_t *) ptr1, *p1;
|
311
|
-
|
311
|
+
ca_size_t k;
|
312
312
|
#ifdef _OPENMP
|
313
313
|
#pragma omp parallel for private(p1)
|
314
314
|
#endif
|
@@ -319,10 +319,10 @@ ca_monop_random_cmplx64_t(int n, char *ptr1, int i1, double rmax, double imax)
|
|
319
319
|
}
|
320
320
|
|
321
321
|
static void
|
322
|
-
ca_monop_random_cmplx128_t(
|
322
|
+
ca_monop_random_cmplx128_t(ca_size_t n, char *ptr1, int i1, double rmax, double imax)
|
323
323
|
{
|
324
324
|
cmplx128_t *q1 = (cmplx128_t *) ptr1, *p1;
|
325
|
-
|
325
|
+
ca_size_t k;
|
326
326
|
#ifdef _OPENMP
|
327
327
|
#pragma omp parallel for private(p1)
|
328
328
|
#endif
|
@@ -334,7 +334,9 @@ ca_monop_random_cmplx128_t(int n, char *ptr1, int i1, double rmax, double imax)
|
|
334
334
|
|
335
335
|
#endif
|
336
336
|
|
337
|
-
|
337
|
+
typedef void (*ca_random_func_t)();
|
338
|
+
|
339
|
+
ca_random_func_t
|
338
340
|
ca_monop_random[CA_NTYPE] = {
|
339
341
|
ca_monop_not_implement,
|
340
342
|
ca_monop_random_boolean8_t,
|
@@ -382,7 +384,7 @@ rb_ca_random (int argc, VALUE *argv, VALUE self)
|
|
382
384
|
if ( ca_is_object_type(ca) ) {
|
383
385
|
CArray *dmy;
|
384
386
|
VALUE *p;
|
385
|
-
|
387
|
+
ca_size_t i;
|
386
388
|
|
387
389
|
rb_scan_args(argc, argv, "01", &rrmax);
|
388
390
|
if ( NIL_P(rrmax) ) {
|
@@ -513,7 +515,7 @@ ca_rand (double rmax)
|
|
513
515
|
shift = 32 - bit_width((uint32_t)rmax);
|
514
516
|
|
515
517
|
do {
|
516
|
-
val = genrand_int32();
|
518
|
+
val = (uint32_t) genrand_int32();
|
517
519
|
val >>= shift;
|
518
520
|
} while ( val >= (uint32_t) rmax );
|
519
521
|
|
data/carray_sort_addr.c
CHANGED
@@ -39,7 +39,7 @@ qcmp_## type (type *a, type *b) \
|
|
39
39
|
}
|
40
40
|
|
41
41
|
static int
|
42
|
-
qcmp_data (char *a, char *b,
|
42
|
+
qcmp_data (char *a, char *b, ca_size_t bytes)
|
43
43
|
{
|
44
44
|
int cmp;
|
45
45
|
cmp = memcmp(a, b, bytes);
|
@@ -105,7 +105,7 @@ struct cmp_base {
|
|
105
105
|
};
|
106
106
|
|
107
107
|
struct cmp_data {
|
108
|
-
|
108
|
+
ca_size_t i;
|
109
109
|
struct cmp_base *base;
|
110
110
|
};
|
111
111
|
|
@@ -115,15 +115,15 @@ qcmp_func (struct cmp_data *a, struct cmp_data *b)
|
|
115
115
|
struct cmp_base *base = a->base;
|
116
116
|
int n = base->n;
|
117
117
|
CArray **ca = base->ca;
|
118
|
-
|
119
|
-
|
118
|
+
ca_size_t ia = a->i;
|
119
|
+
ca_size_t ib = b->i;
|
120
120
|
int result;
|
121
121
|
int i;
|
122
122
|
for (i=0; i<n; i++) {
|
123
123
|
int8_t data_type = ca[i]->data_type;
|
124
124
|
char *ptr = ca[i]->ptr;
|
125
125
|
boolean8_t *m = ( ca[i]->mask ) ? (boolean8_t *) ca[i]->mask->ptr : NULL;
|
126
|
-
|
126
|
+
ca_size_t bytes = ca[i]->bytes;
|
127
127
|
if ( ( ! m ) ||
|
128
128
|
( ( ! m[ia] ) && ( ! m[ib] ) ) ) {
|
129
129
|
if ( data_type == CA_FIXLEN ) {
|
@@ -170,21 +170,21 @@ rb_ca_s_sort_addr (int argc, VALUE *argv, VALUE self)
|
|
170
170
|
CArray *co;
|
171
171
|
struct cmp_base *base;
|
172
172
|
struct cmp_data *data;
|
173
|
-
|
174
|
-
|
173
|
+
ca_size_t elements;
|
174
|
+
ca_size_t *q;
|
175
175
|
int j;
|
176
|
-
|
176
|
+
ca_size_t i;
|
177
177
|
|
178
178
|
if ( argc <= 0 ) {
|
179
179
|
rb_raise(rb_eArgError, "no arg given");
|
180
180
|
}
|
181
181
|
|
182
182
|
rb_check_carray_object(argv[0]);
|
183
|
-
elements =
|
183
|
+
elements = NUM2SIZE(rb_ca_elements(argv[0]));
|
184
184
|
|
185
185
|
for (j=0; j<argc; j++) {
|
186
186
|
rb_check_carray_object(argv[j]);
|
187
|
-
if ( elements !=
|
187
|
+
if ( elements != NUM2SIZE(rb_ca_elements(argv[j])) ) {
|
188
188
|
rb_raise(rb_eArgError, "elements mismatch");
|
189
189
|
}
|
190
190
|
}
|
@@ -214,9 +214,9 @@ rb_ca_s_sort_addr (int argc, VALUE *argv, VALUE self)
|
|
214
214
|
(int (*)(const void*,const void*)) qcmp_func);
|
215
215
|
#endif
|
216
216
|
|
217
|
-
out = rb_ca_template_with_type(argv[0],
|
217
|
+
out = rb_ca_template_with_type(argv[0], INT2NUM(CA_SIZE), INT2NUM(0));
|
218
218
|
Data_Get_Struct(out, CArray, co);
|
219
|
-
q = (
|
219
|
+
q = (ca_size_t *) co->ptr;
|
220
220
|
|
221
221
|
for (i=0; i<elements; i++) {
|
222
222
|
*q = data[i].i;
|
data/carray_stat.c
CHANGED
@@ -27,11 +27,11 @@
|
|
27
27
|
type *q = (type *) co->ptr; \
|
28
28
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
29
29
|
boolean8_t *n = NULL; \
|
30
|
-
type fval = ( ! NIL_P(rfval) ) ? from(rfval) : (type)(0.0); \
|
30
|
+
type fval = ( ! NIL_P(rfval) ) ? (type) from(rfval) : (type)(0.0); \
|
31
31
|
type min = *ptr; \
|
32
32
|
type val; \
|
33
|
-
|
34
|
-
|
33
|
+
ca_size_t count = 0; \
|
34
|
+
ca_size_t i; \
|
35
35
|
if ( m ) { \
|
36
36
|
count = 0; \
|
37
37
|
ca_create_mask(co); \
|
@@ -85,10 +85,10 @@ rb_ca_cummin (int argc, VALUE *argv, VALUE self)
|
|
85
85
|
{
|
86
86
|
volatile VALUE rmin_count = Qnil, rfval = Qnil, obj;
|
87
87
|
CArray *ca, *co;
|
88
|
-
|
88
|
+
ca_size_t min_count;
|
89
89
|
|
90
90
|
if ( argc > 0 ) {
|
91
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
91
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
92
92
|
}
|
93
93
|
|
94
94
|
Data_Get_Struct(self, CArray, ca);
|
@@ -97,7 +97,7 @@ rb_ca_cummin (int argc, VALUE *argv, VALUE self)
|
|
97
97
|
obj = ca_wrap_struct(co);
|
98
98
|
|
99
99
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
100
|
-
ca->elements - 1 :
|
100
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
101
101
|
|
102
102
|
if ( min_count < 0 ) {
|
103
103
|
min_count += ca->elements;
|
@@ -135,11 +135,11 @@ rb_ca_cummin (int argc, VALUE *argv, VALUE self)
|
|
135
135
|
type *q = (type *) co->ptr; \
|
136
136
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
137
137
|
boolean8_t *n = NULL; \
|
138
|
-
type fval = ( ! NIL_P(rfval) ) ? from(rfval) : (type)(0.0); \
|
138
|
+
type fval = ( ! NIL_P(rfval) ) ? (type) from(rfval) : (type)(0.0); \
|
139
139
|
type max = *ptr; \
|
140
140
|
type val; \
|
141
|
-
|
142
|
-
|
141
|
+
ca_size_t count = 0; \
|
142
|
+
ca_size_t i; \
|
143
143
|
if ( m ) { \
|
144
144
|
count = 0; \
|
145
145
|
ca_create_mask(co); \
|
@@ -192,10 +192,10 @@ rb_ca_cummax (int argc, VALUE *argv, VALUE self)
|
|
192
192
|
{
|
193
193
|
volatile VALUE rmin_count = Qnil, rfval = Qnil, obj;
|
194
194
|
CArray *ca, *co;
|
195
|
-
|
195
|
+
ca_size_t min_count;
|
196
196
|
|
197
197
|
if ( argc > 0 ) {
|
198
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
198
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
199
199
|
}
|
200
200
|
|
201
201
|
Data_Get_Struct(self, CArray, ca);
|
@@ -204,7 +204,7 @@ rb_ca_cummax (int argc, VALUE *argv, VALUE self)
|
|
204
204
|
obj = ca_wrap_struct(co);
|
205
205
|
|
206
206
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
207
|
-
ca->elements - 1 :
|
207
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
208
208
|
|
209
209
|
if ( min_count < 0 ) {
|
210
210
|
min_count += ca->elements;
|
@@ -243,10 +243,10 @@ rb_ca_cummax (int argc, VALUE *argv, VALUE self)
|
|
243
243
|
atype *q = (atype *) co->ptr; \
|
244
244
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
245
245
|
boolean8_t *n = NULL; \
|
246
|
-
atype fval = ( ! NIL_P(rfval) ) ? from(rfval) : (atype)(0.0); \
|
246
|
+
atype fval = ( ! NIL_P(rfval) ) ? (type) from(rfval) : (atype)(0.0); \
|
247
247
|
atype prod = (atype)(1.0); \
|
248
|
-
|
249
|
-
|
248
|
+
ca_size_t count = 0; \
|
249
|
+
ca_size_t i; \
|
250
250
|
if ( m ) { \
|
251
251
|
count = 0; \
|
252
252
|
ca_create_mask(co); \
|
@@ -284,10 +284,10 @@ rb_ca_cumprod (int argc, VALUE *argv, VALUE self)
|
|
284
284
|
{
|
285
285
|
volatile VALUE rmin_count = Qnil, rfval = Qnil;
|
286
286
|
CArray *ca, *co;
|
287
|
-
|
287
|
+
ca_size_t min_count;
|
288
288
|
|
289
289
|
if ( argc > 0 ) {
|
290
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
290
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
291
291
|
}
|
292
292
|
|
293
293
|
Data_Get_Struct(self, CArray, ca);
|
@@ -300,7 +300,7 @@ rb_ca_cumprod (int argc, VALUE *argv, VALUE self)
|
|
300
300
|
}
|
301
301
|
|
302
302
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
303
|
-
ca->elements - 1 :
|
303
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
304
304
|
|
305
305
|
if ( min_count < 0 ) {
|
306
306
|
min_count += ca->elements;
|
@@ -342,11 +342,11 @@ rb_ca_cumprod (int argc, VALUE *argv, VALUE self)
|
|
342
342
|
{ \
|
343
343
|
type *p1 = (type*)ca->ptr; \
|
344
344
|
type *p2; \
|
345
|
-
|
345
|
+
ca_size_t s2; \
|
346
346
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
347
347
|
atype sum = 0.0; \
|
348
|
-
|
349
|
-
|
348
|
+
ca_size_t count = 0; \
|
349
|
+
ca_size_t i; \
|
350
350
|
ca_set_iterator(1, cw, &p2, &s2); \
|
351
351
|
if ( m ) { \
|
352
352
|
count = 0; \
|
@@ -377,10 +377,10 @@ rb_ca_wsum (int argc, VALUE *argv, VALUE self)
|
|
377
377
|
{
|
378
378
|
volatile VALUE out, weight = argv[0], rmin_count = Qnil, rfval = Qnil, tmp;
|
379
379
|
CArray *ca, *cw;
|
380
|
-
|
380
|
+
ca_size_t min_count;
|
381
381
|
|
382
382
|
if ( argc > 1 ) {
|
383
|
-
rb_scan_args(argc, argv, "12", &weight, &rmin_count, &rfval);
|
383
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &weight, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
384
384
|
}
|
385
385
|
|
386
386
|
Data_Get_Struct(self, CArray, ca);
|
@@ -399,7 +399,7 @@ rb_ca_wsum (int argc, VALUE *argv, VALUE self)
|
|
399
399
|
}
|
400
400
|
|
401
401
|
min_count = ( NIL_P(rmin_count) || ( ! ca_has_mask(ca) ) ) ?
|
402
|
-
ca->elements - 1 :
|
402
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
403
403
|
|
404
404
|
if ( min_count < 0 ) {
|
405
405
|
min_count += ca->elements;
|
@@ -440,14 +440,14 @@ rb_ca_wsum (int argc, VALUE *argv, VALUE self)
|
|
440
440
|
{ \
|
441
441
|
type *p1 = (type *) ca->ptr; \
|
442
442
|
type *p2; \
|
443
|
-
|
443
|
+
ca_size_t s2; \
|
444
444
|
atype *q = (atype *) co->ptr; \
|
445
445
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
446
446
|
boolean8_t *n = NULL; \
|
447
|
-
atype fval = ( ! NIL_P(rfval) ) ? from(rfval) : (atype)(0.0); \
|
447
|
+
atype fval = ( ! NIL_P(rfval) ) ? (type) from(rfval) : (atype)(0.0); \
|
448
448
|
atype sum = 0.0; \
|
449
|
-
|
450
|
-
|
449
|
+
ca_size_t count = 0; \
|
450
|
+
ca_size_t i; \
|
451
451
|
ca_set_iterator(1, cw, &p2, &s2); \
|
452
452
|
if ( m ) { \
|
453
453
|
count = 0; \
|
@@ -486,10 +486,10 @@ rb_ca_cumwsum (int argc, VALUE *argv, VALUE self)
|
|
486
486
|
{
|
487
487
|
volatile VALUE weight = argv[0], rmin_count = Qnil, rfval = Qnil, tmp;
|
488
488
|
CArray *ca, *cw, *co;
|
489
|
-
|
489
|
+
ca_size_t min_count;
|
490
490
|
|
491
491
|
if ( argc > 1 ) {
|
492
|
-
rb_scan_args(argc, argv, "12", &weight, &rmin_count, &rfval);
|
492
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &weight, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
493
493
|
}
|
494
494
|
|
495
495
|
Data_Get_Struct(self, CArray, ca);
|
@@ -511,7 +511,7 @@ rb_ca_cumwsum (int argc, VALUE *argv, VALUE self)
|
|
511
511
|
}
|
512
512
|
|
513
513
|
min_count = ( NIL_P(rmin_count) || ( ! ca_has_mask(ca) ) ) ?
|
514
|
-
ca->elements - 1 :
|
514
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
515
515
|
|
516
516
|
if ( min_count < 0 ) {
|
517
517
|
min_count += ca->elements;
|
@@ -552,13 +552,13 @@ rb_ca_cumwsum (int argc, VALUE *argv, VALUE self)
|
|
552
552
|
{ \
|
553
553
|
type *p1 = (type*)ca->ptr; \
|
554
554
|
type *p2 = (type*)cw->ptr; \
|
555
|
-
|
555
|
+
ca_size_t s2; \
|
556
556
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
557
557
|
atype sum = 0.0; \
|
558
558
|
atype den = 0.0; \
|
559
559
|
atype ave; \
|
560
|
-
|
561
|
-
|
560
|
+
ca_size_t count = 0; \
|
561
|
+
ca_size_t i; \
|
562
562
|
ca_set_iterator(1, cw, &p2, &s2); \
|
563
563
|
if ( m ) { \
|
564
564
|
count = 0; \
|
@@ -591,10 +591,10 @@ rb_ca_wmean (int argc, VALUE *argv, VALUE self)
|
|
591
591
|
{
|
592
592
|
volatile VALUE out, weight = argv[0], rmin_count = Qnil, rfval = Qnil, tmp;
|
593
593
|
CArray *ca, *cw;
|
594
|
-
|
594
|
+
ca_size_t min_count;
|
595
595
|
|
596
596
|
if ( argc > 1 ) {
|
597
|
-
rb_scan_args(argc, argv, "12", &weight, &rmin_count, &rfval);
|
597
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &weight, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
598
598
|
}
|
599
599
|
|
600
600
|
Data_Get_Struct(self, CArray, ca);
|
@@ -613,7 +613,7 @@ rb_ca_wmean (int argc, VALUE *argv, VALUE self)
|
|
613
613
|
}
|
614
614
|
|
615
615
|
min_count = ( NIL_P(rmin_count) || ( ! ca_has_mask(ca) ) ) ?
|
616
|
-
ca->elements - 1 :
|
616
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
617
617
|
|
618
618
|
if ( min_count < 0 ) {
|
619
619
|
min_count += ca->elements;
|
@@ -657,9 +657,9 @@ rb_ca_wmean (int argc, VALUE *argv, VALUE self)
|
|
657
657
|
double sum = 0.0; \
|
658
658
|
double sum2 = 0.0; \
|
659
659
|
double del, var, ave; \
|
660
|
-
|
661
|
-
|
662
|
-
|
660
|
+
ca_size_t count = 0; \
|
661
|
+
ca_size_t nvalid; \
|
662
|
+
ca_size_t i; \
|
663
663
|
if ( m ) { \
|
664
664
|
count = 0; \
|
665
665
|
for (i=ca->elements; i; i--, ptr++) { \
|
@@ -708,10 +708,10 @@ rb_ca_variancep (int argc, VALUE *argv, VALUE self)
|
|
708
708
|
{
|
709
709
|
volatile VALUE out, rmin_count = Qnil, rfval = Qnil;
|
710
710
|
CArray *ca;
|
711
|
-
|
711
|
+
ca_size_t min_count;
|
712
712
|
|
713
713
|
if ( argc > 0 ) {
|
714
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
714
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
715
715
|
}
|
716
716
|
|
717
717
|
Data_Get_Struct(self, CArray, ca);
|
@@ -721,7 +721,7 @@ rb_ca_variancep (int argc, VALUE *argv, VALUE self)
|
|
721
721
|
}
|
722
722
|
|
723
723
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
724
|
-
ca->elements - 1 :
|
724
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
725
725
|
|
726
726
|
if ( min_count < 0 ) {
|
727
727
|
min_count += ca->elements;
|
@@ -760,9 +760,9 @@ rb_ca_variancep (int argc, VALUE *argv, VALUE self)
|
|
760
760
|
double sum = 0.0; \
|
761
761
|
double sum2 = 0.0; \
|
762
762
|
double del, var, ave; \
|
763
|
-
|
764
|
-
|
765
|
-
|
763
|
+
ca_size_t count = 0; \
|
764
|
+
ca_size_t nvalid; \
|
765
|
+
ca_size_t i; \
|
766
766
|
if ( m ) { \
|
767
767
|
count = 0; \
|
768
768
|
for (i=ca->elements; i; i--, ptr++) { \
|
@@ -811,10 +811,10 @@ rb_ca_variance (int argc, VALUE *argv, VALUE self)
|
|
811
811
|
{
|
812
812
|
volatile VALUE out, rmin_count = Qnil, rfval = Qnil;
|
813
813
|
CArray *ca;
|
814
|
-
|
814
|
+
ca_size_t min_count;
|
815
815
|
|
816
816
|
if ( argc > 0 ) {
|
817
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
817
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
818
818
|
}
|
819
819
|
|
820
820
|
Data_Get_Struct(self, CArray, ca);
|
@@ -824,7 +824,7 @@ rb_ca_variance (int argc, VALUE *argv, VALUE self)
|
|
824
824
|
}
|
825
825
|
|
826
826
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
827
|
-
ca->elements - 1 :
|
827
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
828
828
|
|
829
829
|
if ( min_count < 0 ) {
|
830
830
|
min_count += ca->elements;
|
@@ -859,10 +859,10 @@ rb_ca_count_true (int argc, VALUE *argv, VALUE self)
|
|
859
859
|
{
|
860
860
|
volatile VALUE out, rmin_count = Qnil, rfval = Qnil;
|
861
861
|
CArray *ca;
|
862
|
-
|
862
|
+
ca_size_t min_count;
|
863
863
|
|
864
864
|
if ( argc > 1 ) {
|
865
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
865
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
866
866
|
}
|
867
867
|
|
868
868
|
Data_Get_Struct(self, CArray, ca);
|
@@ -877,7 +877,7 @@ rb_ca_count_true (int argc, VALUE *argv, VALUE self)
|
|
877
877
|
}
|
878
878
|
|
879
879
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
880
|
-
ca->elements - 1 :
|
880
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
881
881
|
|
882
882
|
if ( min_count < 0 ) {
|
883
883
|
min_count += ca->elements;
|
@@ -888,9 +888,9 @@ rb_ca_count_true (int argc, VALUE *argv, VALUE self)
|
|
888
888
|
{
|
889
889
|
boolean8_t *ptr = (boolean8_t *) ca->ptr;
|
890
890
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL;
|
891
|
-
|
892
|
-
|
893
|
-
|
891
|
+
ca_size_t count = 0;
|
892
|
+
ca_size_t value_count = 0;
|
893
|
+
ca_size_t i;
|
894
894
|
if ( m ) {
|
895
895
|
for (i=0; i<ca->elements; i++) {
|
896
896
|
if ( *m ) {
|
@@ -914,7 +914,7 @@ rb_ca_count_true (int argc, VALUE *argv, VALUE self)
|
|
914
914
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval;
|
915
915
|
}
|
916
916
|
else {
|
917
|
-
out =
|
917
|
+
out = SIZE2NUM(value_count);
|
918
918
|
}
|
919
919
|
}
|
920
920
|
|
@@ -928,10 +928,10 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
928
928
|
{
|
929
929
|
volatile VALUE out, rmin_count = Qnil, rfval = Qnil;
|
930
930
|
CArray *ca;
|
931
|
-
|
931
|
+
ca_size_t min_count;
|
932
932
|
|
933
933
|
if ( argc > 1 ) {
|
934
|
-
rb_scan_args(argc, argv, "02", &rmin_count, &rfval);
|
934
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmin_count, (VALUE *) &rfval);
|
935
935
|
}
|
936
936
|
|
937
937
|
Data_Get_Struct(self, CArray, ca);
|
@@ -946,7 +946,7 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
946
946
|
}
|
947
947
|
|
948
948
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
949
|
-
ca->elements - 1 :
|
949
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
950
950
|
|
951
951
|
if ( min_count < 0 ) {
|
952
952
|
min_count += ca->elements;
|
@@ -957,9 +957,9 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
957
957
|
{
|
958
958
|
boolean8_t *ptr = (boolean8_t *) ca->ptr;
|
959
959
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL;
|
960
|
-
|
961
|
-
|
962
|
-
|
960
|
+
ca_size_t count = 0;
|
961
|
+
ca_size_t value_count = 0;
|
962
|
+
ca_size_t i;
|
963
963
|
if ( m ) {
|
964
964
|
for (i=0; i<ca->elements; i++) {
|
965
965
|
if ( *m ) {
|
@@ -983,7 +983,7 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
983
983
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval;
|
984
984
|
}
|
985
985
|
else {
|
986
|
-
out =
|
986
|
+
out = SIZE2NUM(value_count);
|
987
987
|
}
|
988
988
|
}
|
989
989
|
|
@@ -999,9 +999,9 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
999
999
|
type *ptr = (type *) ca->ptr; \
|
1000
1000
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1001
1001
|
type val = (type) from(value); \
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1002
|
+
ca_size_t count = 0; \
|
1003
|
+
ca_size_t value_count = 0; \
|
1004
|
+
ca_size_t i; \
|
1005
1005
|
if ( m ) { \
|
1006
1006
|
for (i=ca->elements; i; i--, ptr++) { \
|
1007
1007
|
if ( ! *m++ ) { \
|
@@ -1025,7 +1025,7 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
1025
1025
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval; \
|
1026
1026
|
} \
|
1027
1027
|
else { \
|
1028
|
-
out =
|
1028
|
+
out = SIZE2NUM(value_count); \
|
1029
1029
|
} \
|
1030
1030
|
}
|
1031
1031
|
|
@@ -1034,9 +1034,9 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
1034
1034
|
char *ptr = ca->ptr; \
|
1035
1035
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1036
1036
|
char *val = ALLOCA_N(char, ca->bytes); \
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1037
|
+
ca_size_t count = 0; \
|
1038
|
+
ca_size_t value_count = 0; \
|
1039
|
+
ca_size_t i; \
|
1040
1040
|
rb_ca_obj2ptr(self, value, val); \
|
1041
1041
|
if ( m ) { \
|
1042
1042
|
for (i=ca->elements; i; i--, ptr+=ca->bytes) {\
|
@@ -1061,7 +1061,7 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
1061
1061
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval; \
|
1062
1062
|
} \
|
1063
1063
|
else { \
|
1064
|
-
out =
|
1064
|
+
out = SIZE2NUM(value_count); \
|
1065
1065
|
} \
|
1066
1066
|
}
|
1067
1067
|
|
@@ -1070,9 +1070,9 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
1070
1070
|
VALUE *ptr = (VALUE *)ca->ptr; \
|
1071
1071
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1072
1072
|
VALUE val = value; \
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1073
|
+
ca_size_t count = 0; \
|
1074
|
+
ca_size_t value_count = 0; \
|
1075
|
+
ca_size_t i; \
|
1076
1076
|
if ( m ) { \
|
1077
1077
|
for (i=ca->elements; i; i--) {\
|
1078
1078
|
if ( ! *m++ ) { \
|
@@ -1098,7 +1098,7 @@ rb_ca_count_false (int argc, VALUE *argv, VALUE self)
|
|
1098
1098
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval; \
|
1099
1099
|
} \
|
1100
1100
|
else { \
|
1101
|
-
out =
|
1101
|
+
out = SIZE2NUM(value_count); \
|
1102
1102
|
} \
|
1103
1103
|
}
|
1104
1104
|
|
@@ -1107,9 +1107,9 @@ rb_ca_count_equal (int argc, VALUE *argv, VALUE self)
|
|
1107
1107
|
{
|
1108
1108
|
volatile VALUE out, value, rmin_count = Qnil, rfval = Qnil;
|
1109
1109
|
CArray *ca;
|
1110
|
-
|
1110
|
+
ca_size_t min_count;
|
1111
1111
|
|
1112
|
-
rb_scan_args(argc, argv, "12", &value, &rmin_count, &rfval);
|
1112
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &value, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
1113
1113
|
|
1114
1114
|
Data_Get_Struct(self, CArray, ca);
|
1115
1115
|
|
@@ -1118,7 +1118,7 @@ rb_ca_count_equal (int argc, VALUE *argv, VALUE self)
|
|
1118
1118
|
}
|
1119
1119
|
|
1120
1120
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
1121
|
-
ca->elements - 1 :
|
1121
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
1122
1122
|
|
1123
1123
|
if ( min_count < 0 ) {
|
1124
1124
|
min_count += ca->elements;
|
@@ -1163,9 +1163,9 @@ rb_ca_count_equal (int argc, VALUE *argv, VALUE self)
|
|
1163
1163
|
type val = (type) from(value); \
|
1164
1164
|
double rtol = fabs(NUM2DBL(reps)); \
|
1165
1165
|
double vabs = nabs(val); \
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1166
|
+
ca_size_t count = 0; \
|
1167
|
+
ca_size_t value_count = 0; \
|
1168
|
+
ca_size_t i; \
|
1169
1169
|
if ( m ) { \
|
1170
1170
|
for (i=ca->elements; i; i--, ptr++) { \
|
1171
1171
|
if ( ! *m++ ) { \
|
@@ -1190,7 +1190,7 @@ rb_ca_count_equal (int argc, VALUE *argv, VALUE self)
|
|
1190
1190
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval; \
|
1191
1191
|
} \
|
1192
1192
|
else { \
|
1193
|
-
out =
|
1193
|
+
out = SIZE2NUM(value_count); \
|
1194
1194
|
} \
|
1195
1195
|
}
|
1196
1196
|
|
@@ -1200,10 +1200,10 @@ rb_ca_count_equiv (int argc, VALUE *argv, VALUE self)
|
|
1200
1200
|
volatile VALUE out, value = argv[0], reps = argv[1],
|
1201
1201
|
rmin_count = Qnil, rfval = Qnil;
|
1202
1202
|
CArray *ca;
|
1203
|
-
|
1203
|
+
ca_size_t min_count;
|
1204
1204
|
|
1205
1205
|
if ( argc > 2 ) {
|
1206
|
-
rb_scan_args(argc, argv, "22", &value, &reps, &rmin_count, &rfval);
|
1206
|
+
rb_scan_args(argc, argv, "22", (VALUE *) &value, (VALUE *) &reps, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
1207
1207
|
}
|
1208
1208
|
|
1209
1209
|
Data_Get_Struct(self, CArray, ca);
|
@@ -1213,7 +1213,7 @@ rb_ca_count_equiv (int argc, VALUE *argv, VALUE self)
|
|
1213
1213
|
}
|
1214
1214
|
|
1215
1215
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
1216
|
-
ca->elements - 1 :
|
1216
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
1217
1217
|
|
1218
1218
|
if ( min_count < 0 ) {
|
1219
1219
|
min_count += ca->elements;
|
@@ -1255,9 +1255,9 @@ rb_ca_count_equiv (int argc, VALUE *argv, VALUE self)
|
|
1255
1255
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1256
1256
|
type val = (type) from(value); \
|
1257
1257
|
double atol = fabs(NUM2DBL(aeps)); \
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1258
|
+
ca_size_t count = 0; \
|
1259
|
+
ca_size_t value_count = 0; \
|
1260
|
+
ca_size_t i; \
|
1261
1261
|
if ( m ) { \
|
1262
1262
|
for (i=ca->elements; i; i--, ptr++) { \
|
1263
1263
|
if ( ! *m++ ) { \
|
@@ -1281,7 +1281,7 @@ rb_ca_count_equiv (int argc, VALUE *argv, VALUE self)
|
|
1281
1281
|
out = ( NIL_P(rfval) ) ? CA_UNDEF : rfval; \
|
1282
1282
|
} \
|
1283
1283
|
else { \
|
1284
|
-
out =
|
1284
|
+
out = SIZE2NUM(value_count); \
|
1285
1285
|
} \
|
1286
1286
|
}
|
1287
1287
|
|
@@ -1291,10 +1291,10 @@ rb_ca_count_close (int argc, VALUE *argv, VALUE self)
|
|
1291
1291
|
volatile VALUE out, value = argv[0], aeps = argv[1],
|
1292
1292
|
rmin_count = Qnil, rfval = Qnil;
|
1293
1293
|
CArray *ca;
|
1294
|
-
|
1294
|
+
ca_size_t min_count;
|
1295
1295
|
|
1296
1296
|
if ( argc > 2 ) {
|
1297
|
-
rb_scan_args(argc, argv, "22", &value, &aeps, &rmin_count, &rfval);
|
1297
|
+
rb_scan_args(argc, argv, "22", (VALUE *) &value, (VALUE *) &aeps, (VALUE *) &rmin_count, (VALUE *) &rfval);
|
1298
1298
|
}
|
1299
1299
|
|
1300
1300
|
Data_Get_Struct(self, CArray, ca);
|
@@ -1304,7 +1304,7 @@ rb_ca_count_close (int argc, VALUE *argv, VALUE self)
|
|
1304
1304
|
}
|
1305
1305
|
|
1306
1306
|
min_count = ( NIL_P(rmin_count) || ! ca_has_mask(ca) ) ?
|
1307
|
-
ca->elements - 1 :
|
1307
|
+
ca->elements - 1 : NUM2SIZE(rmin_count);
|
1308
1308
|
|
1309
1309
|
if ( min_count < 0 ) {
|
1310
1310
|
min_count += ca->elements;
|
@@ -1345,7 +1345,7 @@ rb_ca_count_close (int argc, VALUE *argv, VALUE self)
|
|
1345
1345
|
type *ptr = (type *) ca->ptr; \
|
1346
1346
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1347
1347
|
type val = (type) from(value); \
|
1348
|
-
|
1348
|
+
ca_size_t i; \
|
1349
1349
|
if ( m ) { \
|
1350
1350
|
for (i=ca->elements; i; i--, ptr++) { \
|
1351
1351
|
if ( ( ! *m++ ) && *ptr != val ) { \
|
@@ -1369,7 +1369,7 @@ rb_ca_count_close (int argc, VALUE *argv, VALUE self)
|
|
1369
1369
|
VALUE *ptr = (VALUE *) ca->ptr; \
|
1370
1370
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1371
1371
|
VALUE val = value; \
|
1372
|
-
|
1372
|
+
ca_size_t i; \
|
1373
1373
|
if ( m ) { \
|
1374
1374
|
for (i=ca->elements; i; i--, ptr++) { \
|
1375
1375
|
if ( ( ! *m++ ) && ! rb_equal(*ptr,val) ) { \
|
@@ -1393,7 +1393,7 @@ rb_ca_count_close (int argc, VALUE *argv, VALUE self)
|
|
1393
1393
|
char *ptr = ca->ptr; \
|
1394
1394
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1395
1395
|
char *val = ALLOCA_N(char, ca->bytes); \
|
1396
|
-
|
1396
|
+
ca_size_t i; \
|
1397
1397
|
rb_ca_obj2ptr(self, value, val); \
|
1398
1398
|
if ( m ) { \
|
1399
1399
|
for (i=ca->elements; i; i--, ptr+=ca->bytes) { \
|
@@ -1420,7 +1420,7 @@ rb_ca_all_equal_p (int argc, VALUE *argv, VALUE self)
|
|
1420
1420
|
volatile VALUE flag = Qtrue;
|
1421
1421
|
CArray *ca;
|
1422
1422
|
|
1423
|
-
rb_scan_args(argc, argv, "1", &value);
|
1423
|
+
rb_scan_args(argc, argv, "1", (VALUE *) &value);
|
1424
1424
|
|
1425
1425
|
Data_Get_Struct(self, CArray, ca);
|
1426
1426
|
|
@@ -1463,7 +1463,7 @@ rb_ca_all_equal_p (int argc, VALUE *argv, VALUE self)
|
|
1463
1463
|
type val = (type) from(value); \
|
1464
1464
|
double rtol = fabs(NUM2DBL(reps)); \
|
1465
1465
|
double vabs = nabs(val); \
|
1466
|
-
|
1466
|
+
ca_size_t i; \
|
1467
1467
|
if ( m ) { \
|
1468
1468
|
for (i=ca->elements; i; i--, ptr++) { \
|
1469
1469
|
if ( ! *m++ ) { \
|
@@ -1493,7 +1493,7 @@ rb_ca_all_equiv_p (int argc, VALUE *argv, VALUE self)
|
|
1493
1493
|
volatile VALUE flag = Qtrue;
|
1494
1494
|
CArray *ca;
|
1495
1495
|
|
1496
|
-
rb_scan_args(argc, argv, "2", &value, &reps);
|
1496
|
+
rb_scan_args(argc, argv, "2", (VALUE *) &value, (VALUE *) &reps);
|
1497
1497
|
|
1498
1498
|
Data_Get_Struct(self, CArray, ca);
|
1499
1499
|
|
@@ -1533,7 +1533,7 @@ rb_ca_all_equiv_p (int argc, VALUE *argv, VALUE self)
|
|
1533
1533
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1534
1534
|
type val = (type) from(value); \
|
1535
1535
|
double atol = fabs(NUM2DBL(aeps)); \
|
1536
|
-
|
1536
|
+
ca_size_t i; \
|
1537
1537
|
if ( m ) { \
|
1538
1538
|
for (i=ca->elements; i; i--, ptr++) { \
|
1539
1539
|
if ( ! *m++ ) { \
|
@@ -1561,7 +1561,7 @@ rb_ca_all_close_p (int argc, VALUE *argv, VALUE self)
|
|
1561
1561
|
volatile VALUE flag = Qtrue;
|
1562
1562
|
CArray *ca;
|
1563
1563
|
|
1564
|
-
rb_scan_args(argc, argv, "2", &value, &aeps);
|
1564
|
+
rb_scan_args(argc, argv, "2", (VALUE *) &value, (VALUE *) &aeps);
|
1565
1565
|
|
1566
1566
|
Data_Get_Struct(self, CArray, ca);
|
1567
1567
|
|
@@ -1600,7 +1600,7 @@ rb_ca_all_close_p (int argc, VALUE *argv, VALUE self)
|
|
1600
1600
|
type *ptr = (type *) ca->ptr; \
|
1601
1601
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1602
1602
|
type val = (type) from(value); \
|
1603
|
-
|
1603
|
+
ca_size_t i; \
|
1604
1604
|
if ( m ) { \
|
1605
1605
|
for (i=ca->elements; i; i--, ptr++) { \
|
1606
1606
|
if ( ( ! *m++ ) && *ptr == val ) { \
|
@@ -1624,7 +1624,7 @@ rb_ca_all_close_p (int argc, VALUE *argv, VALUE self)
|
|
1624
1624
|
VALUE *ptr = (VALUE *) ca->ptr; \
|
1625
1625
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1626
1626
|
VALUE val = value; \
|
1627
|
-
|
1627
|
+
ca_size_t i; \
|
1628
1628
|
if ( m ) { \
|
1629
1629
|
for (i=ca->elements; i; i--, ptr++) { \
|
1630
1630
|
if ( ( ! *m++ ) && rb_equal(*ptr,val) ) { \
|
@@ -1648,7 +1648,7 @@ rb_ca_all_close_p (int argc, VALUE *argv, VALUE self)
|
|
1648
1648
|
char *ptr = ca->ptr; \
|
1649
1649
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1650
1650
|
char *val = ALLOCA_N(char, ca->bytes); \
|
1651
|
-
|
1651
|
+
ca_size_t i; \
|
1652
1652
|
rb_ca_obj2ptr(self, value, val); \
|
1653
1653
|
if ( m ) { \
|
1654
1654
|
for (i=ca->elements; i; i--, ptr+=ca->bytes) \
|
@@ -1673,7 +1673,7 @@ rb_ca_any_equal_p (int argc, VALUE *argv, VALUE self)
|
|
1673
1673
|
volatile VALUE flag = Qfalse;
|
1674
1674
|
CArray *ca;
|
1675
1675
|
|
1676
|
-
rb_scan_args(argc, argv, "1", &value);
|
1676
|
+
rb_scan_args(argc, argv, "1", (VALUE *) &value);
|
1677
1677
|
|
1678
1678
|
Data_Get_Struct(self, CArray, ca);
|
1679
1679
|
|
@@ -1716,7 +1716,7 @@ rb_ca_any_equal_p (int argc, VALUE *argv, VALUE self)
|
|
1716
1716
|
type val = (type) from(value); \
|
1717
1717
|
double rtol = fabs(NUM2DBL(reps)); \
|
1718
1718
|
double vabs = nabs(val); \
|
1719
|
-
|
1719
|
+
ca_size_t i; \
|
1720
1720
|
if ( m ) { \
|
1721
1721
|
for (i=ca->elements; i; i--, ptr++) { \
|
1722
1722
|
if ( ! *m++ ) { \
|
@@ -1746,7 +1746,7 @@ rb_ca_any_equiv_p (int argc, VALUE *argv, VALUE self)
|
|
1746
1746
|
volatile VALUE flag = Qfalse;
|
1747
1747
|
CArray *ca;
|
1748
1748
|
|
1749
|
-
rb_scan_args(argc, argv, "2", &value, &reps);
|
1749
|
+
rb_scan_args(argc, argv, "2", (VALUE *) &value, (VALUE *) &reps);
|
1750
1750
|
|
1751
1751
|
Data_Get_Struct(self, CArray, ca);
|
1752
1752
|
|
@@ -1786,9 +1786,9 @@ rb_ca_any_equiv_p (int argc, VALUE *argv, VALUE self)
|
|
1786
1786
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1787
1787
|
type val = (type) from(value); \
|
1788
1788
|
double atol = fabs(NUM2DBL(aeps)); \
|
1789
|
-
|
1789
|
+
ca_size_t i; \
|
1790
1790
|
if ( m ) { \
|
1791
|
-
|
1791
|
+
for (i=ca->elements; i; i--, ptr++) { \
|
1792
1792
|
if ( ! *m++ ) { \
|
1793
1793
|
if ( nabs(*ptr - val) <= atol ) {\
|
1794
1794
|
flag = Qtrue; \
|
@@ -1814,7 +1814,7 @@ rb_ca_any_close_p (int argc, VALUE *argv, VALUE self)
|
|
1814
1814
|
volatile VALUE flag = Qfalse;
|
1815
1815
|
CArray *ca;
|
1816
1816
|
|
1817
|
-
rb_scan_args(argc, argv, "2", &value, &aeps);
|
1817
|
+
rb_scan_args(argc, argv, "2", (VALUE *) &value, (VALUE *) &aeps);
|
1818
1818
|
|
1819
1819
|
Data_Get_Struct(self, CArray, ca);
|
1820
1820
|
|
@@ -1832,15 +1832,15 @@ rb_ca_any_close_p (int argc, VALUE *argv, VALUE self)
|
|
1832
1832
|
case CA_UINT64: proc_any_close(uint64_t,NUM2ULL,fabs); break;
|
1833
1833
|
case CA_FLOAT32: proc_any_close(float32_t,NUM2DBL,fabs); break;
|
1834
1834
|
case CA_FLOAT64: proc_any_close(float64_t,NUM2DBL,fabs); break;
|
1835
|
-
case CA_FLOAT128: proc_any_close(float128_t,NUM2DBL,
|
1835
|
+
case CA_FLOAT128: proc_any_close(float128_t,NUM2DBL,fabsl); break;
|
1836
1836
|
#ifdef HAVE_COMPLEX_H
|
1837
1837
|
case CA_CMPLX64: proc_any_close(cmplx64_t,NUM2CC,cabs); break;
|
1838
1838
|
case CA_CMPLX128: proc_any_close(cmplx128_t,NUM2CC,cabs); break;
|
1839
|
-
case CA_CMPLX256: proc_any_close(cmplx256_t,NUM2CC,
|
1839
|
+
case CA_CMPLX256: proc_any_close(cmplx256_t,NUM2CC,cabsl); break;
|
1840
1840
|
#endif
|
1841
1841
|
default: rb_raise(rb_eCADataTypeError, "invalid data type");
|
1842
1842
|
}
|
1843
|
-
|
1843
|
+
|
1844
1844
|
ca_detach(ca);
|
1845
1845
|
|
1846
1846
|
return flag;
|
@@ -1874,18 +1874,18 @@ rb_ca_none_close_p (int argc, VALUE *argv, VALUE self)
|
|
1874
1874
|
double max = NUM2DBL(vmax); \
|
1875
1875
|
double diff = (max - min)/icls; \
|
1876
1876
|
double trial; \
|
1877
|
-
|
1877
|
+
ca_size_t i; \
|
1878
1878
|
for (i=0; i<=icls+1; i++) \
|
1879
1879
|
cls[i] = diff*i + min; \
|
1880
1880
|
for (i=0; i<ca->elements; i++, ptr++) { \
|
1881
1881
|
if ( m && *m++ ) continue; \
|
1882
1882
|
trial = (double)from(*ptr); \
|
1883
1883
|
if ( diff > 0 && trial >= min && trial <= max ) { \
|
1884
|
-
idx = (
|
1884
|
+
idx = (ca_size_t) ( (trial - min)/diff ); \
|
1885
1885
|
hist[idx]++; \
|
1886
1886
|
} \
|
1887
1887
|
else if ( diff < 0 && trial >= max && trial <= min ) { \
|
1888
|
-
idx = (
|
1888
|
+
idx = (ca_size_t) ( (trial - min)/diff ); \
|
1889
1889
|
hist[idx]++; \
|
1890
1890
|
} \
|
1891
1891
|
} \
|
@@ -1897,25 +1897,25 @@ rb_ca_histogram (int argc, VALUE *argv, VALUE self)
|
|
1897
1897
|
{
|
1898
1898
|
volatile VALUE vnum, vmin, vmax;
|
1899
1899
|
CArray *ca, *co;
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1900
|
+
ca_size_t i, idx, icls;
|
1901
|
+
ca_size_t *hist;
|
1902
|
+
ca_size_t dim[2] = {0, 3};
|
1903
1903
|
double *cls, *p;
|
1904
1904
|
|
1905
1905
|
rb_scan_args(argc, argv, "3", &vnum, &vmin, &vmax);
|
1906
1906
|
|
1907
1907
|
Data_Get_Struct(self, CArray, ca);
|
1908
1908
|
|
1909
|
-
icls =
|
1909
|
+
icls = NUM2SIZE(vnum);
|
1910
1910
|
|
1911
1911
|
if ( icls < 1 ) {
|
1912
1912
|
rb_raise(rb_eArgError, "bin number must be larger than 1");
|
1913
1913
|
}
|
1914
1914
|
|
1915
|
-
hist = ALLOC_N(
|
1915
|
+
hist = ALLOC_N(ca_size_t, icls+1);
|
1916
1916
|
cls = ALLOC_N(double, icls+2);
|
1917
1917
|
|
1918
|
-
MEMZERO(hist,
|
1918
|
+
MEMZERO(hist, ca_size_t, icls+1);
|
1919
1919
|
MEMZERO(cls, double, icls+2);
|
1920
1920
|
|
1921
1921
|
ca_attach(ca);
|
@@ -1962,7 +1962,7 @@ rb_ca_histogram (int argc, VALUE *argv, VALUE self)
|
|
1962
1962
|
|
1963
1963
|
#define proc_grade(type, from) \
|
1964
1964
|
{ \
|
1965
|
-
|
1965
|
+
ca_size_t *dst = (ca_size_t *) sa->ptr; \
|
1966
1966
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
1967
1967
|
boolean8_t *dm = (sa->mask) ? (boolean8_t*) sa->mask->ptr : NULL; \
|
1968
1968
|
type *ptr = (type *) ca->ptr; \
|
@@ -1971,7 +1971,7 @@ rb_ca_histogram (int argc, VALUE *argv, VALUE self)
|
|
1971
1971
|
type miss = 0; \
|
1972
1972
|
double diff = max - min; \
|
1973
1973
|
double trial; \
|
1974
|
-
|
1974
|
+
ca_size_t i; \
|
1975
1975
|
if ( min > max ) { \
|
1976
1976
|
rb_raise(rb_eRuntimeError, "invalid (min, max) range"); \
|
1977
1977
|
} \
|
@@ -1994,7 +1994,7 @@ rb_ca_histogram (int argc, VALUE *argv, VALUE self)
|
|
1994
1994
|
*dm = 1; \
|
1995
1995
|
} \
|
1996
1996
|
else { \
|
1997
|
-
*dst = (
|
1997
|
+
*dst = (ca_size_t) floor( ((trial-min)/diff) * icls ); \
|
1998
1998
|
} \
|
1999
1999
|
dst++; \
|
2000
2000
|
if ( dm ) { \
|
@@ -2009,9 +2009,9 @@ rb_ca_grade (int argc, VALUE *argv, VALUE self)
|
|
2009
2009
|
{
|
2010
2010
|
volatile VALUE out, vnum, vmin, vmax;
|
2011
2011
|
CArray *ca, *sa;
|
2012
|
-
|
2012
|
+
ca_size_t icls;
|
2013
2013
|
|
2014
|
-
rb_scan_args(argc, argv, "12", &vnum, &vmin, &vmax);
|
2014
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &vnum, (VALUE *) &vmin, (VALUE *) &vmax);
|
2015
2015
|
|
2016
2016
|
if ( NIL_P(vmin) ) {
|
2017
2017
|
vmin = rb_funcall(self, rb_intern("min"), 0);
|
@@ -2029,7 +2029,7 @@ rb_ca_grade (int argc, VALUE *argv, VALUE self)
|
|
2029
2029
|
rb_raise(rb_eArgError, "bin number must be larger than 1");
|
2030
2030
|
}
|
2031
2031
|
|
2032
|
-
out = rb_carray_new_safe(
|
2032
|
+
out = rb_carray_new_safe(CA_SIZE, ca->rank, ca->dim, 0, NULL);
|
2033
2033
|
Data_Get_Struct(out, CArray, sa);
|
2034
2034
|
|
2035
2035
|
ca_attach(ca);
|