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_select.c
CHANGED
@@ -24,9 +24,9 @@ typedef struct {
|
|
24
24
|
int8_t data_type;
|
25
25
|
int8_t rank;
|
26
26
|
int32_t flags;
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
ca_size_t bytes;
|
28
|
+
ca_size_t elements;
|
29
|
+
ca_size_t *dim; /* point to _dim */
|
30
30
|
char *ptr;
|
31
31
|
CArray *mask;
|
32
32
|
CArray *parent;
|
@@ -34,7 +34,7 @@ typedef struct {
|
|
34
34
|
uint8_t nosync;
|
35
35
|
/* ---------- */
|
36
36
|
CArray *select;
|
37
|
-
|
37
|
+
ca_size_t _dim;
|
38
38
|
} CASelect;
|
39
39
|
|
40
40
|
/* ------------------------------------------------------------------- */
|
@@ -43,7 +43,7 @@ static int
|
|
43
43
|
ca_select_setup (CASelect *ca, CArray *parent, CArray *select, int share)
|
44
44
|
{
|
45
45
|
int8_t data_type;
|
46
|
-
|
46
|
+
ca_size_t bytes;
|
47
47
|
int i;
|
48
48
|
|
49
49
|
if ( ! ca_is_boolean_type(select) ) {
|
@@ -157,7 +157,7 @@ ca_select_func_clone (void *ap)
|
|
157
157
|
}
|
158
158
|
|
159
159
|
static char *
|
160
|
-
ca_select_func_ptr_at_addr (void *ap,
|
160
|
+
ca_select_func_ptr_at_addr (void *ap, ca_size_t addr)
|
161
161
|
{
|
162
162
|
CASelect *ca = (CASelect *) ap;
|
163
163
|
|
@@ -165,8 +165,8 @@ ca_select_func_ptr_at_addr (void *ap, int32_t addr)
|
|
165
165
|
return ca->ptr + ca->bytes * addr;
|
166
166
|
}
|
167
167
|
else {
|
168
|
-
|
169
|
-
|
168
|
+
ca_size_t n, i, a;
|
169
|
+
ca_size_t elements = ca->select->elements;
|
170
170
|
boolean8_t s;
|
171
171
|
|
172
172
|
n = 0;
|
@@ -192,10 +192,10 @@ ca_select_func_ptr_at_addr (void *ap, int32_t addr)
|
|
192
192
|
}
|
193
193
|
|
194
194
|
static char *
|
195
|
-
ca_select_func_ptr_at_index (void *ap,
|
195
|
+
ca_select_func_ptr_at_index (void *ap, ca_size_t *idx)
|
196
196
|
{
|
197
197
|
CASelect *ca = (CASelect *) ap;
|
198
|
-
|
198
|
+
ca_size_t addr = idx[0];
|
199
199
|
|
200
200
|
if ( ca->ptr ) {
|
201
201
|
return ca->ptr + ca->bytes * addr;
|
@@ -206,11 +206,11 @@ ca_select_func_ptr_at_index (void *ap, int32_t *idx)
|
|
206
206
|
}
|
207
207
|
|
208
208
|
static void
|
209
|
-
ca_select_func_fetch_addr (void *ap,
|
209
|
+
ca_select_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
210
210
|
{
|
211
211
|
CASelect *ca = (CASelect *) ap;
|
212
|
-
|
213
|
-
|
212
|
+
ca_size_t n, i, a;
|
213
|
+
ca_size_t elements = ca->select->elements;
|
214
214
|
boolean8_t s;
|
215
215
|
n = 0;
|
216
216
|
a = 0;
|
@@ -227,17 +227,17 @@ ca_select_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
227
227
|
}
|
228
228
|
|
229
229
|
static void
|
230
|
-
ca_select_func_fetch_index (void *ap,
|
230
|
+
ca_select_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
231
231
|
{
|
232
232
|
ca_select_func_fetch_addr(ap, idx[0], ptr);
|
233
233
|
}
|
234
234
|
|
235
235
|
static void
|
236
|
-
ca_select_func_store_addr (void *ap,
|
236
|
+
ca_select_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
237
237
|
{
|
238
238
|
CASelect *ca = (CASelect *) ap;
|
239
|
-
|
240
|
-
|
239
|
+
ca_size_t n, i, a;
|
240
|
+
ca_size_t elements = ca->select->elements;
|
241
241
|
boolean8_t s;
|
242
242
|
n = 0;
|
243
243
|
a = 0;
|
@@ -254,7 +254,7 @@ ca_select_func_store_addr (void *ap, int32_t addr, void *ptr)
|
|
254
254
|
}
|
255
255
|
|
256
256
|
static void
|
257
|
-
ca_select_func_store_index (void *ap,
|
257
|
+
ca_select_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
258
258
|
{
|
259
259
|
ca_select_func_store_addr(ap, idx[0], ptr);
|
260
260
|
}
|
@@ -418,7 +418,7 @@ void
|
|
418
418
|
ca_select_to_ptr (CArray *ca, CArray *select, char *ptr)
|
419
419
|
{
|
420
420
|
boolean8_t *s = (boolean8_t*) select->ptr;
|
421
|
-
|
421
|
+
ca_size_t i;
|
422
422
|
|
423
423
|
switch ( ca->bytes ) {
|
424
424
|
case 1: proc_select_to_ptr(int8_t); break;
|
@@ -427,7 +427,7 @@ ca_select_to_ptr (CArray *ca, CArray *select, char *ptr)
|
|
427
427
|
case 8: proc_select_to_ptr(float64_t); break;
|
428
428
|
default: {
|
429
429
|
char *p = ptr, *q = ca->ptr;
|
430
|
-
|
430
|
+
ca_size_t bytes = ca->bytes;
|
431
431
|
for (i=ca->elements; i; i--) {
|
432
432
|
if ( *s ) {
|
433
433
|
memcpy(q, p, bytes);
|
@@ -459,7 +459,7 @@ void
|
|
459
459
|
ca_select_from_ptr (CArray *ca, CArray *select, char *ptr)
|
460
460
|
{
|
461
461
|
boolean8_t *s = (boolean8_t *) select->ptr;
|
462
|
-
|
462
|
+
ca_size_t i;
|
463
463
|
|
464
464
|
switch ( ca->bytes ) {
|
465
465
|
case 1: proc_select_from_ptr(int8_t); break;
|
@@ -469,7 +469,7 @@ ca_select_from_ptr (CArray *ca, CArray *select, char *ptr)
|
|
469
469
|
default: {
|
470
470
|
char *p = ptr;
|
471
471
|
char *q = ca->ptr;
|
472
|
-
|
472
|
+
ca_size_t bytes = ca->bytes;
|
473
473
|
for (i=ca->elements; i; i--) {
|
474
474
|
if ( *s ) {
|
475
475
|
memcpy(q, p, bytes);
|
@@ -501,7 +501,7 @@ void
|
|
501
501
|
ca_select_fill (CArray *ca, CArray *select, char *valp)
|
502
502
|
{
|
503
503
|
boolean8_t *s = (boolean8_t *) select->ptr;
|
504
|
-
|
504
|
+
ca_size_t i;
|
505
505
|
|
506
506
|
switch ( ca->bytes ) {
|
507
507
|
case 1: proc_select_fill(int8_t); break;
|
@@ -510,7 +510,7 @@ ca_select_fill (CArray *ca, CArray *select, char *valp)
|
|
510
510
|
case 8: proc_select_fill(float64_t); break;
|
511
511
|
default: {
|
512
512
|
char *q = ca->ptr;
|
513
|
-
|
513
|
+
ca_size_t bytes = ca->bytes;
|
514
514
|
for (i=ca->elements; i; i--) {
|
515
515
|
if ( *s ) {
|
516
516
|
memcpy(q, valp, bytes);
|
data/ca_obj_shift.c
CHANGED
@@ -24,16 +24,16 @@ typedef struct {
|
|
24
24
|
int8_t data_type;
|
25
25
|
int8_t rank;
|
26
26
|
int32_t flags;
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
ca_size_t bytes;
|
28
|
+
ca_size_t elements;
|
29
|
+
ca_size_t *dim;
|
30
30
|
char *ptr;
|
31
31
|
CArray *mask;
|
32
32
|
CArray *parent;
|
33
33
|
uint32_t attach;
|
34
34
|
uint8_t nosync;
|
35
35
|
/* -------------*/
|
36
|
-
|
36
|
+
ca_size_t *shift;
|
37
37
|
char *fill;
|
38
38
|
int8_t *roll;
|
39
39
|
int fill_mask;
|
@@ -45,10 +45,10 @@ static int8_t CA_OBJ_SHIFT;
|
|
45
45
|
|
46
46
|
int
|
47
47
|
ca_shift_setup (CAShift *ca, CArray *parent,
|
48
|
-
|
48
|
+
ca_size_t *shift, char *fill, int8_t *roll)
|
49
49
|
{
|
50
50
|
int8_t data_type, rank;
|
51
|
-
|
51
|
+
ca_size_t elements, bytes;
|
52
52
|
|
53
53
|
data_type = parent->data_type;
|
54
54
|
bytes = parent->bytes;
|
@@ -64,17 +64,17 @@ ca_shift_setup (CAShift *ca, CArray *parent,
|
|
64
64
|
ca->elements = elements;
|
65
65
|
ca->ptr = NULL;
|
66
66
|
ca->mask = NULL;
|
67
|
-
ca->dim = ALLOC_N(
|
67
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
68
68
|
|
69
69
|
ca->parent = parent;
|
70
70
|
ca->attach = 0;
|
71
71
|
ca->nosync = 0;
|
72
|
-
ca->shift = ALLOC_N(
|
72
|
+
ca->shift = ALLOC_N(ca_size_t, rank);
|
73
73
|
ca->fill = ALLOC_N(char, ca->bytes);
|
74
74
|
ca->roll = ALLOC_N(int8_t, rank);
|
75
75
|
|
76
|
-
memcpy(ca->dim, parent->dim, rank * sizeof(
|
77
|
-
memcpy(ca->shift, shift, rank * sizeof(
|
76
|
+
memcpy(ca->dim, parent->dim, rank * sizeof(ca_size_t));
|
77
|
+
memcpy(ca->shift, shift, rank * sizeof(ca_size_t));
|
78
78
|
memcpy(ca->roll, roll, rank * sizeof(int8_t));
|
79
79
|
|
80
80
|
if ( fill ) {
|
@@ -94,7 +94,7 @@ ca_shift_setup (CAShift *ca, CArray *parent,
|
|
94
94
|
}
|
95
95
|
|
96
96
|
CAShift *
|
97
|
-
ca_shift_new (CArray *parent,
|
97
|
+
ca_shift_new (CArray *parent, ca_size_t *shift, char *fill, int8_t *roll)
|
98
98
|
{
|
99
99
|
CAShift *ca = ALLOC(CAShift);
|
100
100
|
ca_shift_setup(ca, parent, shift, fill, roll);
|
@@ -119,11 +119,11 @@ static void ca_shift_attach (CAShift *ca);
|
|
119
119
|
static void ca_shift_sync (CAShift *ca);
|
120
120
|
static void ca_shift_fill (CAShift *ca, char *ptr);
|
121
121
|
|
122
|
-
static
|
123
|
-
ca_shift_normalized_roll_shift (CAShift *ca,
|
122
|
+
static ca_size_t
|
123
|
+
ca_shift_normalized_roll_shift (CAShift *ca, ca_size_t i)
|
124
124
|
{
|
125
|
-
|
126
|
-
|
125
|
+
ca_size_t dim = ca->dim[i];
|
126
|
+
ca_size_t shift = ca->shift[i];
|
127
127
|
if ( shift >= 0 ) {
|
128
128
|
return shift % dim;
|
129
129
|
}
|
@@ -132,12 +132,12 @@ ca_shift_normalized_roll_shift (CAShift *ca, int32_t i)
|
|
132
132
|
}
|
133
133
|
}
|
134
134
|
|
135
|
-
static
|
136
|
-
ca_shift_rolled_index (CAShift *ca,
|
135
|
+
static ca_size_t
|
136
|
+
ca_shift_rolled_index (CAShift *ca, ca_size_t i, ca_size_t k)
|
137
137
|
{
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
ca_size_t dim = ca->dim[i];
|
139
|
+
ca_size_t shift = ca->shift[i];
|
140
|
+
ca_size_t idx = k - shift;
|
141
141
|
if ( idx >= 0 ) {
|
142
142
|
return idx % dim;
|
143
143
|
}
|
@@ -147,12 +147,12 @@ ca_shift_rolled_index (CAShift *ca, int32_t i, int32_t k)
|
|
147
147
|
}
|
148
148
|
}
|
149
149
|
|
150
|
-
static
|
151
|
-
ca_shift_shifted_index (CAShift *ca,
|
150
|
+
static ca_size_t
|
151
|
+
ca_shift_shifted_index (CAShift *ca, ca_size_t i, ca_size_t k)
|
152
152
|
{
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
ca_size_t dim = ca->dim[i];
|
154
|
+
ca_size_t shift = ca->shift[i];
|
155
|
+
ca_size_t idx = k - shift;
|
156
156
|
if ( idx < 0 || idx >= dim ) {
|
157
157
|
return -1;
|
158
158
|
}
|
@@ -171,11 +171,11 @@ ca_shift_func_clone (void *ap)
|
|
171
171
|
}
|
172
172
|
|
173
173
|
static char *
|
174
|
-
ca_shift_func_ptr_at_addr (void *ap,
|
174
|
+
ca_shift_func_ptr_at_addr (void *ap, ca_size_t addr)
|
175
175
|
{
|
176
176
|
CAShift *ca = (CAShift *) ap;
|
177
177
|
if ( ! ca->ptr ) {
|
178
|
-
|
178
|
+
ca_size_t idx[CA_RANK_MAX];
|
179
179
|
ca_addr2index((CArray *)ca, addr, idx);
|
180
180
|
return ca_ptr_at_index(ca, idx);
|
181
181
|
}
|
@@ -185,13 +185,14 @@ ca_shift_func_ptr_at_addr (void *ap, int32_t addr)
|
|
185
185
|
}
|
186
186
|
|
187
187
|
static char *
|
188
|
-
ca_shift_func_ptr_at_index (void *ap,
|
188
|
+
ca_shift_func_ptr_at_index (void *ap, ca_size_t *idx)
|
189
189
|
{
|
190
190
|
CAShift *ca = (CAShift *) ap;
|
191
191
|
if ( ! ca->ptr ) {
|
192
|
-
|
192
|
+
ca_size_t *dim = ca->dim;
|
193
193
|
int8_t *roll = ca->roll;
|
194
|
-
|
194
|
+
int8_t i;
|
195
|
+
ca_size_t k, n;
|
195
196
|
n = 0;
|
196
197
|
for (i=0; i<ca->rank; i++) {
|
197
198
|
k = idx[i];
|
@@ -221,12 +222,13 @@ ca_shift_func_ptr_at_index (void *ap, int32_t *idx)
|
|
221
222
|
}
|
222
223
|
|
223
224
|
static void
|
224
|
-
ca_shift_func_fetch_index (void *ap,
|
225
|
+
ca_shift_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
225
226
|
{
|
226
227
|
CAShift *ca = (CAShift *) ap;
|
227
|
-
|
228
|
+
ca_size_t *dim = ca->dim;
|
228
229
|
int8_t *roll = ca->roll;
|
229
|
-
|
230
|
+
int8_t i;
|
231
|
+
ca_size_t k, n;
|
230
232
|
n = 0;
|
231
233
|
for (i=0; i<ca->rank; i++) {
|
232
234
|
k = idx[i];
|
@@ -247,12 +249,13 @@ ca_shift_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
247
249
|
}
|
248
250
|
|
249
251
|
static void
|
250
|
-
ca_shift_func_store_index (void *ap,
|
252
|
+
ca_shift_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
251
253
|
{
|
252
254
|
CAShift *ca = (CAShift *) ap;
|
253
|
-
|
255
|
+
ca_size_t *dim = ca->dim;
|
254
256
|
int8_t *roll = ca->roll;
|
255
|
-
|
257
|
+
int8_t i;
|
258
|
+
ca_size_t k, n;
|
256
259
|
n = 0;
|
257
260
|
for (i=0; i<ca->rank; i++) {
|
258
261
|
k = idx[i];
|
@@ -391,13 +394,13 @@ ca_operation_function_t ca_shift_func = {
|
|
391
394
|
/* ------------------------------------------------------------------- */
|
392
395
|
|
393
396
|
static void
|
394
|
-
ca_shift_attach_loop (CAShift *ca, int16_t level,
|
397
|
+
ca_shift_attach_loop (CAShift *ca, int16_t level, ca_size_t *idx, ca_size_t *idx0,
|
395
398
|
int32_t fill)
|
396
399
|
{
|
397
|
-
|
398
|
-
|
400
|
+
ca_size_t dim = ca->dim[level];
|
401
|
+
ca_size_t shift = ca->shift[level];
|
399
402
|
int8_t roll = ca->roll[level];
|
400
|
-
|
403
|
+
ca_size_t i;
|
401
404
|
|
402
405
|
if ( level == ca->rank - 1 ) {
|
403
406
|
if ( fill ) {
|
@@ -545,18 +548,18 @@ ca_shift_attach_loop (CAShift *ca, int16_t level, int32_t *idx, int32_t *idx0,
|
|
545
548
|
static void
|
546
549
|
ca_shift_attach (CAShift *ca)
|
547
550
|
{
|
548
|
-
|
549
|
-
|
551
|
+
ca_size_t idx[CA_RANK_MAX];
|
552
|
+
ca_size_t idx0[CA_RANK_MAX];
|
550
553
|
ca_shift_attach_loop(ca, (int16_t) 0, idx, idx0, 0);
|
551
554
|
}
|
552
555
|
|
553
556
|
static void
|
554
|
-
ca_shift_sync_loop (CAShift *ca, int16_t level,
|
557
|
+
ca_shift_sync_loop (CAShift *ca, int16_t level, ca_size_t *idx, ca_size_t *idx0)
|
555
558
|
{
|
556
|
-
|
557
|
-
|
559
|
+
ca_size_t dim = ca->dim[level];
|
560
|
+
ca_size_t shift = ca->shift[level];
|
558
561
|
int8_t roll = ca->roll[level];
|
559
|
-
|
562
|
+
ca_size_t i;
|
560
563
|
|
561
564
|
if ( level == ca->rank - 1 ) {
|
562
565
|
if ( ! shift ) {
|
@@ -688,19 +691,19 @@ ca_shift_sync_loop (CAShift *ca, int16_t level, int32_t *idx, int32_t *idx0)
|
|
688
691
|
static void
|
689
692
|
ca_shift_sync (CAShift *ca)
|
690
693
|
{
|
691
|
-
|
692
|
-
|
694
|
+
ca_size_t idx[CA_RANK_MAX];
|
695
|
+
ca_size_t idx0[CA_RANK_MAX];
|
693
696
|
ca_shift_sync_loop(ca, (int16_t) 0, idx, idx0);
|
694
697
|
}
|
695
698
|
|
696
699
|
static void
|
697
700
|
ca_shift_fill_loop (CAShift *ca, char *ptr,
|
698
|
-
int16_t level,
|
701
|
+
int16_t level, ca_size_t *idx0)
|
699
702
|
{
|
700
|
-
|
701
|
-
|
703
|
+
ca_size_t dim = ca->dim[level];
|
704
|
+
ca_size_t shift = ca->shift[level];
|
702
705
|
int8_t roll = ca->roll[level];
|
703
|
-
|
706
|
+
ca_size_t i;
|
704
707
|
|
705
708
|
if ( level == ca->rank - 1 ) {
|
706
709
|
if ( ( ! shift ) || roll ) {
|
@@ -783,7 +786,7 @@ ca_shift_fill_loop (CAShift *ca, char *ptr,
|
|
783
786
|
static void
|
784
787
|
ca_shift_fill (CAShift *ca, char *ptr)
|
785
788
|
{
|
786
|
-
|
789
|
+
ca_size_t idx0[CA_RANK_MAX];
|
787
790
|
ca_shift_fill_loop(ca, ptr, (int16_t) 0, idx0);
|
788
791
|
}
|
789
792
|
|
@@ -811,7 +814,7 @@ rb_ca_shift_set_fill_value (VALUE self, VALUE rfval)
|
|
811
814
|
*/
|
812
815
|
|
813
816
|
VALUE
|
814
|
-
rb_ca_shift_new (VALUE cary,
|
817
|
+
rb_ca_shift_new (VALUE cary, ca_size_t *shift, char *fill, int8_t *roll)
|
815
818
|
{
|
816
819
|
volatile VALUE obj;
|
817
820
|
CArray *parent;
|
@@ -838,10 +841,10 @@ rb_ca_shift (int argc, VALUE *argv, VALUE self)
|
|
838
841
|
volatile VALUE obj, ropt, rfval = CA_NIL, rroll = Qnil, rcs;
|
839
842
|
CArray *ca;
|
840
843
|
CScalar *cs;
|
841
|
-
|
844
|
+
ca_size_t shift[CA_RANK_MAX];
|
842
845
|
int8_t roll[CA_RANK_MAX];
|
843
846
|
char *fill = NULL;
|
844
|
-
|
847
|
+
int8_t i;
|
845
848
|
|
846
849
|
Data_Get_Struct(self, CArray, ca);
|
847
850
|
|
@@ -853,7 +856,7 @@ rb_ca_shift (int argc, VALUE *argv, VALUE self)
|
|
853
856
|
}
|
854
857
|
|
855
858
|
for (i=0; i<ca->rank; i++) {
|
856
|
-
shift[i] =
|
859
|
+
shift[i] = NUM2SIZE(argv[i]);
|
857
860
|
}
|
858
861
|
|
859
862
|
if ( rfval == CA_NIL ) {
|
@@ -870,7 +873,7 @@ rb_ca_shift (int argc, VALUE *argv, VALUE self)
|
|
870
873
|
Data_Get_Struct(rcs, CScalar, cs);
|
871
874
|
fill = cs->ptr;
|
872
875
|
if ( ca_is_object_type(ca) ) {
|
873
|
-
*(VALUE *)fill =
|
876
|
+
*(VALUE *)fill = INT2NUM(0);
|
874
877
|
}
|
875
878
|
else {
|
876
879
|
memset(fill, 0, cs->bytes);
|
data/ca_obj_transpose.c
CHANGED
@@ -17,17 +17,17 @@ typedef struct {
|
|
17
17
|
int8_t data_type;
|
18
18
|
int8_t rank;
|
19
19
|
int32_t flags;
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
ca_size_t bytes;
|
21
|
+
ca_size_t elements;
|
22
|
+
ca_size_t *dim;
|
23
23
|
char *ptr;
|
24
24
|
CArray *mask;
|
25
25
|
CArray *parent;
|
26
26
|
uint32_t attach;
|
27
27
|
uint8_t nosync;
|
28
28
|
/* -------------*/
|
29
|
-
|
30
|
-
|
29
|
+
ca_size_t *imap;
|
30
|
+
ca_size_t step;
|
31
31
|
} CATrans;
|
32
32
|
|
33
33
|
static int8_t CA_OBJ_TRANSPOSE;
|
@@ -42,14 +42,15 @@ static VALUE rb_cCATrans;
|
|
42
42
|
/* ------------------------------------------------------------------- */
|
43
43
|
|
44
44
|
int
|
45
|
-
ca_trans_setup (CATrans *ca, CArray *parent,
|
45
|
+
ca_trans_setup (CATrans *ca, CArray *parent, ca_size_t *imap)
|
46
46
|
{
|
47
47
|
int8_t data_type, rank;
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
ca_size_t bytes, elements;
|
49
|
+
ca_size_t *dim0;
|
50
|
+
ca_size_t newdim[CA_RANK_MAX];
|
51
|
+
ca_size_t map[CA_RANK_MAX];
|
52
|
+
int8_t i;
|
53
|
+
ca_size_t idim, step;
|
53
54
|
|
54
55
|
data_type = parent->data_type;
|
55
56
|
bytes = parent->bytes;
|
@@ -89,16 +90,16 @@ ca_trans_setup (CATrans *ca, CArray *parent, int32_t *imap)
|
|
89
90
|
ca->elements = elements;
|
90
91
|
ca->ptr = NULL;
|
91
92
|
ca->mask = NULL;
|
92
|
-
ca->dim = ALLOC_N(
|
93
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
93
94
|
|
94
95
|
ca->parent = parent;
|
95
96
|
ca->attach = 0;
|
96
97
|
ca->nosync = 0;
|
97
|
-
ca->imap = ALLOC_N(
|
98
|
+
ca->imap = ALLOC_N(ca_size_t, rank);
|
98
99
|
ca->step = step;
|
99
100
|
|
100
|
-
memcpy(ca->dim, newdim, rank * sizeof(
|
101
|
-
memcpy(ca->imap, imap, rank * sizeof(
|
101
|
+
memcpy(ca->dim, newdim, rank * sizeof(ca_size_t));
|
102
|
+
memcpy(ca->imap, imap, rank * sizeof(ca_size_t));
|
102
103
|
|
103
104
|
if ( ca_has_mask(parent) ) {
|
104
105
|
ca_create_mask(ca);
|
@@ -108,7 +109,7 @@ ca_trans_setup (CATrans *ca, CArray *parent, int32_t *imap)
|
|
108
109
|
}
|
109
110
|
|
110
111
|
CATrans *
|
111
|
-
ca_trans_new (CArray *parent,
|
112
|
+
ca_trans_new (CArray *parent, ca_size_t *imap)
|
112
113
|
{
|
113
114
|
CATrans *ca = ALLOC(CATrans);
|
114
115
|
ca_trans_setup(ca, parent, imap);
|
@@ -142,30 +143,30 @@ ca_trans_func_clone (void *ap)
|
|
142
143
|
}
|
143
144
|
|
144
145
|
static char *
|
145
|
-
ca_trans_func_ptr_at_addr (void *ap,
|
146
|
+
ca_trans_func_ptr_at_addr (void *ap, ca_size_t addr)
|
146
147
|
{
|
147
148
|
CATrans *ca = (CATrans *) ap;
|
148
149
|
if ( ca->ptr ) {
|
149
150
|
return ca->ptr + ca->bytes * addr;
|
150
151
|
}
|
151
152
|
else {
|
152
|
-
|
153
|
+
ca_size_t idx[CA_RANK_MAX];
|
153
154
|
ca_addr2index((CArray *)ca, addr, idx);
|
154
155
|
return ca_ptr_at_index(ca, idx);
|
155
156
|
}
|
156
157
|
}
|
157
158
|
|
158
159
|
static char *
|
159
|
-
ca_trans_func_ptr_at_index (void *ap,
|
160
|
+
ca_trans_func_ptr_at_index (void *ap, ca_size_t *idx)
|
160
161
|
{
|
161
162
|
CATrans *ca = (CATrans *) ap;
|
162
163
|
if ( ca->ptr ) {
|
163
164
|
return ca_array_func_ptr_at_index(ca, idx);
|
164
165
|
}
|
165
166
|
else {
|
166
|
-
|
167
|
-
|
168
|
-
|
167
|
+
ca_size_t *imap = ca->imap;
|
168
|
+
ca_size_t idx0[CA_RANK_MAX];
|
169
|
+
int8_t i;
|
169
170
|
for (i=0; i<ca->rank; i++) {
|
170
171
|
idx0[imap[i]] = idx[i];
|
171
172
|
}
|
@@ -174,12 +175,12 @@ ca_trans_func_ptr_at_index (void *ap, int32_t *idx)
|
|
174
175
|
}
|
175
176
|
|
176
177
|
static void
|
177
|
-
ca_trans_func_fetch_index (void *ap,
|
178
|
+
ca_trans_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
178
179
|
{
|
179
180
|
CATrans *ca = (CATrans *) ap;
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
ca_size_t *imap = ca->imap;
|
182
|
+
ca_size_t idx0[CA_RANK_MAX];
|
183
|
+
int8_t i;
|
183
184
|
for (i=0; i<ca->rank; i++) {
|
184
185
|
idx0[imap[i]] = idx[i];
|
185
186
|
}
|
@@ -187,12 +188,12 @@ ca_trans_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
187
188
|
}
|
188
189
|
|
189
190
|
static void
|
190
|
-
ca_trans_func_store_index (void *ap,
|
191
|
+
ca_trans_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
191
192
|
{
|
192
193
|
CATrans *ca = (CATrans *) ap;
|
193
|
-
|
194
|
-
|
195
|
-
|
194
|
+
ca_size_t *imap = ca->imap;
|
195
|
+
ca_size_t idx0[CA_RANK_MAX];
|
196
|
+
int8_t i;
|
196
197
|
for (i=0; i<ca->rank; i++) {
|
197
198
|
idx0[imap[i]] = idx[i];
|
198
199
|
}
|
@@ -303,12 +304,12 @@ ca_operation_function_t ca_trans_func = {
|
|
303
304
|
/* ------------------------------------------------------------------- */
|
304
305
|
|
305
306
|
static void
|
306
|
-
ca_trans_attach_loop (CATrans *ca, int8_t level,
|
307
|
+
ca_trans_attach_loop (CATrans *ca, int8_t level, ca_size_t *idx, ca_size_t *idx0)
|
307
308
|
{
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
309
|
+
ca_size_t step = ca->step;
|
310
|
+
ca_size_t dim = ca->dim[level];
|
311
|
+
ca_size_t *imap = ca->imap;
|
312
|
+
ca_size_t i;
|
312
313
|
|
313
314
|
if ( level == ca->rank - 1 ) {
|
314
315
|
idx[level] = 0;
|
@@ -378,18 +379,18 @@ ca_trans_attach_loop (CATrans *ca, int8_t level, int32_t *idx, int32_t *idx0)
|
|
378
379
|
static void
|
379
380
|
ca_trans_attach (CATrans *ca)
|
380
381
|
{
|
381
|
-
|
382
|
-
|
382
|
+
ca_size_t idx[CA_RANK_MAX];
|
383
|
+
ca_size_t idx0[CA_RANK_MAX];
|
383
384
|
ca_trans_attach_loop(ca, 0, idx, idx0);
|
384
385
|
}
|
385
386
|
|
386
387
|
static void
|
387
|
-
ca_trans_sync_loop (CATrans *ca, int8_t level,
|
388
|
+
ca_trans_sync_loop (CATrans *ca, int8_t level, ca_size_t *idx, ca_size_t *idx0)
|
388
389
|
{
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
390
|
+
ca_size_t step = ca->step;
|
391
|
+
ca_size_t dim = ca->dim[level];
|
392
|
+
ca_size_t *imap = ca->imap;
|
393
|
+
ca_size_t i;
|
393
394
|
|
394
395
|
if ( level == ca->rank - 1 ) {
|
395
396
|
idx[level] = 0;
|
@@ -459,18 +460,18 @@ ca_trans_sync_loop (CATrans *ca, int8_t level, int32_t *idx, int32_t *idx0)
|
|
459
460
|
static void
|
460
461
|
ca_trans_sync (CATrans *ca)
|
461
462
|
{
|
462
|
-
|
463
|
-
|
463
|
+
ca_size_t idx[CA_RANK_MAX];
|
464
|
+
ca_size_t idx0[CA_RANK_MAX];
|
464
465
|
ca_trans_sync_loop(ca, 0, idx, idx0);
|
465
466
|
}
|
466
467
|
|
467
468
|
/*
|
468
469
|
static void
|
469
470
|
ca_trans_fill_loop (CATrans *ca, char *ptr,
|
470
|
-
int8_t level,
|
471
|
+
int8_t level, ca_size_t *idx0)
|
471
472
|
{
|
472
|
-
|
473
|
-
|
473
|
+
ca_size_t *imap = ca->imap;
|
474
|
+
ca_size_t i;
|
474
475
|
|
475
476
|
if ( level == ca->rank - 1 ) {
|
476
477
|
for (i=0; i<ca->dim[level]; i++) {
|
@@ -496,7 +497,7 @@ ca_trans_fill (CATrans *ca, char *ptr)
|
|
496
497
|
/* ------------------------------------------------------------------- */
|
497
498
|
|
498
499
|
VALUE
|
499
|
-
rb_ca_trans_new (VALUE cary,
|
500
|
+
rb_ca_trans_new (VALUE cary, ca_size_t *imap)
|
500
501
|
{
|
501
502
|
volatile VALUE obj;
|
502
503
|
CArray *parent;
|
@@ -522,8 +523,8 @@ rb_ca_trans (int argc, VALUE *argv, VALUE self)
|
|
522
523
|
{
|
523
524
|
volatile VALUE obj;
|
524
525
|
CArray *ca;
|
525
|
-
|
526
|
-
|
526
|
+
ca_size_t imap[CA_RANK_MAX];
|
527
|
+
int8_t i;
|
527
528
|
|
528
529
|
Data_Get_Struct(self, CArray, ca);
|
529
530
|
|
@@ -534,7 +535,7 @@ rb_ca_trans (int argc, VALUE *argv, VALUE self)
|
|
534
535
|
}
|
535
536
|
else if ( argc == ca->rank ) {
|
536
537
|
for (i=0; i<ca->rank; i++) {
|
537
|
-
imap[i] =
|
538
|
+
imap[i] = NUM2SIZE(argv[i]);
|
538
539
|
}
|
539
540
|
}
|
540
541
|
else {
|