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/ca_obj_reduce.c
CHANGED
@@ -24,9 +24,9 @@ static VALUE rb_cCAReduce;
|
|
24
24
|
/* ------------------------------------------------------------------- */
|
25
25
|
|
26
26
|
int
|
27
|
-
ca_reduce_setup (CAReduce *ca, CArray *parent,
|
27
|
+
ca_reduce_setup (CAReduce *ca, CArray *parent, ca_size_t count, ca_size_t offset)
|
28
28
|
{
|
29
|
-
|
29
|
+
ca_size_t elements;
|
30
30
|
|
31
31
|
/* check arguments */
|
32
32
|
|
@@ -66,7 +66,7 @@ ca_reduce_setup (CAReduce *ca, CArray *parent, int32_t count, int32_t offset)
|
|
66
66
|
}
|
67
67
|
|
68
68
|
CAReduce *
|
69
|
-
ca_reduce_new (CArray *parent,
|
69
|
+
ca_reduce_new (CArray *parent, ca_size_t count, ca_size_t offset)
|
70
70
|
{
|
71
71
|
CAReduce *ca = ALLOC(CAReduce);
|
72
72
|
ca_reduce_setup(ca, parent, count, offset);
|
@@ -94,21 +94,21 @@ ca_reduce_func_clone (void *ap)
|
|
94
94
|
}
|
95
95
|
|
96
96
|
static char *
|
97
|
-
ca_reduce_func_ptr_at_addr (void *ap,
|
97
|
+
ca_reduce_func_ptr_at_addr (void *ap, ca_size_t addr)
|
98
98
|
{
|
99
99
|
CAReduce *ca = (CAReduce *) ap;
|
100
100
|
return ca->ptr + addr;
|
101
101
|
}
|
102
102
|
|
103
103
|
static char *
|
104
|
-
ca_reduce_func_ptr_at_index (void *ap,
|
104
|
+
ca_reduce_func_ptr_at_index (void *ap, ca_size_t *idx)
|
105
105
|
{
|
106
106
|
CAReduce *ca = (CAReduce *) ap;
|
107
107
|
return ca_func[CA_OBJ_ARRAY].ptr_at_index(ca, idx);
|
108
108
|
}
|
109
109
|
|
110
110
|
static void
|
111
|
-
ca_reduce_func_fetch_addr (void *ap,
|
111
|
+
ca_reduce_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
112
112
|
{
|
113
113
|
CAReduce *ca = (CAReduce *) ap;
|
114
114
|
char q;
|
@@ -124,10 +124,10 @@ ca_reduce_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
124
124
|
}
|
125
125
|
|
126
126
|
static void
|
127
|
-
ca_reduce_func_store_addr (void *ap,
|
127
|
+
ca_reduce_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
128
128
|
{
|
129
129
|
CAReduce *ca = (CAReduce *) ap;
|
130
|
-
|
130
|
+
ca_size_t i;
|
131
131
|
for (i=0; i<ca->count; i++) {
|
132
132
|
ca_store_addr(ca->parent, addr*ca->count+i+ca->offset, ptr);
|
133
133
|
}
|
@@ -147,7 +147,7 @@ ca_reduce_func_attach (void *ap)
|
|
147
147
|
{
|
148
148
|
CAReduce *ca = (CAReduce *) ap;
|
149
149
|
char *p;
|
150
|
-
|
150
|
+
ca_size_t i;
|
151
151
|
ca_attach(ca->parent);
|
152
152
|
/* ca->ptr = ALLOC_N(char, ca->elements); */
|
153
153
|
ca->ptr = malloc_with_check(ca_length(ca));
|
@@ -163,7 +163,7 @@ ca_reduce_func_sync (void *ap)
|
|
163
163
|
{
|
164
164
|
CAReduce *ca = (CAReduce *) ap;
|
165
165
|
char *p;
|
166
|
-
|
166
|
+
ca_size_t i;
|
167
167
|
p = ca->ptr;
|
168
168
|
ca_attach(ca->parent);
|
169
169
|
for (i=0; i<ca->elements; i++) {
|
@@ -187,7 +187,7 @@ static void
|
|
187
187
|
ca_reduce_func_copy_data (void *ap, void *ptr)
|
188
188
|
{
|
189
189
|
CAReduce *ca = (CAReduce *) ap;
|
190
|
-
|
190
|
+
ca_size_t i;
|
191
191
|
char *p;
|
192
192
|
ca_attach(ca->parent);
|
193
193
|
p = ptr;
|
@@ -203,7 +203,7 @@ ca_reduce_func_sync_data (void *ap, void *ptr)
|
|
203
203
|
{
|
204
204
|
CAReduce *ca = (CAReduce *) ap;
|
205
205
|
char *p;
|
206
|
-
|
206
|
+
ca_size_t i;
|
207
207
|
ca_attach(ca->parent);
|
208
208
|
p = ptr;
|
209
209
|
for (i=0; i<ca->elements; i++) {
|
@@ -218,7 +218,7 @@ static void
|
|
218
218
|
ca_reduce_func_fill_data (void *ap, void *ptr)
|
219
219
|
{
|
220
220
|
CAReduce *ca = (CAReduce *) ap;
|
221
|
-
|
221
|
+
ca_size_t i;
|
222
222
|
ca_attach(ca->parent);
|
223
223
|
for (i=0; i<ca->elements; i++) {
|
224
224
|
ca_reduce_func_store_addr(ca, i, ptr);
|
data/ca_obj_refer.c
CHANGED
@@ -21,11 +21,11 @@ VALUE rb_cCARefer;
|
|
21
21
|
|
22
22
|
static int
|
23
23
|
ca_refer_setup (CARefer *ca, CArray *parent,
|
24
|
-
int8_t data_type, int8_t rank,
|
25
|
-
|
24
|
+
int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
|
25
|
+
ca_size_t offset)
|
26
26
|
{
|
27
|
-
|
28
|
-
|
27
|
+
ca_size_t elements, ratio;
|
28
|
+
int8_t i;
|
29
29
|
int is_deformed;
|
30
30
|
|
31
31
|
CA_CHECK_DATA_TYPE(data_type);
|
@@ -82,7 +82,7 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
82
82
|
ca->rank = rank;
|
83
83
|
ca->bytes = bytes;
|
84
84
|
ca->elements = elements;
|
85
|
-
ca->dim = ALLOC_N(
|
85
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
86
86
|
ca->ptr = NULL;
|
87
87
|
ca->mask = NULL;
|
88
88
|
ca->mask0 = NULL;
|
@@ -99,7 +99,7 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
99
99
|
ca->is_deformed = 1;
|
100
100
|
}
|
101
101
|
|
102
|
-
memcpy(ca->dim, dim, rank * sizeof(
|
102
|
+
memcpy(ca->dim, dim, rank * sizeof(ca_size_t));
|
103
103
|
|
104
104
|
if ( ca_is_scalar(parent) ) {
|
105
105
|
ca_set_flag(ca, CA_FLAG_SCALAR);
|
@@ -110,8 +110,8 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
110
110
|
|
111
111
|
CARefer *
|
112
112
|
ca_refer_new (CArray *parent,
|
113
|
-
int8_t data_type, int8_t rank,
|
114
|
-
|
113
|
+
int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
|
114
|
+
ca_size_t offset)
|
115
115
|
{
|
116
116
|
CARefer *ca = ALLOC(CARefer);
|
117
117
|
ca_refer_setup(ca, parent, data_type, rank, dim, bytes, offset);
|
@@ -141,10 +141,10 @@ ca_refer_func_clone (void *ap)
|
|
141
141
|
}
|
142
142
|
|
143
143
|
static char *
|
144
|
-
ca_refer_func_ptr_at_addr (void *ap,
|
144
|
+
ca_refer_func_ptr_at_addr (void *ap, ca_size_t addr)
|
145
145
|
{
|
146
146
|
CARefer *ca = (CARefer *) ap;
|
147
|
-
|
147
|
+
ca_size_t major, minor;
|
148
148
|
switch ( ca->is_deformed ) {
|
149
149
|
case 0:
|
150
150
|
case 1:
|
@@ -161,11 +161,12 @@ ca_refer_func_ptr_at_addr (void *ap, int32_t addr)
|
|
161
161
|
}
|
162
162
|
|
163
163
|
static char *
|
164
|
-
ca_refer_func_ptr_at_index (void *ap,
|
164
|
+
ca_refer_func_ptr_at_index (void *ap, ca_size_t *idx)
|
165
165
|
{
|
166
166
|
CARefer *ca = (CARefer*) ap;
|
167
|
-
|
168
|
-
|
167
|
+
ca_size_t *dim = ca->dim;
|
168
|
+
int8_t i;
|
169
|
+
ca_size_t n;
|
169
170
|
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[rank-1] */
|
170
171
|
for (i=1; i<ca->rank; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[rank-1] */
|
171
172
|
n = dim[i]*n+idx[i]; /* ... + idx[rank-2]*dim[1] + idx[rank-1] */
|
@@ -174,10 +175,10 @@ ca_refer_func_ptr_at_index (void *ap, int32_t *idx)
|
|
174
175
|
}
|
175
176
|
|
176
177
|
static void
|
177
|
-
ca_refer_func_fetch_addr (void *ap,
|
178
|
+
ca_refer_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
178
179
|
{
|
179
180
|
CARefer *ca = (CARefer *) ap;
|
180
|
-
|
181
|
+
ca_size_t major, minor;
|
181
182
|
switch ( ca->is_deformed ) {
|
182
183
|
case 0:
|
183
184
|
ca_fetch_addr(ca->parent, addr, ptr);
|
@@ -213,12 +214,13 @@ ca_refer_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
213
214
|
}
|
214
215
|
|
215
216
|
static void
|
216
|
-
ca_refer_func_fetch_index (void *ap,
|
217
|
+
ca_refer_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
217
218
|
{
|
218
219
|
CARefer *ca = (CARefer *) ap;
|
219
220
|
if ( ca->is_deformed ) {
|
220
|
-
|
221
|
-
|
221
|
+
ca_size_t *dim = ca->dim;
|
222
|
+
int8_t i;
|
223
|
+
ca_size_t n;
|
222
224
|
n = idx[0];
|
223
225
|
for (i=1; i<ca->rank; i++) {
|
224
226
|
n = dim[i]*n+idx[i];
|
@@ -231,10 +233,10 @@ ca_refer_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
231
233
|
}
|
232
234
|
|
233
235
|
static void
|
234
|
-
ca_refer_func_store_addr (void *ap,
|
236
|
+
ca_refer_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
235
237
|
{
|
236
238
|
CARefer *ca = (CARefer *) ap;
|
237
|
-
|
239
|
+
ca_size_t major, minor;
|
238
240
|
switch ( ca->is_deformed ) {
|
239
241
|
case 0:
|
240
242
|
ca_store_addr(ca->parent, addr, ptr);
|
@@ -273,12 +275,13 @@ ca_refer_func_store_addr (void *ap, int32_t addr, void *ptr)
|
|
273
275
|
}
|
274
276
|
|
275
277
|
static void
|
276
|
-
ca_refer_func_store_index (void *ap,
|
278
|
+
ca_refer_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
277
279
|
{
|
278
280
|
CARefer *ca = (CARefer *) ap;
|
279
281
|
if ( ca->is_deformed ) {
|
280
|
-
|
281
|
-
|
282
|
+
ca_size_t *dim = ca->dim;
|
283
|
+
int8_t i;
|
284
|
+
ca_size_t n;
|
282
285
|
n = idx[0];
|
283
286
|
for (i=1; i<ca->rank; i++) {
|
284
287
|
n = dim[i]*n+idx[i];
|
@@ -354,8 +357,8 @@ ca_refer_func_sync_data (void *ap, void *ptr)
|
|
354
357
|
|
355
358
|
#define proc_fill_bang_fixlen() \
|
356
359
|
{ \
|
357
|
-
|
358
|
-
|
360
|
+
ca_size_t i; \
|
361
|
+
ca_size_t bytes = ca->bytes; \
|
359
362
|
char *p = ca->parent->ptr + ca->parent->bytes * ca->offset; \
|
360
363
|
for (i=ca->elements; i; i--, p+=bytes) { \
|
361
364
|
memcpy(p, val, bytes); \
|
@@ -364,7 +367,7 @@ ca_refer_func_sync_data (void *ap, void *ptr)
|
|
364
367
|
|
365
368
|
#define proc_fill_bang(type) \
|
366
369
|
{ \
|
367
|
-
|
370
|
+
ca_size_t i; \
|
368
371
|
type *p = (type *)(ca->parent->ptr + ca->parent->bytes * ca->offset); \
|
369
372
|
type v = *(type *)val; \
|
370
373
|
for (i=ca->elements; i; i--, p++) { \
|
@@ -421,7 +424,7 @@ ca_refer_func_create_mask (void *ap)
|
|
421
424
|
CA_BOOLEAN, ca->rank, ca->dim, 0, ca->offset);
|
422
425
|
}
|
423
426
|
else if ( ca->is_deformed == -2 ) {
|
424
|
-
|
427
|
+
ca_size_t count[CA_RANK_MAX];
|
425
428
|
int i;
|
426
429
|
for (i=0; i<ca->parent->rank; i++) {
|
427
430
|
count[i] = 0;
|
@@ -512,9 +515,9 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
512
515
|
CARefer *cr;
|
513
516
|
int8_t data_type;
|
514
517
|
int8_t rank;
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
+
ca_size_t dim[CA_RANK_MAX];
|
519
|
+
ca_size_t bytes, offset = 0;
|
520
|
+
int8_t i;
|
518
521
|
|
519
522
|
Data_Get_Struct(self, CArray, ca);
|
520
523
|
|
@@ -532,10 +535,10 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
532
535
|
}
|
533
536
|
else {
|
534
537
|
volatile VALUE rtype, rdim, ropt, rbytes = Qnil, roffset = Qnil;
|
535
|
-
|
538
|
+
ca_size_t elements;
|
536
539
|
|
537
540
|
ropt = rb_pop_options(&argc, &argv);
|
538
|
-
rb_scan_args(argc, argv, "11", &rtype, &rdim);
|
541
|
+
rb_scan_args(argc, argv, "11", (VALUE *) &rtype, (VALUE *) &rdim);
|
539
542
|
rb_scan_options(ropt, "bytes,offset", &rbytes, &roffset);
|
540
543
|
|
541
544
|
if ( NIL_P(rbytes) ) {
|
@@ -559,12 +562,12 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
559
562
|
|
560
563
|
elements = 1;
|
561
564
|
for (i=0; i<rank; i++) {
|
562
|
-
dim[i] =
|
565
|
+
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
563
566
|
elements *= dim[i];
|
564
567
|
}
|
565
568
|
|
566
569
|
if ( ! NIL_P(roffset) ) {
|
567
|
-
offset =
|
570
|
+
offset = NUM2SIZE(roffset);
|
568
571
|
}
|
569
572
|
|
570
573
|
cr = ca_refer_new((CArray*)ca, data_type, rank, dim, bytes, offset);
|
@@ -581,18 +584,18 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
581
584
|
|
582
585
|
VALUE
|
583
586
|
rb_ca_refer_new (VALUE self,
|
584
|
-
int8_t data_type, int8_t rank,
|
585
|
-
|
587
|
+
int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
|
588
|
+
ca_size_t offset)
|
586
589
|
{
|
587
590
|
volatile VALUE list, rdim, ropt;
|
588
591
|
CArray *ca;
|
589
|
-
|
592
|
+
int8_t i;
|
590
593
|
|
591
594
|
Data_Get_Struct(self, CArray, ca);
|
592
595
|
|
593
596
|
rdim = rb_ary_new2(rank);
|
594
597
|
for (i=0; i<rank; i++) {
|
595
|
-
rb_ary_store(rdim, i,
|
598
|
+
rb_ary_store(rdim, i, SIZE2NUM(dim[i]));
|
596
599
|
}
|
597
600
|
|
598
601
|
list = rb_ary_new2(3);
|
@@ -604,7 +607,7 @@ rb_ca_refer_new (VALUE self,
|
|
604
607
|
}
|
605
608
|
rb_ary_store(list, 1, rdim);
|
606
609
|
ropt = rb_hash_new();
|
607
|
-
rb_set_options(ropt, "bytes,offset",
|
610
|
+
rb_set_options(ropt, "bytes,offset", SIZE2NUM(bytes), SIZE2NUM(offset));
|
608
611
|
rb_ary_store(list, 2, ropt);
|
609
612
|
|
610
613
|
return rb_ca_refer(3, RARRAY_PTR(list), self);
|
data/ca_obj_repeat.c
CHANGED
@@ -20,10 +20,10 @@ VALUE rb_cCARepeat;
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
int
|
23
|
-
ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank,
|
23
|
+
ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
|
24
24
|
{
|
25
25
|
int8_t data_type;
|
26
|
-
|
26
|
+
ca_size_t elements, bytes, nrpt, repeat_level, repeat_num,
|
27
27
|
contig_level, contig_num, data_rank;
|
28
28
|
int i, j;
|
29
29
|
|
@@ -78,12 +78,12 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, int32_t *count)
|
|
78
78
|
ca->elements = elements;
|
79
79
|
ca->ptr = NULL;
|
80
80
|
ca->mask = NULL;
|
81
|
-
ca->dim = ALLOC_N(
|
81
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
82
82
|
|
83
83
|
ca->parent = parent;
|
84
84
|
ca->attach = 0;
|
85
85
|
ca->nosync = 0;
|
86
|
-
ca->count = ALLOC_N(
|
86
|
+
ca->count = ALLOC_N(ca_size_t, rank);
|
87
87
|
ca->repeat_level = repeat_level;
|
88
88
|
ca->repeat_num = repeat_num;
|
89
89
|
ca->contig_level = contig_level;
|
@@ -99,7 +99,7 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, int32_t *count)
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
|
102
|
-
memcpy(ca->count, count, rank * sizeof(
|
102
|
+
memcpy(ca->count, count, rank * sizeof(ca_size_t));
|
103
103
|
|
104
104
|
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
105
105
|
|
@@ -112,7 +112,7 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, int32_t *count)
|
|
112
112
|
|
113
113
|
|
114
114
|
CARepeat *
|
115
|
-
ca_repeat_new (CArray *parent, int8_t rank,
|
115
|
+
ca_repeat_new (CArray *parent, int8_t rank, ca_size_t *count)
|
116
116
|
{
|
117
117
|
CARepeat *ca = ALLOC(CARepeat);
|
118
118
|
ca_repeat_setup(ca, parent, rank, count);
|
@@ -145,30 +145,31 @@ ca_repeat_func_clone (void *ap)
|
|
145
145
|
}
|
146
146
|
|
147
147
|
static char *
|
148
|
-
ca_repeat_func_ptr_at_addr (void *ap,
|
148
|
+
ca_repeat_func_ptr_at_addr (void *ap, ca_size_t addr)
|
149
149
|
{
|
150
150
|
CARepeat *ca = (CARepeat *) ap;
|
151
151
|
if ( ca->ptr ) {
|
152
152
|
return ca->ptr + ca->bytes * addr;
|
153
153
|
}
|
154
154
|
else {
|
155
|
-
|
155
|
+
ca_size_t idx[CA_RANK_MAX];
|
156
156
|
ca_addr2index((CArray *)ca, addr, idx);
|
157
157
|
return ca_ptr_at_index(ca, idx);
|
158
158
|
}
|
159
159
|
}
|
160
160
|
|
161
161
|
static char *
|
162
|
-
ca_repeat_func_ptr_at_index (void *ap,
|
162
|
+
ca_repeat_func_ptr_at_index (void *ap, ca_size_t *idx)
|
163
163
|
{
|
164
164
|
CARepeat *ca = (CARepeat *) ap;
|
165
165
|
if ( ca->ptr ) {
|
166
166
|
return ca_array_func_ptr_at_index(ca, idx);
|
167
167
|
}
|
168
168
|
else {
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
ca_size_t *count = ca->count;
|
170
|
+
ca_size_t *dim0 = ca->parent->dim;
|
171
|
+
int8_t i;
|
172
|
+
ca_size_t n, j;
|
172
173
|
|
173
174
|
j = 0;
|
174
175
|
n = 0;
|
@@ -189,12 +190,13 @@ ca_repeat_func_ptr_at_index (void *ap, int32_t *idx)
|
|
189
190
|
}
|
190
191
|
|
191
192
|
static void
|
192
|
-
ca_repeat_func_fetch_index (void *ap,
|
193
|
+
ca_repeat_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
193
194
|
{
|
194
195
|
CARepeat *ca = (CARepeat *) ap;
|
195
|
-
|
196
|
-
|
197
|
-
|
196
|
+
ca_size_t *count = ca->count;
|
197
|
+
ca_size_t idx0[CA_RANK_MAX];
|
198
|
+
int8_t i;
|
199
|
+
ca_size_t n, j;
|
198
200
|
j = 0;
|
199
201
|
n = 0;
|
200
202
|
for (i=0; i<ca->rank; i++) {
|
@@ -206,12 +208,13 @@ ca_repeat_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
206
208
|
}
|
207
209
|
|
208
210
|
static void
|
209
|
-
ca_repeat_func_store_index (void *ap,
|
211
|
+
ca_repeat_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
210
212
|
{
|
211
213
|
CARepeat *ca = (CARepeat *) ap;
|
212
|
-
|
213
|
-
|
214
|
-
|
214
|
+
ca_size_t *count = ca->count;
|
215
|
+
ca_size_t idx0[CA_RANK_MAX];
|
216
|
+
int8_t i;
|
217
|
+
ca_size_t n, j;
|
215
218
|
j = 0;
|
216
219
|
n = 0;
|
217
220
|
for (i=0; i<ca->rank; i++) {
|
@@ -329,7 +332,7 @@ ca_operation_function_t ca_repeat_func = {
|
|
329
332
|
/* ------------------------------------------------------------------- */
|
330
333
|
|
331
334
|
static void
|
332
|
-
memfill (void *dp, void *sp,
|
335
|
+
memfill (void *dp, void *sp, ca_size_t bytes, ca_size_t n)
|
333
336
|
{
|
334
337
|
switch ( bytes ) {
|
335
338
|
case 1:
|
@@ -351,7 +354,7 @@ memfill (void *dp, void *sp, size_t bytes, size_t n)
|
|
351
354
|
break;
|
352
355
|
}
|
353
356
|
default: {
|
354
|
-
|
357
|
+
ca_size_t i;
|
355
358
|
char *p = (char *) dp, *q = (char *) sp;
|
356
359
|
for (i=0; i<n; i++) {
|
357
360
|
memcpy(p, q, bytes);
|
@@ -363,10 +366,10 @@ memfill (void *dp, void *sp, size_t bytes, size_t n)
|
|
363
366
|
|
364
367
|
static void
|
365
368
|
ca_repeat_attach_loop1 (CARepeat *ca, int8_t level, int8_t level0,
|
366
|
-
|
369
|
+
ca_size_t *idx, ca_size_t *idx0)
|
367
370
|
{
|
368
|
-
|
369
|
-
|
371
|
+
ca_size_t *count = ca->count;
|
372
|
+
ca_size_t i;
|
370
373
|
|
371
374
|
if ( level == ca->contig_level ) {
|
372
375
|
if ( ca->contig_num == 1 ) {
|
@@ -402,9 +405,9 @@ ca_repeat_attach_loop1 (CARepeat *ca, int8_t level, int8_t level0,
|
|
402
405
|
static void
|
403
406
|
ca_repeat_attach (CARepeat *ca)
|
404
407
|
{
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
+
ca_size_t idx[CA_RANK_MAX];
|
409
|
+
ca_size_t idx0[CA_RANK_MAX];
|
410
|
+
ca_size_t i;
|
408
411
|
char *dp, *sp;
|
409
412
|
|
410
413
|
for (i=0; i<ca->rank; i++) {
|
@@ -422,10 +425,10 @@ ca_repeat_attach (CARepeat *ca)
|
|
422
425
|
|
423
426
|
static void
|
424
427
|
ca_repeat_sync_loop (CARepeat *ca, int8_t level, int8_t level0,
|
425
|
-
|
428
|
+
ca_size_t *idx, ca_size_t *idx0)
|
426
429
|
{
|
427
|
-
|
428
|
-
|
430
|
+
ca_size_t *count = ca->count;
|
431
|
+
ca_size_t i;
|
429
432
|
|
430
433
|
if ( level == ca->contig_level ) {
|
431
434
|
if ( ca->contig_num == 1 ) {
|
@@ -453,9 +456,9 @@ ca_repeat_sync_loop (CARepeat *ca, int8_t level, int8_t level0,
|
|
453
456
|
static void
|
454
457
|
ca_repeat_sync (CARepeat *ca)
|
455
458
|
{
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
+
ca_size_t idx[CA_RANK_MAX];
|
460
|
+
ca_size_t idx0[CA_RANK_MAX];
|
461
|
+
int8_t i;
|
459
462
|
for (i=0; i<ca->rank; i++) {
|
460
463
|
idx[i] = 0;
|
461
464
|
idx0[i] = 0;
|
@@ -472,7 +475,7 @@ ca_repeat_fill (CARepeat *ca, char *ptr)
|
|
472
475
|
/* ------------------------------------------------------------------- */
|
473
476
|
|
474
477
|
VALUE
|
475
|
-
rb_ca_repeat_new (VALUE cary, int8_t rank,
|
478
|
+
rb_ca_repeat_new (VALUE cary, int8_t rank, ca_size_t *count)
|
476
479
|
{
|
477
480
|
volatile VALUE obj;
|
478
481
|
CArray *parent;
|
@@ -491,9 +494,9 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
491
494
|
{
|
492
495
|
volatile VALUE obj;
|
493
496
|
CArray *ca;
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
+
ca_size_t count[CA_RANK_MAX];
|
498
|
+
ca_size_t repeat;
|
499
|
+
ca_size_t i;
|
497
500
|
|
498
501
|
Data_Get_Struct(self, CArray, ca);
|
499
502
|
|
@@ -504,7 +507,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
504
507
|
) ) {
|
505
508
|
volatile VALUE args;
|
506
509
|
CArray *ct;
|
507
|
-
|
510
|
+
ca_size_t rank, dim[CA_RANK_MAX];
|
508
511
|
int k;
|
509
512
|
if ( argv[0] == ID2SYM(rb_intern("%") ) ) {
|
510
513
|
Data_Get_Struct(argv[1], CArray, ct);
|
@@ -521,7 +524,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
521
524
|
k = 0;
|
522
525
|
for (i=0; i<ct->rank; i++) {
|
523
526
|
if ( ca->dim[k] == 1 ) {
|
524
|
-
rb_ary_push(args,
|
527
|
+
rb_ary_push(args, SIZE2NUM(ct->dim[i]));
|
525
528
|
k++;
|
526
529
|
}
|
527
530
|
else if ( ct->dim[i] == ca->dim[k] ) {
|
@@ -530,7 +533,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
530
533
|
k++; rank++;
|
531
534
|
}
|
532
535
|
else {
|
533
|
-
rb_ary_push(args,
|
536
|
+
rb_ary_push(args, SIZE2NUM(ct->dim[i]));
|
534
537
|
}
|
535
538
|
}
|
536
539
|
if ( rank != ca->rank ) {
|
@@ -541,7 +544,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
541
544
|
k = ca->rank - 1;
|
542
545
|
for (i=ct->rank-1; i>=0; i--) {
|
543
546
|
if ( ca->dim[k] == 1 ) {
|
544
|
-
rb_ary_unshift(args,
|
547
|
+
rb_ary_unshift(args, SIZE2NUM(ct->dim[i]));
|
545
548
|
k--;
|
546
549
|
}
|
547
550
|
else if ( ct->dim[i] == ca->dim[k] ) {
|
@@ -549,7 +552,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
549
552
|
k--;
|
550
553
|
}
|
551
554
|
else {
|
552
|
-
rb_ary_unshift(args,
|
555
|
+
rb_ary_unshift(args, SIZE2NUM(ct->dim[i]));
|
553
556
|
}
|
554
557
|
}
|
555
558
|
if ( k != 0 ) {
|
@@ -563,7 +566,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
563
566
|
self = rb_ca_refer_new(self, ca->data_type, rank, dim, ca->bytes, 0);
|
564
567
|
}
|
565
568
|
}
|
566
|
-
return rb_ca_repeat(RARRAY_LEN(args), RARRAY_PTR(args), self);
|
569
|
+
return rb_ca_repeat((int)RARRAY_LEN(args), RARRAY_PTR(args), self);
|
567
570
|
}
|
568
571
|
|
569
572
|
repeat = 1;
|
@@ -577,7 +580,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
577
580
|
}
|
578
581
|
}
|
579
582
|
else {
|
580
|
-
count[i] =
|
583
|
+
count[i] = NUM2SIZE(argv[i]);
|
581
584
|
if ( count[i] == 0 ) {
|
582
585
|
rb_raise(rb_eArgError,
|
583
586
|
"zero repeat count specified in creating CARepeat object");
|
@@ -587,8 +590,8 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
587
590
|
}
|
588
591
|
|
589
592
|
if ( repeat == 1 ) {
|
590
|
-
|
591
|
-
|
593
|
+
ca_size_t dim[CA_RANK_MAX];
|
594
|
+
int8_t j = 0;
|
592
595
|
for (i=0; i<argc; i++) {
|
593
596
|
if ( count[i] == 0 ) {
|
594
597
|
dim[i] = ca->dim[j];
|