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_mapping.c
CHANGED
@@ -23,9 +23,9 @@ typedef struct {
|
|
23
23
|
int8_t data_type;
|
24
24
|
int8_t rank;
|
25
25
|
int32_t flags;
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
ca_size_t bytes;
|
27
|
+
ca_size_t elements;
|
28
|
+
ca_size_t *dim;
|
29
29
|
char *ptr;
|
30
30
|
CArray *mask;
|
31
31
|
CArray *parent;
|
@@ -50,11 +50,11 @@ int
|
|
50
50
|
ca_mapping_setup (CAMapping *ca, CArray *parent, CArray *mapper, int share)
|
51
51
|
{
|
52
52
|
int8_t rank, data_type;
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
ca_size_t elements, bytes;
|
54
|
+
ca_size_t *p;
|
55
|
+
ca_size_t i;
|
56
56
|
|
57
|
-
ca_check_type(mapper,
|
57
|
+
ca_check_type(mapper, CA_SIZE);
|
58
58
|
|
59
59
|
data_type = parent->data_type;
|
60
60
|
bytes = parent->bytes;
|
@@ -72,13 +72,13 @@ ca_mapping_setup (CAMapping *ca, CArray *parent, CArray *mapper, int share)
|
|
72
72
|
ca->rank = rank;
|
73
73
|
ca->elements = elements;
|
74
74
|
ca->mask = NULL;
|
75
|
-
ca->dim = ALLOC_N(
|
75
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
76
76
|
|
77
77
|
ca->parent = parent;
|
78
78
|
ca->attach = 0;
|
79
79
|
ca->nosync = 0;
|
80
80
|
|
81
|
-
memcpy(ca->dim, mapper->dim, rank * sizeof(
|
81
|
+
memcpy(ca->dim, mapper->dim, rank * sizeof(ca_size_t));
|
82
82
|
|
83
83
|
if ( share ) {
|
84
84
|
ca_set_flag(ca, CA_FLAG_SHARE_INDEX);
|
@@ -97,7 +97,7 @@ ca_mapping_setup (CAMapping *ca, CArray *parent, CArray *mapper, int share)
|
|
97
97
|
ca_create_mask(ca);
|
98
98
|
}
|
99
99
|
|
100
|
-
p = (
|
100
|
+
p = (ca_size_t*)ca->mapper->ptr;
|
101
101
|
for (i=0; i<ca->elements; i++) {
|
102
102
|
CA_CHECK_INDEX(*p, parent->elements);
|
103
103
|
p++;
|
@@ -154,11 +154,11 @@ ca_mapping_func_clone (void *ap)
|
|
154
154
|
}
|
155
155
|
|
156
156
|
static char *
|
157
|
-
ca_mapping_func_ptr_at_addr (void *ap,
|
157
|
+
ca_mapping_func_ptr_at_addr (void *ap, ca_size_t addr)
|
158
158
|
{
|
159
159
|
CAMapping *ca = (CAMapping *) ap;
|
160
160
|
if ( ! ca->ptr ) {
|
161
|
-
|
161
|
+
ca_size_t idx[CA_RANK_MAX];
|
162
162
|
ca_addr2index((CArray *)ca, addr, idx);
|
163
163
|
return ca_ptr_at_index(ca, idx);
|
164
164
|
}
|
@@ -168,17 +168,18 @@ ca_mapping_func_ptr_at_addr (void *ap, int32_t addr)
|
|
168
168
|
}
|
169
169
|
|
170
170
|
static char *
|
171
|
-
ca_mapping_func_ptr_at_index (void *ap,
|
171
|
+
ca_mapping_func_ptr_at_index (void *ap, ca_size_t *idx)
|
172
172
|
{
|
173
173
|
CAMapping *ca = (CAMapping *) ap;
|
174
174
|
if ( ! ca->ptr ) {
|
175
|
-
|
176
|
-
|
175
|
+
ca_size_t *dim = ca->dim;
|
176
|
+
int8_t i;
|
177
|
+
ca_size_t n;
|
177
178
|
n = idx[0];
|
178
179
|
for (i=1; i<ca->rank; i++) {
|
179
180
|
n = dim[i]*n+idx[i];
|
180
181
|
}
|
181
|
-
n = *(
|
182
|
+
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
182
183
|
if ( ca->parent->ptr == NULL ) {
|
183
184
|
return ca_ptr_at_addr(ca->parent, n);
|
184
185
|
}
|
@@ -192,30 +193,32 @@ ca_mapping_func_ptr_at_index (void *ap, int32_t *idx)
|
|
192
193
|
}
|
193
194
|
|
194
195
|
static void
|
195
|
-
ca_mapping_func_fetch_index (void *ap,
|
196
|
+
ca_mapping_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
196
197
|
{
|
197
198
|
CAMapping *ca = (CAMapping *) ap;
|
198
|
-
|
199
|
-
|
199
|
+
ca_size_t *dim = ca->dim;
|
200
|
+
int8_t i;
|
201
|
+
ca_size_t n;
|
200
202
|
n = idx[0];
|
201
203
|
for (i=1; i<ca->rank; i++) {
|
202
204
|
n = dim[i]*n+idx[i];
|
203
205
|
}
|
204
|
-
n = *(
|
206
|
+
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
205
207
|
ca_fetch_addr(ca->parent, n, ptr);
|
206
208
|
}
|
207
209
|
|
208
210
|
static void
|
209
|
-
ca_mapping_func_store_index (void *ap,
|
211
|
+
ca_mapping_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
210
212
|
{
|
211
213
|
CAMapping *ca = (CAMapping *) ap;
|
212
|
-
|
213
|
-
|
214
|
+
ca_size_t *dim = ca->dim;
|
215
|
+
int8_t i;
|
216
|
+
ca_size_t n;
|
214
217
|
n = idx[0];
|
215
218
|
for (i=1; i<ca->rank; i++) {
|
216
219
|
n = dim[i]*n+idx[i];
|
217
220
|
}
|
218
|
-
n = *(
|
221
|
+
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
219
222
|
ca_store_addr(ca->parent, n, ptr);
|
220
223
|
}
|
221
224
|
|
@@ -331,8 +334,8 @@ ca_operation_function_t ca_mapping_func = {
|
|
331
334
|
static void
|
332
335
|
ca_mapping_attach (CAMapping *ca)
|
333
336
|
{
|
334
|
-
|
335
|
-
|
337
|
+
ca_size_t *ip = (ca_size_t*) ca_ptr_at_addr(ca->mapper, 0);
|
338
|
+
ca_size_t i;
|
336
339
|
|
337
340
|
#define proc_mapping_attach(type) \
|
338
341
|
{ \
|
@@ -409,8 +412,8 @@ ca_mapping_attach (CAMapping *ca)
|
|
409
412
|
static void
|
410
413
|
ca_mapping_sync (CAMapping *ca)
|
411
414
|
{
|
412
|
-
|
413
|
-
|
415
|
+
ca_size_t *ip = (ca_size_t*) ca_ptr_at_addr(ca->mapper, 0);
|
416
|
+
ca_size_t i;
|
414
417
|
|
415
418
|
switch ( ca->bytes ) {
|
416
419
|
case 1:
|
@@ -478,8 +481,8 @@ ca_mapping_sync (CAMapping *ca)
|
|
478
481
|
static void
|
479
482
|
ca_mapping_fill (CAMapping *ca, char *ptr)
|
480
483
|
{
|
481
|
-
|
482
|
-
|
484
|
+
ca_size_t *ip = (ca_size_t*) ca_ptr_at_addr(ca->mapper, 0);
|
485
|
+
ca_size_t i;
|
483
486
|
|
484
487
|
switch ( ca->bytes ) {
|
485
488
|
case 1:
|
@@ -569,10 +572,10 @@ rb_ca_mapping (int argc, VALUE *argv, VALUE self)
|
|
569
572
|
CArray *mapper;
|
570
573
|
Data_Get_Struct(self, CArray, ca);
|
571
574
|
|
572
|
-
rb_scan_args(argc, argv, "1", &rmapper);
|
575
|
+
rb_scan_args(argc, argv, "1", (VALUE *) &rmapper);
|
573
576
|
rb_check_carray_object(rmapper);
|
574
577
|
|
575
|
-
mapper = ca_wrap_readonly(rmapper,
|
578
|
+
mapper = ca_wrap_readonly(rmapper, CA_SIZE);
|
576
579
|
|
577
580
|
obj = rb_ca_mapping_new(self, mapper);
|
578
581
|
|
data/ca_obj_object.c
CHANGED
@@ -59,7 +59,7 @@ static VALUE rb_cCAObjectMask;
|
|
59
59
|
|
60
60
|
|
61
61
|
static CAObjectMask *
|
62
|
-
ca_objmask_new (VALUE array, int8_t rank,
|
62
|
+
ca_objmask_new (VALUE array, int8_t rank, ca_size_t *dim)
|
63
63
|
{
|
64
64
|
CAObjectMask *ca = ALLOC(CAObjectMask);
|
65
65
|
ca_wrap_setup_null((CArray *)ca, CA_BOOLEAN, rank, dim, 0, NULL);
|
@@ -85,24 +85,24 @@ ca_objmask_func_clone (void *ap)
|
|
85
85
|
}
|
86
86
|
|
87
87
|
void
|
88
|
-
ca_objmask_func_fetch_addr (void *ap,
|
88
|
+
ca_objmask_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
89
89
|
{
|
90
90
|
CAObjectMask *ca = (CAObjectMask *) ap;
|
91
91
|
volatile VALUE ridx, raddr, rval;
|
92
92
|
int i;
|
93
93
|
|
94
94
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_addr"), Qtrue) ) {
|
95
|
-
raddr =
|
95
|
+
raddr = SIZE2NUM(addr);
|
96
96
|
rval = rb_funcall(ca->array, rb_intern("mask_fetch_addr"), 1, raddr);
|
97
97
|
*(uint8_t*) ptr = NUM2INT(rval) == 0 ? 0 : 1;
|
98
98
|
ca_array_func_store_addr(ca, addr, ptr);
|
99
99
|
}
|
100
100
|
else if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_index"), Qtrue) ) {
|
101
|
-
|
101
|
+
ca_size_t idx[CA_RANK_MAX];
|
102
102
|
ca_addr2index(ca, addr, idx);
|
103
103
|
ridx = rb_ary_new2(ca->rank);
|
104
104
|
for (i=0; i<ca->rank; i++) {
|
105
|
-
rb_ary_store(ridx, i,
|
105
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
106
106
|
}
|
107
107
|
rval = rb_funcall(ca->array, rb_intern("mask_fetch_index"), 1, ridx);
|
108
108
|
*(uint8_t*) ptr = NUM2INT(rval) == 0 ? 0 : 1;
|
@@ -114,7 +114,7 @@ ca_objmask_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
114
114
|
}
|
115
115
|
|
116
116
|
void
|
117
|
-
ca_objmask_func_fetch_index (void *ap,
|
117
|
+
ca_objmask_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
118
118
|
{
|
119
119
|
CAObjectMask *ca = (CAObjectMask *) ap;
|
120
120
|
volatile VALUE ridx, raddr, rval;
|
@@ -123,15 +123,15 @@ ca_objmask_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
123
123
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_index"), Qtrue) ) {
|
124
124
|
ridx = rb_ary_new2(ca->rank);
|
125
125
|
for (i=0; i<ca->rank; i++) {
|
126
|
-
rb_ary_store(ridx, i,
|
126
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
127
127
|
}
|
128
128
|
rval = rb_funcall(ca->array, rb_intern("mask_fetch_index"), 1, ridx);
|
129
129
|
*(uint8_t*) ptr = NUM2INT(rval) == 0 ? 0 : 1;
|
130
130
|
ca_array_func_store_index(ca, idx, ptr);
|
131
131
|
}
|
132
132
|
else if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_addr"), Qtrue) ) {
|
133
|
-
|
134
|
-
raddr =
|
133
|
+
ca_size_t addr = ca_index2addr(ca, idx);
|
134
|
+
raddr = SIZE2NUM(addr);
|
135
135
|
rval = rb_funcall(ca->array, rb_intern("mask_fetch_addr"), 1, raddr);
|
136
136
|
*(uint8_t*) ptr = NUM2INT(rval) == 0 ? 0 : 1;
|
137
137
|
ca_array_func_store_addr(ca, addr, ptr);
|
@@ -143,49 +143,49 @@ ca_objmask_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
143
143
|
|
144
144
|
|
145
145
|
void
|
146
|
-
ca_objmask_func_store_addr (void *ap,
|
146
|
+
ca_objmask_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
147
147
|
{
|
148
148
|
CAObjectMask *ca = (CAObjectMask *) ap;
|
149
149
|
volatile VALUE ridx, raddr, rval;
|
150
150
|
int i;
|
151
151
|
|
152
152
|
ca_array_func_store_addr(ca, addr, ptr);
|
153
|
-
rval =
|
153
|
+
rval = INT2NUM( *(uint8_t*)ptr );
|
154
154
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_addr"), Qtrue) ) {
|
155
|
-
raddr =
|
155
|
+
raddr = SIZE2NUM(addr);
|
156
156
|
rb_funcall(ca->array, rb_intern("mask_store_addr"), 2, raddr, rval);
|
157
157
|
}
|
158
158
|
else if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_index"), Qtrue) ) {
|
159
|
-
|
159
|
+
ca_size_t idx[CA_RANK_MAX];
|
160
160
|
ca_addr2index(ca, addr, idx);
|
161
161
|
ridx = rb_ary_new2(ca->rank);
|
162
162
|
for (i=0; i<ca->rank; i++) {
|
163
|
-
rb_ary_store(ridx, i,
|
163
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
164
164
|
}
|
165
165
|
rb_funcall(ca->array, rb_intern("mask_store_index"), 2, ridx, rval);
|
166
166
|
}
|
167
167
|
}
|
168
168
|
|
169
169
|
void
|
170
|
-
ca_objmask_func_store_index (void *ap,
|
170
|
+
ca_objmask_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
171
171
|
{
|
172
172
|
CAObjectMask *ca = (CAObjectMask *) ap;
|
173
173
|
volatile VALUE ridx, raddr, rval;
|
174
174
|
int i;
|
175
175
|
|
176
176
|
ca_array_func_store_index(ca, idx, ptr);
|
177
|
-
rval =
|
177
|
+
rval = INT2NUM( *(uint8_t*)ptr );
|
178
178
|
|
179
179
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_index"), Qtrue) ) {
|
180
180
|
ridx = rb_ary_new2(ca->rank);
|
181
181
|
for (i=0; i<ca->rank; i++) {
|
182
|
-
rb_ary_store(ridx, i,
|
182
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
183
183
|
}
|
184
184
|
rb_funcall(ca->array, rb_intern("mask_store_index"), 2, ridx, rval);
|
185
185
|
}
|
186
186
|
else if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_addr"), Qtrue) ) {
|
187
|
-
|
188
|
-
raddr =
|
187
|
+
ca_size_t addr = ca_index2addr(ca, idx);
|
188
|
+
raddr = SIZE2NUM(addr);
|
189
189
|
rb_funcall(ca->array, rb_intern("mask_store_addr"), 2, raddr, rval);
|
190
190
|
}
|
191
191
|
|
@@ -250,7 +250,7 @@ ca_objmask_func_fill_data (void *ap, void *val)
|
|
250
250
|
ca_array_func_fill_data(ca, val);
|
251
251
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_fill_data"), Qtrue) ) {
|
252
252
|
rb_funcall(ca->array, rb_intern("mask_fill_data"),
|
253
|
-
1,
|
253
|
+
1, INT2NUM(*(uint8_t*)val));
|
254
254
|
}
|
255
255
|
}
|
256
256
|
|
@@ -301,11 +301,11 @@ rb_ca_objmask_initialize_copy (VALUE self, VALUE other)
|
|
301
301
|
|
302
302
|
static int
|
303
303
|
ca_object_setup (CAObject *ca,
|
304
|
-
int8_t data_type, int8_t rank,
|
304
|
+
int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes)
|
305
305
|
{
|
306
|
-
|
306
|
+
ca_size_t elements;
|
307
307
|
double length;
|
308
|
-
|
308
|
+
int8_t i;
|
309
309
|
|
310
310
|
/* check arguments */
|
311
311
|
|
@@ -339,17 +339,17 @@ ca_object_setup (CAObject *ca,
|
|
339
339
|
ca->attach = 0;
|
340
340
|
ca->nosync = 0;
|
341
341
|
|
342
|
-
ca->dim = ALLOC_N(
|
342
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
343
343
|
|
344
344
|
ca->data = ca_wrap_new_null(data_type, rank, dim, bytes, NULL);
|
345
345
|
|
346
|
-
memcpy(ca->dim, dim, rank * sizeof(
|
346
|
+
memcpy(ca->dim, dim, rank * sizeof(ca_size_t));
|
347
347
|
|
348
348
|
return 0;
|
349
349
|
}
|
350
350
|
|
351
351
|
static CAObject *
|
352
|
-
ca_object_new (int8_t data_type, int8_t rank,
|
352
|
+
ca_object_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes)
|
353
353
|
{
|
354
354
|
CAObject *ca = ALLOC(CAObject);
|
355
355
|
ca_object_setup(ca, data_type, rank, dim, bytes);
|
@@ -380,13 +380,13 @@ ca_object_func_clone (void *ap)
|
|
380
380
|
#define ca_object_func_ptr_at_index ca_array_func_ptr_at_index
|
381
381
|
|
382
382
|
static void
|
383
|
-
ca_object_func_fetch_addr (void *ap,
|
383
|
+
ca_object_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
384
384
|
{
|
385
385
|
CAObject *ca = (CAObject *) ap;
|
386
386
|
volatile VALUE ridx, raddr, rval;
|
387
387
|
int i;
|
388
388
|
if ( rb_obj_respond_to(ca->self, rb_intern("fetch_addr"), Qtrue) ) {
|
389
|
-
raddr =
|
389
|
+
raddr = SIZE2NUM(addr);
|
390
390
|
rval = rb_funcall(ca->self, rb_intern("fetch_addr"), 1, raddr);
|
391
391
|
if ( rval == CA_UNDEF ) {
|
392
392
|
ca_update_mask(ca);
|
@@ -395,7 +395,7 @@ ca_object_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
395
395
|
}
|
396
396
|
*(boolean8_t*)ca_ptr_at_addr(ca->mask, addr) = 1;
|
397
397
|
if ( ca->data_type == CA_OBJECT ) {
|
398
|
-
rb_ca_obj2ptr(ca->self,
|
398
|
+
rb_ca_obj2ptr(ca->self, INT2NUM(0), ptr);
|
399
399
|
}
|
400
400
|
}
|
401
401
|
else {
|
@@ -406,11 +406,11 @@ ca_object_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
406
406
|
}
|
407
407
|
}
|
408
408
|
else {
|
409
|
-
|
409
|
+
ca_size_t idx[CA_RANK_MAX];
|
410
410
|
ca_addr2index(ca, addr, idx);
|
411
411
|
ridx = rb_ary_new2(ca->rank);
|
412
412
|
for (i=0; i<ca->rank; i++) {
|
413
|
-
rb_ary_store(ridx, i,
|
413
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
414
414
|
}
|
415
415
|
rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
|
416
416
|
if ( rval == CA_UNDEF ) {
|
@@ -420,7 +420,7 @@ ca_object_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
420
420
|
}
|
421
421
|
*(boolean8_t*)ca_ptr_at_index(ca->mask, idx) = 1;
|
422
422
|
if ( ca->data_type == CA_OBJECT ) {
|
423
|
-
rb_ca_obj2ptr(ca->self,
|
423
|
+
rb_ca_obj2ptr(ca->self, INT2NUM(0), ptr);
|
424
424
|
}
|
425
425
|
}
|
426
426
|
else {
|
@@ -433,7 +433,7 @@ ca_object_func_fetch_addr (void *ap, int32_t addr, void *ptr)
|
|
433
433
|
}
|
434
434
|
|
435
435
|
static void
|
436
|
-
ca_object_func_fetch_index (void *ap,
|
436
|
+
ca_object_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
437
437
|
{
|
438
438
|
CAObject *ca = (CAObject *) ap;
|
439
439
|
volatile VALUE ridx, raddr, rval;
|
@@ -441,7 +441,7 @@ ca_object_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
441
441
|
if ( rb_obj_respond_to(ca->self, rb_intern("fetch_index"), Qtrue) ) {
|
442
442
|
ridx = rb_ary_new2(ca->rank);
|
443
443
|
for (i=0; i<ca->rank; i++) {
|
444
|
-
rb_ary_store(ridx, i,
|
444
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
445
445
|
}
|
446
446
|
rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
|
447
447
|
if ( rval == CA_UNDEF ) {
|
@@ -451,7 +451,7 @@ ca_object_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
451
451
|
}
|
452
452
|
*(boolean8_t*)ca_ptr_at_index(ca->mask, idx) = 1;
|
453
453
|
if ( ca->data_type == CA_OBJECT ) {
|
454
|
-
rb_ca_obj2ptr(ca->self,
|
454
|
+
rb_ca_obj2ptr(ca->self, INT2NUM(0), ptr);
|
455
455
|
}
|
456
456
|
}
|
457
457
|
else {
|
@@ -462,8 +462,8 @@ ca_object_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
462
462
|
}
|
463
463
|
}
|
464
464
|
else {
|
465
|
-
|
466
|
-
raddr =
|
465
|
+
ca_size_t addr = ca_index2addr(ca, idx);
|
466
|
+
raddr = SIZE2NUM(addr);
|
467
467
|
rval = rb_funcall(ca->self, rb_intern("fetch_addr"), 1, raddr);
|
468
468
|
if ( rval == CA_UNDEF ) {
|
469
469
|
ca_update_mask(ca);
|
@@ -472,7 +472,7 @@ ca_object_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
472
472
|
}
|
473
473
|
*(boolean8_t*)ca_ptr_at_addr(ca->mask, addr) = 1;
|
474
474
|
if ( ca->data_type == CA_OBJECT ) {
|
475
|
-
rb_ca_obj2ptr(ca->self,
|
475
|
+
rb_ca_obj2ptr(ca->self, INT2NUM(0), ptr);
|
476
476
|
}
|
477
477
|
}
|
478
478
|
else {
|
@@ -485,22 +485,22 @@ ca_object_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
485
485
|
}
|
486
486
|
|
487
487
|
static void
|
488
|
-
ca_object_func_store_addr (void *ap,
|
488
|
+
ca_object_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
489
489
|
{
|
490
490
|
CAObject *ca = (CAObject *) ap;
|
491
491
|
volatile VALUE ridx, raddr, rval;
|
492
492
|
int i;
|
493
493
|
if ( rb_obj_respond_to(ca->self, rb_intern("store_addr"), Qtrue) ) {
|
494
|
-
raddr =
|
494
|
+
raddr = SIZE2NUM(addr);
|
495
495
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
496
496
|
rb_funcall(ca->self, rb_intern("store_addr"), 2, raddr, rval);
|
497
497
|
}
|
498
498
|
else {
|
499
|
-
|
499
|
+
ca_size_t idx[CA_RANK_MAX];
|
500
500
|
ca_addr2index(ca, addr, idx);
|
501
501
|
ridx = rb_ary_new2(ca->rank);
|
502
502
|
for (i=0; i<ca->rank; i++) {
|
503
|
-
rb_ary_store(ridx, i,
|
503
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
504
504
|
}
|
505
505
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
506
506
|
rb_funcall(ca->self, rb_intern("store_index"), 2, ridx, rval);
|
@@ -508,7 +508,7 @@ ca_object_func_store_addr (void *ap, int32_t addr, void *ptr)
|
|
508
508
|
}
|
509
509
|
|
510
510
|
static void
|
511
|
-
ca_object_func_store_index (void *ap,
|
511
|
+
ca_object_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
512
512
|
{
|
513
513
|
CAObject *ca = (CAObject *) ap;
|
514
514
|
volatile VALUE ridx, raddr, rval;
|
@@ -516,14 +516,14 @@ ca_object_func_store_index (void *ap, int32_t *idx, void *ptr)
|
|
516
516
|
if ( rb_obj_respond_to(ca->self, rb_intern("store_index"), Qtrue) ) {
|
517
517
|
ridx = rb_ary_new2(ca->rank);
|
518
518
|
for (i=0; i<ca->rank; i++) {
|
519
|
-
rb_ary_store(ridx, i,
|
519
|
+
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
520
520
|
}
|
521
521
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
522
522
|
rb_funcall(ca->self, rb_intern("store_index"), 2, ridx, rval);
|
523
523
|
}
|
524
524
|
else {
|
525
|
-
|
526
|
-
raddr =
|
525
|
+
ca_size_t addr = ca_index2addr(ca, idx);
|
526
|
+
raddr = SIZE2NUM(addr);
|
527
527
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
528
528
|
rb_funcall(ca->self, rb_intern("store_addr"), 2, raddr, rval);
|
529
529
|
}
|
@@ -537,8 +537,8 @@ ca_object_func_allocate (void *ap)
|
|
537
537
|
ca->data->ptr = malloc_with_check(ca_length(ca));
|
538
538
|
if ( ca_is_object_type(ca->data) ) { /* GC safe */
|
539
539
|
VALUE *p = (VALUE *) ca->data->ptr;
|
540
|
-
VALUE zero =
|
541
|
-
|
540
|
+
VALUE zero = INT2NUM(0);
|
541
|
+
ca_size_t i;
|
542
542
|
for (i=0; i<ca->elements; i++) {
|
543
543
|
*p++ = zero;
|
544
544
|
}
|
@@ -555,8 +555,8 @@ ca_object_func_attach (void *ap)
|
|
555
555
|
ca->data->ptr = malloc_with_check(ca_length(ca));
|
556
556
|
if ( ca_is_object_type(ca->data) ) { /* GC safe */
|
557
557
|
VALUE *p = (VALUE *) ca->data->ptr;
|
558
|
-
VALUE zero =
|
559
|
-
|
558
|
+
VALUE zero = INT2NUM(0);
|
559
|
+
ca_size_t i;
|
560
560
|
for (i=0; i<ca->elements; i++) {
|
561
561
|
*p++ = zero;
|
562
562
|
}
|
@@ -704,11 +704,11 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
|
|
704
704
|
volatile VALUE rtype, rdim, ropt, rbytes = Qnil, rrdonly = Qnil, rparent = Qnil, rdata;
|
705
705
|
CAObject *ca;
|
706
706
|
int8_t data_type, rank;
|
707
|
-
|
708
|
-
|
707
|
+
ca_size_t dim[CA_RANK_MAX];
|
708
|
+
ca_size_t bytes;
|
709
709
|
int i;
|
710
710
|
|
711
|
-
rb_scan_args(argc, argv, "21", &rtype, &rdim, &ropt);
|
711
|
+
rb_scan_args(argc, argv, "21", (VALUE *) &rtype, (VALUE *) &rdim, (VALUE *) &ropt);
|
712
712
|
rb_scan_options(ropt, "bytes,read_only,parent",
|
713
713
|
&rbytes, &rrdonly, &rparent);
|
714
714
|
|
@@ -723,7 +723,7 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
|
|
723
723
|
|
724
724
|
rank = RARRAY_LEN(rdim);
|
725
725
|
for (i=0; i<rank; i++) {
|
726
|
-
dim[i] =
|
726
|
+
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
727
727
|
}
|
728
728
|
|
729
729
|
Data_Get_Struct(self, CAObject, ca);
|