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_stat_proc.rb
CHANGED
@@ -11,6 +11,17 @@
|
|
11
11
|
#
|
12
12
|
# ----------------------------------------------------------------------------
|
13
13
|
|
14
|
+
have_type_long_double = false
|
15
|
+
|
16
|
+
open("carray_config.h") { |io|
|
17
|
+
while line = io.gets
|
18
|
+
case line
|
19
|
+
when /HAVE_TYPE_LONG_DOUBLE *1/
|
20
|
+
have_type_long_double = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
14
25
|
def macro_expand (text, values)
|
15
26
|
text = text.clone
|
16
27
|
values.each do |key, val|
|
@@ -28,7 +39,7 @@ TYPEINFO = {
|
|
28
39
|
'type2obj' => 'LONG2NUM',
|
29
40
|
'type2dbl' => '(float64_t)',
|
30
41
|
'int2type' => '',
|
31
|
-
'atype' => 'double',
|
42
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
32
43
|
'azero' => '0.0',
|
33
44
|
'aone' => '1.0',
|
34
45
|
'atype2obj' => 'rb_float_new',
|
@@ -43,7 +54,7 @@ TYPEINFO = {
|
|
43
54
|
'type2obj' => 'LONG2NUM',
|
44
55
|
'type2dbl' => '(float64_t)',
|
45
56
|
'int2type' => '',
|
46
|
-
'atype' => 'double',
|
57
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
47
58
|
'azero' => '0.0',
|
48
59
|
'aone' => '1.0',
|
49
60
|
'atype2obj' => 'rb_float_new',
|
@@ -58,7 +69,7 @@ TYPEINFO = {
|
|
58
69
|
'type2obj' => 'ULONG2NUM',
|
59
70
|
'type2dbl' => '(float64_t)',
|
60
71
|
'int2type' => '',
|
61
|
-
'atype' => 'double',
|
72
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
62
73
|
'azero' => '0.0',
|
63
74
|
'aone' => '1.0',
|
64
75
|
'atype2obj' => 'rb_float_new',
|
@@ -73,7 +84,7 @@ TYPEINFO = {
|
|
73
84
|
'type2obj' => 'LONG2NUM',
|
74
85
|
'type2dbl' => '(float64_t)',
|
75
86
|
'int2type' => '',
|
76
|
-
'atype' => 'double',
|
87
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
77
88
|
'azero' => '0.0',
|
78
89
|
'aone' => '1.0',
|
79
90
|
'atype2obj' => 'rb_float_new',
|
@@ -88,7 +99,7 @@ TYPEINFO = {
|
|
88
99
|
'type2obj' => 'ULONG2NUM',
|
89
100
|
'type2dbl' => '(float64_t)',
|
90
101
|
'int2type' => '',
|
91
|
-
'atype' => 'double',
|
102
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
92
103
|
'azero' => '0.0',
|
93
104
|
'aone' => '1.0',
|
94
105
|
'atype2obj' => 'rb_float_new',
|
@@ -103,7 +114,7 @@ TYPEINFO = {
|
|
103
114
|
'type2obj' => 'LONG2NUM',
|
104
115
|
'type2dbl' => '(float64_t)',
|
105
116
|
'int2type' => '',
|
106
|
-
'atype' => 'double',
|
117
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
107
118
|
'azero' => '0.0',
|
108
119
|
'aone' => '1.0',
|
109
120
|
'atype2obj' => 'rb_float_new',
|
@@ -118,7 +129,7 @@ TYPEINFO = {
|
|
118
129
|
'type2obj' => 'ULONG2NUM',
|
119
130
|
'type2dbl' => '(float64_t)',
|
120
131
|
'int2type' => '',
|
121
|
-
'atype' => 'double',
|
132
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
122
133
|
'azero' => '0.0',
|
123
134
|
'aone' => '1.0',
|
124
135
|
'atype2obj' => 'rb_float_new',
|
@@ -133,7 +144,7 @@ TYPEINFO = {
|
|
133
144
|
'type2obj' => 'LL2NUM',
|
134
145
|
'type2dbl' => '(float64_t)',
|
135
146
|
'int2type' => '',
|
136
|
-
'atype' => 'double',
|
147
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
137
148
|
'azero' => '0.0',
|
138
149
|
'aone' => '1.0',
|
139
150
|
'atype2obj' => 'rb_float_new',
|
@@ -148,7 +159,7 @@ TYPEINFO = {
|
|
148
159
|
'type2obj' => 'ULL2NUM',
|
149
160
|
'type2dbl' => '(float64_t)',
|
150
161
|
'int2type' => '',
|
151
|
-
'atype' => 'double',
|
162
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
152
163
|
'azero' => '0.0',
|
153
164
|
'aone' => '1.0',
|
154
165
|
'atype2obj' => 'rb_float_new',
|
@@ -163,7 +174,7 @@ TYPEINFO = {
|
|
163
174
|
'type2obj' => 'rb_float_new',
|
164
175
|
'type2dbl' => '(float64_t)',
|
165
176
|
'int2type' => '',
|
166
|
-
'atype' => 'double',
|
177
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
167
178
|
'azero' => '0.0',
|
168
179
|
'aone' => '1.0',
|
169
180
|
'atype2obj' => 'rb_float_new',
|
@@ -178,7 +189,7 @@ TYPEINFO = {
|
|
178
189
|
'type2obj' => 'rb_float_new',
|
179
190
|
'type2dbl' => '',
|
180
191
|
'int2type' => '',
|
181
|
-
'atype' => 'double',
|
192
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
182
193
|
'azero' => '0.0',
|
183
194
|
'aone' => '1.0',
|
184
195
|
'atype2obj' => 'rb_float_new',
|
@@ -193,7 +204,7 @@ TYPEINFO = {
|
|
193
204
|
'type2obj' => 'rb_float_new',
|
194
205
|
'type2dbl' => '',
|
195
206
|
'int2type' => '',
|
196
|
-
'atype' => 'double',
|
207
|
+
'atype' => have_type_long_double ? 'long double' : 'double',
|
197
208
|
'azero' => '0.0',
|
198
209
|
'aone' => '1.0',
|
199
210
|
'atype2obj' => 'rb_float_new',
|
@@ -247,7 +258,7 @@ TYPEINFO = {
|
|
247
258
|
},
|
248
259
|
'VALUE' => {
|
249
260
|
'type' => "VALUE",
|
250
|
-
'zero' => '
|
261
|
+
'zero' => 'INT2NUM(0)',
|
251
262
|
'dat2type' => '',
|
252
263
|
'obj2type' => '',
|
253
264
|
'type2obj' => '',
|
@@ -289,10 +300,10 @@ header = <<HERE_END
|
|
289
300
|
#include "carray.h"
|
290
301
|
|
291
302
|
typedef struct {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
303
|
+
ca_size_t offset;
|
304
|
+
ca_size_t count;
|
305
|
+
ca_size_t step;
|
306
|
+
ca_size_t *addr;
|
296
307
|
} CAStatIterator;
|
297
308
|
|
298
309
|
typedef void (*ca_stat_proc_t)();
|
@@ -363,16 +374,16 @@ text = <<'HERE_END'
|
|
363
374
|
/* ============================= */
|
364
375
|
|
365
376
|
static void
|
366
|
-
ca_proc_prod_<type> (
|
377
|
+
ca_proc_prod_<type> (ca_size_t elements, ca_size_t min_count,
|
367
378
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
368
379
|
int return_object, VALUE *retobj,
|
369
|
-
boolean8_t *retmask,
|
380
|
+
boolean8_t *retmask, float64_t *retval)
|
370
381
|
{
|
371
382
|
volatile <atype> prod = <aone>;
|
372
383
|
<type> *p = (<type> *) ptr;
|
373
|
-
|
374
|
-
|
375
|
-
|
384
|
+
ca_size_t *a = (ca_size_t *) it;
|
385
|
+
ca_size_t count = 0;
|
386
|
+
ca_size_t i;
|
376
387
|
iterator_rewind(it);
|
377
388
|
if ( m ) {
|
378
389
|
for (i=0; i<elements; i++) {
|
@@ -398,7 +409,7 @@ ca_proc_prod_<type> (int32_t elements, int32_t min_count,
|
|
398
409
|
if ( retmask ) {
|
399
410
|
*retmask = ( count > min_count ) ? 1 : 0;
|
400
411
|
}
|
401
|
-
*retval = prod;
|
412
|
+
*retval = <type2dbl>(prod);
|
402
413
|
}
|
403
414
|
}
|
404
415
|
|
@@ -407,14 +418,14 @@ ca_proc_prod_<type> (int32_t elements, int32_t min_count,
|
|
407
418
|
/* ============================= */
|
408
419
|
|
409
420
|
static void
|
410
|
-
ca_proc_count_<type> (
|
421
|
+
ca_proc_count_<type> (ca_size_t elements, ca_size_t min_count,
|
411
422
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
412
423
|
int return_object, VALUE *retobj,
|
413
|
-
boolean8_t *retmask,
|
424
|
+
boolean8_t *retmask, ca_size_t *retval)
|
414
425
|
{
|
415
|
-
|
416
|
-
|
417
|
-
|
426
|
+
ca_size_t *a = (ca_size_t *) it;
|
427
|
+
ca_size_t count = 0;
|
428
|
+
ca_size_t i;
|
418
429
|
iterator_rewind(it);
|
419
430
|
if ( m ) {
|
420
431
|
for (i=0; i<elements; i++) {
|
@@ -425,7 +436,7 @@ ca_proc_count_<type> (int32_t elements, int32_t min_count,
|
|
425
436
|
}
|
426
437
|
}
|
427
438
|
if ( return_object ) {
|
428
|
-
*retobj = ( count > min_count ) ? CA_UNDEF :
|
439
|
+
*retobj = ( count > min_count ) ? CA_UNDEF : SIZE2NUM(elements - count);
|
429
440
|
}
|
430
441
|
else {
|
431
442
|
if ( retmask ) {
|
@@ -436,16 +447,16 @@ ca_proc_count_<type> (int32_t elements, int32_t min_count,
|
|
436
447
|
}
|
437
448
|
|
438
449
|
static void
|
439
|
-
ca_proc_sum_<type> (
|
450
|
+
ca_proc_sum_<type> (ca_size_t elements, ca_size_t min_count,
|
440
451
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
441
452
|
int return_object, VALUE *retobj,
|
442
453
|
boolean8_t *retmask, float64_t *retval)
|
443
454
|
{
|
444
455
|
volatile <atype> sum = <azero>;
|
445
456
|
<type> *p = (<type> *) ptr;
|
446
|
-
|
447
|
-
|
448
|
-
|
457
|
+
ca_size_t *a = (ca_size_t *)it;
|
458
|
+
ca_size_t count = 0;
|
459
|
+
ca_size_t i;
|
449
460
|
iterator_rewind(it);
|
450
461
|
if ( m ) {
|
451
462
|
for (i=0; i<elements; i++) {
|
@@ -481,16 +492,16 @@ ca_proc_sum_<type> (int32_t elements, int32_t min_count,
|
|
481
492
|
/* ============================= */
|
482
493
|
|
483
494
|
static void
|
484
|
-
ca_proc_mean_<type> (
|
495
|
+
ca_proc_mean_<type> (ca_size_t elements, ca_size_t min_count,
|
485
496
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
486
497
|
int return_object, VALUE *retobj,
|
487
498
|
boolean8_t *retmask, float64_t *retval)
|
488
499
|
{
|
489
500
|
volatile <atype> sum = <azero>, ave;
|
490
501
|
<type> *p = (<type> *) ptr;
|
491
|
-
|
492
|
-
|
493
|
-
|
502
|
+
ca_size_t *a = (ca_size_t *) it;
|
503
|
+
ca_size_t count = 0;
|
504
|
+
ca_size_t i;
|
494
505
|
iterator_rewind(it);
|
495
506
|
if ( m ) {
|
496
507
|
for (i=0; i<elements; i++) {
|
@@ -526,16 +537,16 @@ ca_proc_mean_<type> (int32_t elements, int32_t min_count,
|
|
526
537
|
/* ============================= */
|
527
538
|
|
528
539
|
static void
|
529
|
-
ca_proc_variancep_<type> (
|
540
|
+
ca_proc_variancep_<type> (ca_size_t elements, ca_size_t min_count,
|
530
541
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
531
542
|
int return_object, VALUE *retobj,
|
532
543
|
boolean8_t *retmask, float64_t *retval)
|
533
544
|
{
|
534
545
|
volatile <atype> sum = <azero>, sum2 = <azero>, ave, var, diff;
|
535
546
|
<type> *p = (<type> *) ptr;
|
536
|
-
|
537
|
-
|
538
|
-
|
547
|
+
ca_size_t *a = (ca_size_t *) it;
|
548
|
+
ca_size_t count = 0;
|
549
|
+
ca_size_t i;
|
539
550
|
iterator_rewind(it);
|
540
551
|
if ( m ) {
|
541
552
|
for (i=0; i<elements; i++) {
|
@@ -595,16 +606,16 @@ ca_proc_variancep_<type> (int32_t elements, int32_t min_count,
|
|
595
606
|
/* ============================= */
|
596
607
|
|
597
608
|
static void
|
598
|
-
ca_proc_stddevp_<type> (
|
609
|
+
ca_proc_stddevp_<type> (ca_size_t elements, ca_size_t min_count,
|
599
610
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
600
611
|
int return_object, VALUE *retobj,
|
601
612
|
boolean8_t *retmask, float64_t *retval)
|
602
613
|
{
|
603
614
|
volatile <atype> sum = <azero>, sum2 = <azero>, ave, var, diff;
|
604
615
|
<type> *p = (<type> *) ptr;
|
605
|
-
|
606
|
-
|
607
|
-
|
616
|
+
ca_size_t *a = (ca_size_t *) it;
|
617
|
+
ca_size_t count = 0;
|
618
|
+
ca_size_t i;
|
608
619
|
iterator_rewind(it);
|
609
620
|
if ( m ) {
|
610
621
|
for (i=0; i<elements; i++) {
|
@@ -664,16 +675,16 @@ ca_proc_stddevp_<type> (int32_t elements, int32_t min_count,
|
|
664
675
|
/* ============================= */
|
665
676
|
|
666
677
|
static void
|
667
|
-
ca_proc_variance_<type> (
|
678
|
+
ca_proc_variance_<type> (ca_size_t elements, ca_size_t min_count,
|
668
679
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
669
680
|
int return_object, VALUE *retobj,
|
670
681
|
boolean8_t *retmask, float64_t *retval)
|
671
682
|
{
|
672
683
|
volatile <atype> sum = <azero>, sum2 = <azero>, ave, var, diff;
|
673
684
|
<type> *p = (<type> *) ptr;
|
674
|
-
|
675
|
-
|
676
|
-
|
685
|
+
ca_size_t *a = (ca_size_t *) it;
|
686
|
+
ca_size_t count = 0;
|
687
|
+
ca_size_t i;
|
677
688
|
iterator_rewind(it);
|
678
689
|
if ( m ) {
|
679
690
|
for (i=0; i<elements; i++) {
|
@@ -733,16 +744,16 @@ ca_proc_variance_<type> (int32_t elements, int32_t min_count,
|
|
733
744
|
/* ============================= */
|
734
745
|
|
735
746
|
static void
|
736
|
-
ca_proc_stddev_<type> (
|
747
|
+
ca_proc_stddev_<type> (ca_size_t elements, ca_size_t min_count,
|
737
748
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
738
749
|
int return_object, VALUE *retobj,
|
739
750
|
boolean8_t *retmask, <atype> *retval)
|
740
751
|
{
|
741
752
|
volatile <atype> sum = <azero>, sum2 = <azero>, ave, var, diff;
|
742
753
|
<type> *p = (<type> *) ptr;
|
743
|
-
|
744
|
-
|
745
|
-
|
754
|
+
ca_size_t *a = (ca_size_t *) it;
|
755
|
+
ca_size_t count = 0;
|
756
|
+
ca_size_t i;
|
746
757
|
iterator_rewind(it);
|
747
758
|
if ( m ) {
|
748
759
|
for (i=0; i<elements; i++) {
|
@@ -802,17 +813,17 @@ ca_proc_stddev_<type> (int32_t elements, int32_t min_count,
|
|
802
813
|
/* ============================= */
|
803
814
|
|
804
815
|
static void
|
805
|
-
ca_proc_min_<type> (
|
816
|
+
ca_proc_min_<type> (ca_size_t elements, ca_size_t min_count,
|
806
817
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
807
818
|
int return_object, VALUE *retobj,
|
808
819
|
boolean8_t *retmask, <type> *retval)
|
809
820
|
{
|
810
821
|
<type> min = <zero>;
|
811
822
|
<type> *p = (<type> *) ptr;
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
823
|
+
ca_size_t *a = (ca_size_t *) it;
|
824
|
+
ca_size_t count = 0;
|
825
|
+
ca_size_t addr;
|
826
|
+
ca_size_t i;
|
816
827
|
iterator_rewind(it);
|
817
828
|
if ( m ) {
|
818
829
|
addr = -1;
|
@@ -870,17 +881,17 @@ ca_proc_min_<type> (int32_t elements, int32_t min_count,
|
|
870
881
|
/* ============================= */
|
871
882
|
|
872
883
|
static void
|
873
|
-
ca_proc_min_addr_<type> (
|
884
|
+
ca_proc_min_addr_<type> (ca_size_t elements, ca_size_t min_count,
|
874
885
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
875
886
|
int return_object, VALUE *retobj,
|
876
|
-
boolean8_t *retmask,
|
887
|
+
boolean8_t *retmask, ca_size_t *retval)
|
877
888
|
{
|
878
889
|
<type> min = <zero>;
|
879
890
|
<type> *p = (<type> *) ptr;
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
891
|
+
ca_size_t *a = (ca_size_t *) it;
|
892
|
+
ca_size_t count = 0;
|
893
|
+
ca_size_t addr;
|
894
|
+
ca_size_t i;
|
884
895
|
iterator_rewind(it);
|
885
896
|
if ( m ) {
|
886
897
|
addr = -1;
|
@@ -924,7 +935,7 @@ ca_proc_min_addr_<type> (int32_t elements, int32_t min_count,
|
|
924
935
|
}
|
925
936
|
if ( return_object ) {
|
926
937
|
*retobj = ( count > min_count ) ? CA_UNDEF
|
927
|
-
: ( addr < 0 ) ? Qnil :
|
938
|
+
: ( addr < 0 ) ? Qnil : SIZE2NUM(addr);
|
928
939
|
}
|
929
940
|
else {
|
930
941
|
if ( retmask ) {
|
@@ -939,17 +950,17 @@ ca_proc_min_addr_<type> (int32_t elements, int32_t min_count,
|
|
939
950
|
/* ============================= */
|
940
951
|
|
941
952
|
static void
|
942
|
-
ca_proc_max_<type> (
|
953
|
+
ca_proc_max_<type> (ca_size_t elements, ca_size_t min_count,
|
943
954
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
944
955
|
int return_object, VALUE *retobj,
|
945
956
|
boolean8_t *retmask, <type> *retval)
|
946
957
|
{
|
947
958
|
<type> max = 0;
|
948
959
|
<type> *p = (<type> *) ptr;
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
960
|
+
ca_size_t *a = (ca_size_t *) it;
|
961
|
+
ca_size_t count = 0;
|
962
|
+
ca_size_t addr;
|
963
|
+
ca_size_t i;
|
953
964
|
iterator_rewind(it);
|
954
965
|
if ( m ) {
|
955
966
|
addr = -1;
|
@@ -1007,17 +1018,17 @@ ca_proc_max_<type> (int32_t elements, int32_t min_count,
|
|
1007
1018
|
/* ============================= */
|
1008
1019
|
|
1009
1020
|
static void
|
1010
|
-
ca_proc_max_addr_<type> (
|
1021
|
+
ca_proc_max_addr_<type> (ca_size_t elements, ca_size_t min_count,
|
1011
1022
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
1012
1023
|
int return_object, VALUE *retobj,
|
1013
|
-
boolean8_t *retmask,
|
1024
|
+
boolean8_t *retmask, ca_size_t *retval)
|
1014
1025
|
{
|
1015
1026
|
<type> max = 0;
|
1016
1027
|
<type> *p = (<type> *) ptr;
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1028
|
+
ca_size_t *a = (ca_size_t *) it;
|
1029
|
+
ca_size_t count = 0;
|
1030
|
+
ca_size_t addr;
|
1031
|
+
ca_size_t i;
|
1021
1032
|
iterator_rewind(it);
|
1022
1033
|
if ( m ) {
|
1023
1034
|
addr = -1;
|
@@ -1061,7 +1072,7 @@ ca_proc_max_addr_<type> (int32_t elements, int32_t min_count,
|
|
1061
1072
|
}
|
1062
1073
|
if ( return_object ) {
|
1063
1074
|
*retobj = ( count > min_count ) ? CA_UNDEF
|
1064
|
-
: ( addr < 0 ) ? Qnil :
|
1075
|
+
: ( addr < 0 ) ? Qnil : SIZE2NUM(addr);
|
1065
1076
|
}
|
1066
1077
|
else {
|
1067
1078
|
if ( retmask ) {
|
@@ -1077,13 +1088,13 @@ ca_proc_max_addr_<type> (int32_t elements, int32_t min_count,
|
|
1077
1088
|
/* ============================= */
|
1078
1089
|
|
1079
1090
|
static void
|
1080
|
-
ca_proc_cumcount_<type> (
|
1091
|
+
ca_proc_cumcount_<type> (ca_size_t elements, ca_size_t min_count,
|
1081
1092
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
1082
|
-
boolean8_t *retmask,
|
1093
|
+
boolean8_t *retmask, ca_size_t *retval)
|
1083
1094
|
{
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1095
|
+
ca_size_t *a = (ca_size_t *) it;
|
1096
|
+
ca_size_t count = 0;
|
1097
|
+
ca_size_t i;
|
1087
1098
|
iterator_rewind(it);
|
1088
1099
|
if ( m ) {
|
1089
1100
|
for (i=0; i<elements; i++) {
|
@@ -1117,15 +1128,15 @@ ca_proc_cumcount_<type> (int32_t elements, int32_t min_count,
|
|
1117
1128
|
/* ============================= */
|
1118
1129
|
|
1119
1130
|
static void
|
1120
|
-
ca_proc_cumsum_<type> (
|
1131
|
+
ca_proc_cumsum_<type> (ca_size_t elements, ca_size_t min_count,
|
1121
1132
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
1122
1133
|
boolean8_t *retmask, float64_t *retval)
|
1123
1134
|
{
|
1124
1135
|
volatile <atype> sum = <azero>;
|
1125
1136
|
<type> *p = (<type> *) ptr;
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1137
|
+
ca_size_t *a = (ca_size_t *) it;
|
1138
|
+
ca_size_t count = 0;
|
1139
|
+
ca_size_t i;
|
1129
1140
|
iterator_rewind(it);
|
1130
1141
|
if ( m ) {
|
1131
1142
|
for (i=0; i<elements; i++) {
|
@@ -1230,16 +1241,16 @@ text = <<'HERE_END'
|
|
1230
1241
|
/* ============================= */
|
1231
1242
|
|
1232
1243
|
static void
|
1233
|
-
ca_proc_accum_<type> (
|
1244
|
+
ca_proc_accum_<type> (ca_size_t elements, ca_size_t min_count,
|
1234
1245
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
1235
1246
|
int return_object, VALUE *retobj,
|
1236
1247
|
boolean8_t *retmask, <type> *retval)
|
1237
1248
|
{
|
1238
1249
|
<type> sum = <zero>;
|
1239
1250
|
<type> *p = (<type> *) ptr;
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1251
|
+
ca_size_t *a = (ca_size_t *) it;
|
1252
|
+
ca_size_t count = 0;
|
1253
|
+
ca_size_t i;
|
1243
1254
|
iterator_rewind(it);
|
1244
1255
|
if ( m ) {
|
1245
1256
|
for (i=0; i<elements; i++) {
|
@@ -1332,7 +1343,7 @@ rb_ca_stat_1d (VALUE self, VALUE rmc, VALUE vfval,
|
|
1332
1343
|
CArray *ca;
|
1333
1344
|
CAStatIterator it;
|
1334
1345
|
boolean8_t *m;
|
1335
|
-
|
1346
|
+
ca_size_t mc;
|
1336
1347
|
|
1337
1348
|
Data_Get_Struct(self, CArray, ca);
|
1338
1349
|
|
@@ -1348,7 +1359,7 @@ rb_ca_stat_1d (VALUE self, VALUE rmc, VALUE vfval,
|
|
1348
1359
|
else {
|
1349
1360
|
ca_attach(ca);
|
1350
1361
|
m = ( ca->mask ) ? (boolean8_t *)ca->mask->ptr : NULL;
|
1351
|
-
mc = ( ( ! ca_has_mask(ca) ) || NIL_P(rmc)) ? ca->elements - 1 :
|
1362
|
+
mc = ( ( ! ca_has_mask(ca) ) || NIL_P(rmc)) ? ca->elements - 1 : NUM2SIZE(rmc);
|
1352
1363
|
if ( mc < 0 ) {
|
1353
1364
|
mc += ca->elements;
|
1354
1365
|
}
|
@@ -1365,13 +1376,13 @@ rb_ca_stat_1d (VALUE self, VALUE rmc, VALUE vfval,
|
|
1365
1376
|
}
|
1366
1377
|
|
1367
1378
|
static void
|
1368
|
-
ca_stat_nd_contig_loop (CArray *ca, CArray *co,
|
1379
|
+
ca_stat_nd_contig_loop (CArray *ca, CArray *co, ca_size_t mc,
|
1369
1380
|
ca_stat_proc_t *ca_proc,
|
1370
|
-
int level,
|
1381
|
+
int level, ca_size_t *idx, char **op, boolean8_t **om)
|
1371
1382
|
{
|
1372
1383
|
void *p;
|
1373
1384
|
boolean8_t *m;
|
1374
|
-
|
1385
|
+
ca_size_t i, n;
|
1375
1386
|
if ( level == co->rank ) {
|
1376
1387
|
CAStatIterator it;
|
1377
1388
|
n = ca->elements/co->elements;
|
@@ -1400,7 +1411,7 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1400
1411
|
{
|
1401
1412
|
volatile VALUE out;
|
1402
1413
|
CArray *ca, *co;
|
1403
|
-
|
1414
|
+
ca_size_t mc, ndim;
|
1404
1415
|
|
1405
1416
|
Data_Get_Struct(self, CArray, ca);
|
1406
1417
|
|
@@ -1426,7 +1437,7 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1426
1437
|
mc = ca->elements/co->elements - 1;
|
1427
1438
|
}
|
1428
1439
|
else {
|
1429
|
-
mc =
|
1440
|
+
mc = NUM2SIZE(rmc);
|
1430
1441
|
}
|
1431
1442
|
|
1432
1443
|
if ( mc < 0 ) {
|
@@ -1434,10 +1445,10 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1434
1445
|
}
|
1435
1446
|
|
1436
1447
|
{
|
1437
|
-
|
1448
|
+
ca_size_t idx[CA_RANK_MAX];
|
1438
1449
|
char *op;
|
1439
1450
|
boolean8_t *om;
|
1440
|
-
|
1451
|
+
int8_t i;
|
1441
1452
|
for (i=0; i<ca->rank; i++) {
|
1442
1453
|
idx[i] = 0;
|
1443
1454
|
}
|
@@ -1457,22 +1468,22 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1457
1468
|
}
|
1458
1469
|
|
1459
1470
|
static void
|
1460
|
-
ca_stat_get_offset_loop (CArray *ca,
|
1461
|
-
int level,
|
1462
|
-
int level1,
|
1471
|
+
ca_stat_get_offset_loop (CArray *ca, ca_size_t *dm,
|
1472
|
+
int level, ca_size_t *idx,
|
1473
|
+
int level1, ca_size_t *idx1,
|
1463
1474
|
CArray *offset)
|
1464
1475
|
{
|
1465
|
-
|
1476
|
+
ca_size_t i;
|
1466
1477
|
if ( level == ca->rank - 1 ) {
|
1467
1478
|
if ( dm[level] == 0 ) {
|
1468
1479
|
idx[level] = 0;
|
1469
|
-
*(
|
1480
|
+
*(ca_size_t *)ca_ptr_at_index(offset, idx1) = ca_index2addr(ca, idx);
|
1470
1481
|
}
|
1471
1482
|
else {
|
1472
1483
|
for (i=0; i<ca->dim[level]; i++) {
|
1473
1484
|
idx[level] = i;
|
1474
1485
|
idx1[level1] = i;
|
1475
|
-
*(
|
1486
|
+
*(ca_size_t *)ca_ptr_at_index(offset, idx1) = ca_index2addr(ca, idx);
|
1476
1487
|
}
|
1477
1488
|
}
|
1478
1489
|
}
|
@@ -1496,15 +1507,15 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1496
1507
|
int8_t data_type, ca_stat_proc_t *ca_proc)
|
1497
1508
|
{
|
1498
1509
|
volatile VALUE out;
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1510
|
+
ca_size_t idx[CA_RANK_MAX];
|
1511
|
+
ca_size_t idx1[CA_RANK_MAX];
|
1512
|
+
ca_size_t out_dim[CA_RANK_MAX];
|
1513
|
+
ca_size_t loop_dim[CA_RANK_MAX];
|
1514
|
+
ca_size_t dm[CA_RANK_MAX], dn[CA_RANK_MAX];
|
1504
1515
|
CArray *ca, *co, *first, *offset;
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1516
|
+
ca_size_t out_rank, loop_rank;
|
1517
|
+
ca_size_t mc;
|
1518
|
+
ca_size_t i, k;
|
1508
1519
|
|
1509
1520
|
Data_Get_Struct(self, CArray, ca);
|
1510
1521
|
|
@@ -1514,7 +1525,7 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1514
1525
|
}
|
1515
1526
|
|
1516
1527
|
for (i=0; i<RARRAY_LEN(vaxis); i++) {
|
1517
|
-
k =
|
1528
|
+
k = NUM2SIZE(rb_ary_entry(vaxis, i));
|
1518
1529
|
dm[k] = 1;
|
1519
1530
|
dn[k] = 0;
|
1520
1531
|
}
|
@@ -1535,10 +1546,10 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1535
1546
|
out = rb_carray_new(data_type, out_rank, out_dim, 0, NULL);
|
1536
1547
|
Data_Get_Struct(out, CArray, co);
|
1537
1548
|
|
1538
|
-
first = carray_new(
|
1549
|
+
first = carray_new(CA_SIZE, out_rank, out_dim, 0, NULL);
|
1539
1550
|
first->ptr = realloc(first->ptr, first->bytes*(first->elements+1));
|
1540
1551
|
|
1541
|
-
offset = carray_new(
|
1552
|
+
offset = carray_new(CA_SIZE, loop_rank, loop_dim, 0, NULL);
|
1542
1553
|
offset->ptr = realloc(offset->ptr, offset->bytes*(offset->elements+1));
|
1543
1554
|
|
1544
1555
|
ca_stat_get_offset_loop(ca, dn, 0, idx, 0, idx1, first);
|
@@ -1552,7 +1563,7 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1552
1563
|
mc = offset->elements - 1;
|
1553
1564
|
}
|
1554
1565
|
else {
|
1555
|
-
mc =
|
1566
|
+
mc = NUM2SIZE(rmc);
|
1556
1567
|
}
|
1557
1568
|
|
1558
1569
|
if ( mc < 0 ) {
|
@@ -1563,14 +1574,14 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1563
1574
|
|
1564
1575
|
{
|
1565
1576
|
CAStatIterator it, jt;
|
1566
|
-
|
1577
|
+
ca_size_t *a = (ca_size_t *) (&it);
|
1567
1578
|
boolean8_t *m0, *m, *om;
|
1568
1579
|
char *p, *op;
|
1569
1580
|
|
1570
1581
|
it.step = 1;
|
1571
|
-
it.addr = (
|
1582
|
+
it.addr = (ca_size_t *)first->ptr;
|
1572
1583
|
jt.step = 1;
|
1573
|
-
jt.addr = (
|
1584
|
+
jt.addr = (ca_size_t *)offset->ptr;
|
1574
1585
|
|
1575
1586
|
m0 = ( ca->mask && ca->mask->ptr ) ? (boolean8_t *)ca->mask->ptr : NULL;
|
1576
1587
|
om = ( co->mask && co->mask->ptr ) ? (boolean8_t *)co->mask->ptr : NULL;
|
@@ -1622,21 +1633,21 @@ rb_ca_stat_general (int argc, VALUE *argv, VALUE self,
|
|
1622
1633
|
"don't specify mask_limit and min_count simaltaniously");
|
1623
1634
|
}
|
1624
1635
|
else if ( ! NIL_P(rmin_count) ) {
|
1625
|
-
|
1636
|
+
ca_size_t min_count = NUM2SIZE(rmin_count);
|
1626
1637
|
if ( min_count == 0 ) {
|
1627
1638
|
rmc = Qnil;
|
1628
1639
|
}
|
1629
1640
|
else {
|
1630
|
-
rmc =
|
1641
|
+
rmc = SIZE2NUM(-min_count);
|
1631
1642
|
}
|
1632
1643
|
}
|
1633
1644
|
else if ( ! NIL_P(rmask_limit) ) {
|
1634
|
-
|
1645
|
+
ca_size_t mask_limit = NUM2SIZE(rmask_limit);
|
1635
1646
|
if ( mask_limit == 0 ) {
|
1636
1647
|
rmc = Qnil;
|
1637
1648
|
}
|
1638
1649
|
else {
|
1639
|
-
rmc =
|
1650
|
+
rmc = SIZE2NUM(mask_limit-1);
|
1640
1651
|
}
|
1641
1652
|
}
|
1642
1653
|
else {
|
@@ -1655,13 +1666,13 @@ rb_ca_stat_general (int argc, VALUE *argv, VALUE self,
|
|
1655
1666
|
}
|
1656
1667
|
else {
|
1657
1668
|
int is_contig = 1;
|
1658
|
-
|
1669
|
+
ca_size_t i, k;
|
1659
1670
|
|
1660
1671
|
vaxis = rb_funcall(vaxis, rb_intern("sort"), 0);
|
1661
1672
|
vaxis = rb_funcall(vaxis, rb_intern("uniq"), 0);
|
1662
1673
|
|
1663
1674
|
for (i=0; i<RARRAY_LEN(vaxis); i++) {
|
1664
|
-
k =
|
1675
|
+
k = NUM2SIZE(rb_ary_entry(vaxis, RARRAY_LEN(vaxis)-1-i));
|
1665
1676
|
CA_CHECK_INDEX(k, ca->rank);
|
1666
1677
|
if ( k != ca->rank-1-i ) {
|
1667
1678
|
is_contig = 0;
|
@@ -1773,11 +1784,11 @@ static VALUE
|
|
1773
1784
|
rb_ca_stat_type2 (int argc, VALUE *argv, VALUE self,
|
1774
1785
|
int8_t data_type, ca_stat_proc_t *ca_proc)
|
1775
1786
|
{
|
1776
|
-
VALUE out, rmc, rfval;
|
1787
|
+
volatile VALUE out, rmc, rfval;
|
1777
1788
|
CArray *ca, *co;
|
1778
|
-
|
1789
|
+
ca_size_t mc;
|
1779
1790
|
|
1780
|
-
rb_scan_args(argc, argv, "02", &rmc, &rfval);
|
1791
|
+
rb_scan_args(argc, argv, "02", (VALUE *) &rmc, (VALUE *) &rfval);
|
1781
1792
|
|
1782
1793
|
Data_Get_Struct(self, CArray, ca);
|
1783
1794
|
|
@@ -1801,7 +1812,7 @@ rb_ca_stat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1801
1812
|
if ( ca->mask ) {
|
1802
1813
|
m = (boolean8_t *)ca->mask->ptr;
|
1803
1814
|
}
|
1804
|
-
mc = ( (! ca->mask) || NIL_P(rmc) ) ? ca->elements - 1 :
|
1815
|
+
mc = ( (! ca->mask) || NIL_P(rmc) ) ? ca->elements - 1 : NUM2SIZE(rmc);
|
1805
1816
|
if ( mc < 0 ) {
|
1806
1817
|
mc += ca->elements;
|
1807
1818
|
}
|
@@ -1823,13 +1834,13 @@ rb_ca_stat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1823
1834
|
}
|
1824
1835
|
|
1825
1836
|
static void
|
1826
|
-
ca_dimstat_type2_loop (CArray *ca, CArray *co,
|
1837
|
+
ca_dimstat_type2_loop (CArray *ca, CArray *co, ca_size_t mc,
|
1827
1838
|
ca_stat_proc_t *ca_proc,
|
1828
|
-
int level,
|
1839
|
+
int level, ca_size_t *idx, char **op, boolean8_t **om)
|
1829
1840
|
{
|
1830
1841
|
void *p;
|
1831
1842
|
boolean8_t *m;
|
1832
|
-
|
1843
|
+
ca_size_t i, n;
|
1833
1844
|
if ( level == co->rank ) {
|
1834
1845
|
CAStatIterator it;
|
1835
1846
|
n = ca->elements/co->elements;
|
@@ -1854,12 +1865,12 @@ ca_dimstat_type2_loop (CArray *ca, CArray *co, int32_t mc,
|
|
1854
1865
|
}
|
1855
1866
|
|
1856
1867
|
static void
|
1857
|
-
ca_dimstat_type2 (CArray *ca, CArray *co,
|
1868
|
+
ca_dimstat_type2 (CArray *ca, CArray *co, ca_size_t mc, ca_stat_proc_t *ca_proc)
|
1858
1869
|
{
|
1859
|
-
|
1870
|
+
ca_size_t idx[CA_RANK_MAX];
|
1860
1871
|
char *op;
|
1861
1872
|
boolean8_t *om;
|
1862
|
-
|
1873
|
+
int8_t i;
|
1863
1874
|
for (i=0; i<ca->rank; i++) {
|
1864
1875
|
idx[i] = 0;
|
1865
1876
|
}
|
@@ -1878,11 +1889,11 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1878
1889
|
volatile VALUE rndim, rmc, rfval;
|
1879
1890
|
volatile VALUE out;
|
1880
1891
|
CArray *ca, *co;
|
1881
|
-
|
1882
|
-
|
1892
|
+
ca_size_t odim[CA_RANK_MAX], n;
|
1893
|
+
ca_size_t mc, ndim;
|
1883
1894
|
int32_t i;
|
1884
1895
|
|
1885
|
-
rb_scan_args(argc, argv, "12", &rndim, &rmc, &rfval);
|
1896
|
+
rb_scan_args(argc, argv, "12", (VALUE *) &rndim, (VALUE *) &rmc, (VALUE *) &rfval);
|
1886
1897
|
|
1887
1898
|
Data_Get_Struct(self, CArray, ca);
|
1888
1899
|
|
@@ -1892,7 +1903,7 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1892
1903
|
ca_type_name[ca->data_type]);
|
1893
1904
|
}
|
1894
1905
|
|
1895
|
-
ndim =
|
1906
|
+
ndim = NUM2SIZE(rndim);
|
1896
1907
|
if ( ndim <= 0 || ndim > ca->rank ) {
|
1897
1908
|
rb_raise(rb_eRuntimeError, "invalid dimension specified");
|
1898
1909
|
}
|
@@ -1915,7 +1926,7 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1915
1926
|
mc = ca->elements/co->elements - 1;
|
1916
1927
|
}
|
1917
1928
|
else {
|
1918
|
-
mc =
|
1929
|
+
mc = NUM2SIZE(rmc);
|
1919
1930
|
}
|
1920
1931
|
|
1921
1932
|
if ( mc < 0 ) {
|