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_unbound_repeat.c
CHANGED
@@ -21,10 +21,10 @@ VALUE rb_cCAUnboundRepeat;
|
|
21
21
|
|
22
22
|
int
|
23
23
|
ca_ubrep_setup (CAUnboundRepeat *ca, CArray *parent,
|
24
|
-
int32_t rep_rank,
|
24
|
+
int32_t rep_rank, ca_size_t *rep_dim)
|
25
25
|
{
|
26
26
|
int8_t data_type, rank;
|
27
|
-
|
27
|
+
ca_size_t bytes, elements;
|
28
28
|
|
29
29
|
/* check arguments */
|
30
30
|
|
@@ -43,17 +43,17 @@ ca_ubrep_setup (CAUnboundRepeat *ca, CArray *parent,
|
|
43
43
|
ca->elements = elements;
|
44
44
|
ca->ptr = NULL;
|
45
45
|
ca->mask = NULL;
|
46
|
-
ca->dim = ALLOC_N(
|
46
|
+
ca->dim = ALLOC_N(ca_size_t, rank);
|
47
47
|
|
48
48
|
ca->parent = parent;
|
49
49
|
ca->attach = 0;
|
50
50
|
ca->nosync = 0;
|
51
51
|
|
52
52
|
ca->rep_rank = rep_rank;
|
53
|
-
ca->rep_dim = ALLOC_N(
|
53
|
+
ca->rep_dim = ALLOC_N(ca_size_t, rep_rank);
|
54
54
|
|
55
|
-
memcpy(ca->dim, parent->dim, rank * sizeof(
|
56
|
-
memcpy(ca->rep_dim, rep_dim, rep_rank * sizeof(
|
55
|
+
memcpy(ca->dim, parent->dim, rank * sizeof(ca_size_t));
|
56
|
+
memcpy(ca->rep_dim, rep_dim, rep_rank * sizeof(ca_size_t));
|
57
57
|
|
58
58
|
if ( ca_has_mask(parent) ) {
|
59
59
|
ca_create_mask(ca);
|
@@ -63,7 +63,7 @@ ca_ubrep_setup (CAUnboundRepeat *ca, CArray *parent,
|
|
63
63
|
}
|
64
64
|
|
65
65
|
CAUnboundRepeat *
|
66
|
-
ca_ubrep_new (CArray *parent, int32_t rep_rank,
|
66
|
+
ca_ubrep_new (CArray *parent, int32_t rep_rank, ca_size_t *rep_dim)
|
67
67
|
{
|
68
68
|
CAUnboundRepeat *ca = ALLOC(CAUnboundRepeat);
|
69
69
|
ca_ubrep_setup(ca, parent, rep_rank, rep_dim);
|
@@ -92,42 +92,42 @@ ca_ubrep_func_clone (void *ap)
|
|
92
92
|
}
|
93
93
|
|
94
94
|
static char *
|
95
|
-
ca_ubrep_func_ptr_at_addr (void *ap,
|
95
|
+
ca_ubrep_func_ptr_at_addr (void *ap, ca_size_t addr)
|
96
96
|
{
|
97
97
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
98
98
|
return ca_ptr_at_addr(ca->parent, addr);
|
99
99
|
}
|
100
100
|
|
101
101
|
static char *
|
102
|
-
ca_ubrep_func_ptr_at_index (void *ap,
|
102
|
+
ca_ubrep_func_ptr_at_index (void *ap, ca_size_t *idx)
|
103
103
|
{
|
104
104
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
105
105
|
return ca_ptr_at_index(ca->parent, idx);
|
106
106
|
}
|
107
107
|
|
108
108
|
static void
|
109
|
-
ca_ubrep_func_fetch_addr (void *ap,
|
109
|
+
ca_ubrep_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
110
110
|
{
|
111
111
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
112
112
|
ca_fetch_addr(ca->parent, addr, ptr);
|
113
113
|
}
|
114
114
|
|
115
115
|
static void
|
116
|
-
ca_ubrep_func_fetch_index (void *ap,
|
116
|
+
ca_ubrep_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
117
117
|
{
|
118
118
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
119
119
|
ca_fetch_index(ca->parent, idx, ptr);
|
120
120
|
}
|
121
121
|
|
122
122
|
static void
|
123
|
-
ca_ubrep_func_store_addr (void *ap,
|
123
|
+
ca_ubrep_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
124
124
|
{
|
125
125
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
126
126
|
ca_store_addr(ca->parent, addr, ptr);
|
127
127
|
}
|
128
128
|
|
129
129
|
static void
|
130
|
-
ca_ubrep_func_store_index (void *ap,
|
130
|
+
ca_ubrep_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
131
131
|
{
|
132
132
|
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
133
133
|
ca_store_index(ca->parent, idx, ptr);
|
@@ -239,7 +239,7 @@ ca_operation_function_t ca_ubrep_func = {
|
|
239
239
|
/* ------------------------------------------------------------------- */
|
240
240
|
|
241
241
|
VALUE
|
242
|
-
rb_ca_ubrep_new (VALUE cary, int32_t rep_rank,
|
242
|
+
rb_ca_ubrep_new (VALUE cary, int32_t rep_rank, ca_size_t *rep_dim)
|
243
243
|
{
|
244
244
|
volatile VALUE obj;
|
245
245
|
CArray *parent;
|
@@ -257,9 +257,10 @@ VALUE
|
|
257
257
|
rb_ca_unbound_repeat (int argc, VALUE *argv, VALUE self)
|
258
258
|
{
|
259
259
|
CArray *ca;
|
260
|
-
|
261
|
-
int32_t rep_rank
|
262
|
-
|
260
|
+
ca_size_t rank, dim[CA_RANK_MAX];
|
261
|
+
int32_t rep_rank;
|
262
|
+
ca_size_t rep_dim[CA_RANK_MAX];
|
263
|
+
ca_size_t count, i;
|
263
264
|
|
264
265
|
Data_Get_Struct(self, CArray, ca);
|
265
266
|
|
@@ -298,7 +299,7 @@ rb_ca_unbound_repeat (int argc, VALUE *argv, VALUE self)
|
|
298
299
|
return self;
|
299
300
|
}
|
300
301
|
else {
|
301
|
-
return rb_ca_unbound_repeat(RARRAY_LEN(args), RARRAY_PTR(args), self);
|
302
|
+
return rb_ca_unbound_repeat((int)RARRAY_LEN(args), RARRAY_PTR(args), self);
|
302
303
|
}
|
303
304
|
}
|
304
305
|
else if ( argc == 2 &&
|
@@ -384,9 +385,9 @@ rb_ca_ubrep_initialize_copy (VALUE self, VALUE other)
|
|
384
385
|
|
385
386
|
/*
|
386
387
|
static CARepeat *
|
387
|
-
ca_ubrep_bind (CAUnboundRepeat *ca, int32_t new_rank,
|
388
|
+
ca_ubrep_bind (CAUnboundRepeat *ca, int32_t new_rank, ca_size_t *new_dim)
|
388
389
|
{
|
389
|
-
|
390
|
+
ca_size_t rep_spec[CA_RANK_MAX];
|
390
391
|
int i;
|
391
392
|
if ( ca->rep_rank != new_rank ) {
|
392
393
|
rb_raise(rb_eArgError, "invalid new_rank");
|
@@ -404,12 +405,12 @@ ca_ubrep_bind (CAUnboundRepeat *ca, int32_t new_rank, int32_t *new_dim)
|
|
404
405
|
*/
|
405
406
|
|
406
407
|
VALUE
|
407
|
-
ca_ubrep_bind2 (VALUE self, int32_t new_rank,
|
408
|
+
ca_ubrep_bind2 (VALUE self, int32_t new_rank, ca_size_t *new_dim)
|
408
409
|
{
|
409
410
|
CAUnboundRepeat *ca;
|
410
|
-
|
411
|
-
|
412
|
-
|
411
|
+
ca_size_t rep_spec[CA_RANK_MAX];
|
412
|
+
ca_size_t upr_spec[CA_RANK_MAX];
|
413
|
+
ca_size_t srp_spec[CA_RANK_MAX];
|
413
414
|
int uprep = 0, srp_rank;
|
414
415
|
int i;
|
415
416
|
|
@@ -494,7 +495,7 @@ static VALUE
|
|
494
495
|
rb_ca_ubrep_bind (int argc, VALUE *argv, VALUE self)
|
495
496
|
{
|
496
497
|
CAUnboundRepeat *ca;
|
497
|
-
|
498
|
+
ca_size_t rep_spec[CA_RANK_MAX];
|
498
499
|
int i;
|
499
500
|
|
500
501
|
Data_Get_Struct(self, CAUnboundRepeat, ca);
|
@@ -504,7 +505,7 @@ rb_ca_ubrep_bind (int argc, VALUE *argv, VALUE self)
|
|
504
505
|
}
|
505
506
|
for (i=0; i<argc; i++) {
|
506
507
|
if ( ca->rep_dim[i] == 0 ) {
|
507
|
-
rep_spec[i] =
|
508
|
+
rep_spec[i] = NUM2SIZE(argv[i]);
|
508
509
|
}
|
509
510
|
else {
|
510
511
|
rep_spec[i] = 0;
|
@@ -526,7 +527,7 @@ rb_ca_ubrep_spec (VALUE self)
|
|
526
527
|
spec = rb_ary_new2(ca->rep_rank);
|
527
528
|
for (i=0; i<ca->rep_rank; i++) {
|
528
529
|
if ( ca->rep_dim[i] ) {
|
529
|
-
rb_ary_store(spec, i,
|
530
|
+
rb_ary_store(spec, i, SIZE2NUM(ca->rep_dim[i]));
|
530
531
|
}
|
531
532
|
else {
|
532
533
|
rb_ary_store(spec, i, ID2SYM(rb_intern("*")));
|
data/ca_obj_window.c
CHANGED
@@ -27,11 +27,11 @@ int8_t CA_OBJ_WINDOW;
|
|
27
27
|
|
28
28
|
int
|
29
29
|
ca_window_setup (CAWindow *ca, CArray *parent,
|
30
|
-
|
30
|
+
ca_size_t *start, ca_size_t *count, int8_t bounds, char *fill)
|
31
31
|
{
|
32
32
|
int8_t data_type, rank;
|
33
|
-
|
34
|
-
|
33
|
+
ca_size_t *dim;
|
34
|
+
ca_size_t bytes, elements;
|
35
35
|
int i;
|
36
36
|
|
37
37
|
data_type = parent->data_type;
|
@@ -62,23 +62,23 @@ ca_window_setup (CAWindow *ca, CArray *parent,
|
|
62
62
|
ca->attach = 0;
|
63
63
|
ca->nosync = 0;
|
64
64
|
ca->bounds = bounds;
|
65
|
-
ca->start = ALLOC_N(
|
66
|
-
ca->count = ALLOC_N(
|
67
|
-
ca->size0 = ALLOC_N(
|
65
|
+
ca->start = ALLOC_N(ca_size_t, rank);
|
66
|
+
ca->count = ALLOC_N(ca_size_t, rank);
|
67
|
+
ca->size0 = ALLOC_N(ca_size_t, rank);
|
68
68
|
ca->fill = ALLOC_N(char, ca->bytes);
|
69
69
|
|
70
70
|
ca->dim = ca->count;
|
71
71
|
|
72
|
-
memcpy(ca->start, start, rank * sizeof(
|
73
|
-
memcpy(ca->count, count, rank * sizeof(
|
74
|
-
memcpy(ca->size0, dim, rank * sizeof(
|
72
|
+
memcpy(ca->start, start, rank * sizeof(ca_size_t));
|
73
|
+
memcpy(ca->count, count, rank * sizeof(ca_size_t));
|
74
|
+
memcpy(ca->size0, dim, rank * sizeof(ca_size_t));
|
75
75
|
|
76
76
|
if ( fill ) {
|
77
77
|
memcpy(ca->fill, fill, ca->bytes);
|
78
78
|
}
|
79
79
|
else {
|
80
80
|
if ( ca_is_object_type(ca) ) {
|
81
|
-
*(VALUE *)ca->fill =
|
81
|
+
*(VALUE *)ca->fill = INT2NUM(0);
|
82
82
|
}
|
83
83
|
else {
|
84
84
|
memset(ca->fill, 0, ca->bytes);
|
@@ -94,7 +94,7 @@ ca_window_setup (CAWindow *ca, CArray *parent,
|
|
94
94
|
|
95
95
|
CAWindow *
|
96
96
|
ca_window_new (CArray *parent,
|
97
|
-
|
97
|
+
ca_size_t *start, ca_size_t *count, int8_t bounds, char *fill)
|
98
98
|
{
|
99
99
|
CAWindow *ca = ALLOC(CAWindow);
|
100
100
|
ca_window_setup(ca, parent, start, count, bounds, fill);
|
@@ -130,31 +130,32 @@ ca_window_func_clone (void *ap)
|
|
130
130
|
}
|
131
131
|
|
132
132
|
static char *
|
133
|
-
ca_window_func_ptr_at_index (void *ap,
|
133
|
+
ca_window_func_ptr_at_index (void *ap, ca_size_t *idx) ;
|
134
134
|
|
135
135
|
static char *
|
136
|
-
ca_window_func_ptr_at_addr (void *ap,
|
136
|
+
ca_window_func_ptr_at_addr (void *ap, ca_size_t addr)
|
137
137
|
{
|
138
138
|
CAWindow *ca = (CAWindow *) ap;
|
139
139
|
if ( ca->ptr ) {
|
140
140
|
return ca->ptr + ca->bytes * addr;
|
141
141
|
}
|
142
142
|
else {
|
143
|
-
|
143
|
+
ca_size_t idx[CA_RANK_MAX];
|
144
144
|
ca_addr2index((CArray *)ca, addr, idx);
|
145
145
|
return ca_window_func_ptr_at_index(ca, idx);
|
146
146
|
}
|
147
147
|
}
|
148
148
|
|
149
149
|
static char *
|
150
|
-
ca_window_func_ptr_at_index (void *ap,
|
150
|
+
ca_window_func_ptr_at_index (void *ap, ca_size_t *idx)
|
151
151
|
{
|
152
|
-
|
152
|
+
ca_size_t k;
|
153
153
|
CAWindow *ca = (CAWindow *) ap;
|
154
154
|
if ( ! ca->ptr ) {
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
ca_size_t *start = ca->start;
|
156
|
+
ca_size_t *size0 = ca->size0;
|
157
|
+
int8_t i;
|
158
|
+
ca_size_t n;
|
158
159
|
n = 0;
|
159
160
|
for (i=0; i<ca->rank; i++) {
|
160
161
|
k = start[i] + idx[i];
|
@@ -178,13 +179,14 @@ ca_window_func_ptr_at_index (void *ap, int32_t *idx)
|
|
178
179
|
}
|
179
180
|
|
180
181
|
static void
|
181
|
-
ca_window_func_fetch_index (void *ap,
|
182
|
+
ca_window_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
182
183
|
{
|
183
184
|
CAWindow *ca = (CAWindow *) ap;
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
ca_size_t *start = ca->start;
|
186
|
+
ca_size_t *size0 = ca->size0;
|
187
|
+
ca_size_t idx0[CA_RANK_MAX];
|
188
|
+
int8_t i;
|
189
|
+
ca_size_t k;
|
188
190
|
for (i=0; i<ca->rank; i++) {
|
189
191
|
k = start[i] + idx[i];
|
190
192
|
k = ca_bounds_normalize_index(ca->bounds, size0[i], k);
|
@@ -198,13 +200,14 @@ ca_window_func_fetch_index (void *ap, int32_t *idx, void *ptr)
|
|
198
200
|
}
|
199
201
|
|
200
202
|
static void
|
201
|
-
ca_window_func_store_index (void *ap,
|
203
|
+
ca_window_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
202
204
|
{
|
203
205
|
CAWindow *ca = (CAWindow *) ap;
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
206
|
+
ca_size_t *start = ca->start;
|
207
|
+
ca_size_t *size0 = ca->size0;
|
208
|
+
ca_size_t idx0[CA_RANK_MAX];
|
209
|
+
int8_t i;
|
210
|
+
ca_size_t k;
|
208
211
|
for (i=0; i<ca->rank; i++) {
|
209
212
|
k = start[i] + idx[i];
|
210
213
|
k = ca_bounds_normalize_index(ca->bounds, size0[i], k);
|
@@ -294,7 +297,7 @@ ca_window_func_create_mask (void *ap)
|
|
294
297
|
{
|
295
298
|
CAWindow *ca = (CAWindow *) ap;
|
296
299
|
boolean8_t fill;
|
297
|
-
|
300
|
+
ca_size_t bounds = ca->bounds;
|
298
301
|
|
299
302
|
ca_update_mask(ca->parent);
|
300
303
|
if ( ! ca->parent->mask ) {
|
@@ -348,8 +351,8 @@ ca_operation_function_t ca_window_func = {
|
|
348
351
|
} \
|
349
352
|
else { \
|
350
353
|
CArray *parent = cb->parent; \
|
351
|
-
|
352
|
-
|
354
|
+
ca_size_t start = cb->start[level]; \
|
355
|
+
ca_size_t size0 = cb->size0[level]; \
|
353
356
|
type *p, *q, *v; \
|
354
357
|
idx[level] = 0; \
|
355
358
|
p = (type*)ca_ptr_at_index((CArray*)cb, idx); \
|
@@ -389,10 +392,10 @@ ca_operation_function_t ca_window_func = {
|
|
389
392
|
|
390
393
|
static void
|
391
394
|
ca_window_attach_loop (CAWindow *cb, int8_t level,
|
392
|
-
|
395
|
+
ca_size_t *idx, ca_size_t *idx0, int fill)
|
393
396
|
{
|
394
|
-
|
395
|
-
|
397
|
+
ca_size_t count = cb->count[level];
|
398
|
+
ca_size_t i, k;
|
396
399
|
|
397
400
|
if ( level == cb->rank - 1 ) {
|
398
401
|
switch ( cb->data_type ) {
|
@@ -421,8 +424,8 @@ ca_window_attach_loop (CAWindow *cb, int8_t level,
|
|
421
424
|
}
|
422
425
|
}
|
423
426
|
else {
|
424
|
-
|
425
|
-
|
427
|
+
ca_size_t start = cb->start[level];
|
428
|
+
ca_size_t size0 = cb->size0[level];
|
426
429
|
for (i=0; i<count; i++) {
|
427
430
|
idx[level] = i;
|
428
431
|
k = start + i;
|
@@ -447,8 +450,8 @@ ca_window_attach_loop (CAWindow *cb, int8_t level,
|
|
447
450
|
}
|
448
451
|
}
|
449
452
|
else {
|
450
|
-
|
451
|
-
|
453
|
+
ca_size_t start = cb->start[level];
|
454
|
+
ca_size_t size0 = cb->size0[level];
|
452
455
|
for (i=0; i<count; i++) {
|
453
456
|
idx[level] = i;
|
454
457
|
k = start + i;
|
@@ -469,8 +472,8 @@ ca_window_attach_loop (CAWindow *cb, int8_t level,
|
|
469
472
|
void
|
470
473
|
ca_window_attach (CAWindow *cb)
|
471
474
|
{
|
472
|
-
|
473
|
-
|
475
|
+
ca_size_t idx[CA_RANK_MAX];
|
476
|
+
ca_size_t idx0[CA_RANK_MAX];
|
474
477
|
ca_window_attach_loop(cb, (int8_t) 0, idx, idx0, 0);
|
475
478
|
}
|
476
479
|
|
@@ -515,12 +518,12 @@ ca_window_attach (CAWindow *cb)
|
|
515
518
|
|
516
519
|
static void
|
517
520
|
ca_window_sync_loop (CAWindow *cb, int8_t level,
|
518
|
-
|
521
|
+
ca_size_t *idx, ca_size_t *idx0)
|
519
522
|
{
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
523
|
+
ca_size_t count = cb->count[level];
|
524
|
+
ca_size_t start = cb->start[level];
|
525
|
+
ca_size_t size0 = cb->size0[level];
|
526
|
+
ca_size_t i, k;
|
524
527
|
|
525
528
|
if ( level == cb->rank - 1 ) {
|
526
529
|
switch ( cb->data_type ) {
|
@@ -575,8 +578,8 @@ ca_window_sync_loop (CAWindow *cb, int8_t level,
|
|
575
578
|
void
|
576
579
|
ca_window_sync (CAWindow *cb)
|
577
580
|
{
|
578
|
-
|
579
|
-
|
581
|
+
ca_size_t idx[CA_RANK_MAX];
|
582
|
+
ca_size_t idx0[CA_RANK_MAX];
|
580
583
|
ca_window_sync_loop(cb, (int8_t) 0, idx, idx0);
|
581
584
|
}
|
582
585
|
|
@@ -619,12 +622,12 @@ ca_window_sync (CAWindow *cb)
|
|
619
622
|
|
620
623
|
static void
|
621
624
|
ca_window_fill_loop (CAWindow *cb, char *ptr,
|
622
|
-
int8_t level,
|
625
|
+
int8_t level, ca_size_t *idx0)
|
623
626
|
{
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
627
|
+
ca_size_t count = cb->count[level];
|
628
|
+
ca_size_t start = cb->start[level];
|
629
|
+
ca_size_t size0 = cb->size0[level];
|
630
|
+
ca_size_t i, k;
|
628
631
|
|
629
632
|
if ( level == cb->rank - 1 ) {
|
630
633
|
switch ( cb->data_type ) {
|
@@ -678,7 +681,7 @@ ca_window_fill_loop (CAWindow *cb, char *ptr,
|
|
678
681
|
void
|
679
682
|
ca_window_fill (CAWindow *cb, char *ptr)
|
680
683
|
{
|
681
|
-
|
684
|
+
ca_size_t idx0[CA_RANK_MAX];
|
682
685
|
ca_window_fill_loop(cb, ptr, (int8_t) 0, idx0);
|
683
686
|
}
|
684
687
|
|
@@ -686,7 +689,7 @@ ca_window_fill (CAWindow *cb, char *ptr)
|
|
686
689
|
|
687
690
|
VALUE
|
688
691
|
rb_ca_window_new (VALUE cary,
|
689
|
-
|
692
|
+
ca_size_t *start, ca_size_t *count, int8_t bounds, char *fill)
|
690
693
|
{
|
691
694
|
volatile VALUE obj;
|
692
695
|
CArray *parent;
|
@@ -713,12 +716,12 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
713
716
|
volatile VALUE obj, ropt, rfval = CA_NIL, rbounds = Qnil, rcs;
|
714
717
|
CArray *ca;
|
715
718
|
CScalar *cs;
|
716
|
-
|
717
|
-
|
719
|
+
ca_size_t start[CA_RANK_MAX];
|
720
|
+
ca_size_t count[CA_RANK_MAX];
|
718
721
|
int32_t bounds = CA_BOUNDS_FILL;
|
719
722
|
char *fill = NULL;
|
720
723
|
char *cbounds;
|
721
|
-
|
724
|
+
ca_size_t i;
|
722
725
|
|
723
726
|
Data_Get_Struct(self, CArray, ca);
|
724
727
|
|
@@ -730,7 +733,7 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
730
733
|
}
|
731
734
|
|
732
735
|
for (i=0; i<argc; i++) {
|
733
|
-
|
736
|
+
ca_size_t offset, len, step;
|
734
737
|
volatile VALUE arg = argv[i];
|
735
738
|
ca_parse_range_without_check(arg, ca->dim[i], &offset, &len, &step);
|
736
739
|
if ( step != 1 || len < 0 ) {
|
@@ -845,8 +848,9 @@ static VALUE
|
|
845
848
|
rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
846
849
|
{
|
847
850
|
CAWindow *cw;
|
848
|
-
|
849
|
-
|
851
|
+
ca_size_t addr;
|
852
|
+
int8_t i;
|
853
|
+
ca_size_t idxi;
|
850
854
|
|
851
855
|
Data_Get_Struct(self, CAWindow, cw);
|
852
856
|
|
@@ -857,7 +861,7 @@ rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
857
861
|
|
858
862
|
addr = 0;
|
859
863
|
for (i=0; i<cw->rank; i++) {
|
860
|
-
idxi =
|
864
|
+
idxi = NUM2SIZE(argv[i]);
|
861
865
|
CA_CHECK_INDEX(idxi, cw->dim[i]);
|
862
866
|
addr = cw->size0[i] * addr + cw->start[i] + idxi;
|
863
867
|
}
|
@@ -866,7 +870,7 @@ rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
866
870
|
return Qnil;
|
867
871
|
}
|
868
872
|
else {
|
869
|
-
return
|
873
|
+
return SIZE2NUM(addr);
|
870
874
|
}
|
871
875
|
}
|
872
876
|
|
@@ -881,9 +885,9 @@ static VALUE
|
|
881
885
|
rb_ca_window_addr2addr0 (VALUE self, VALUE raddr)
|
882
886
|
{
|
883
887
|
CAWindow *cw;
|
884
|
-
|
885
|
-
|
886
|
-
|
888
|
+
ca_size_t addr = NUM2SIZE(raddr);
|
889
|
+
ca_size_t idx[CA_RANK_MAX];
|
890
|
+
int8_t i;
|
887
891
|
|
888
892
|
Data_Get_Struct(self, CAWindow, cw);
|
889
893
|
|
@@ -895,7 +899,7 @@ rb_ca_window_addr2addr0 (VALUE self, VALUE raddr)
|
|
895
899
|
addr += cw->start[i] + idx[i];
|
896
900
|
}
|
897
901
|
|
898
|
-
return
|
902
|
+
return SIZE2NUM(addr);
|
899
903
|
}
|
900
904
|
|
901
905
|
|
@@ -903,7 +907,8 @@ static VALUE
|
|
903
907
|
rb_ca_window_move (int argc, VALUE *argv, VALUE self)
|
904
908
|
{
|
905
909
|
CAWindow *cw;
|
906
|
-
|
910
|
+
ca_size_t start;
|
911
|
+
int8_t i;
|
907
912
|
|
908
913
|
Data_Get_Struct(self, CAWindow, cw);
|
909
914
|
|
@@ -913,7 +918,7 @@ rb_ca_window_move (int argc, VALUE *argv, VALUE self)
|
|
913
918
|
|
914
919
|
ca_update_mask(cw);
|
915
920
|
for (i=0; i<cw->rank; i++) {
|
916
|
-
start =
|
921
|
+
start = NUM2SIZE(argv[i]);
|
917
922
|
cw->start[i] = start;
|
918
923
|
if ( cw->mask ) {
|
919
924
|
((CAWindow*)(cw->mask))->start[i] = start;
|
@@ -954,7 +959,7 @@ rb_ca_window_get_bounds (VALUE self)
|
|
954
959
|
{
|
955
960
|
CAWindow *cw;
|
956
961
|
Data_Get_Struct(self, CAWindow, cw);
|
957
|
-
return
|
962
|
+
return SIZE2NUM(cw->bounds);
|
958
963
|
}
|
959
964
|
|
960
965
|
#define rb_cw_get_attr_ary(name) \
|
@@ -962,11 +967,11 @@ rb_ca_window_get_bounds (VALUE self)
|
|
962
967
|
{ \
|
963
968
|
volatile VALUE ary; \
|
964
969
|
CAWindow *cw; \
|
965
|
-
|
970
|
+
int8_t i; \
|
966
971
|
Data_Get_Struct(self, CAWindow, cw); \
|
967
972
|
ary = rb_ary_new2(cw->rank); \
|
968
973
|
for (i=0; i<cw->rank; i++) { \
|
969
|
-
rb_ary_store(ary, i,
|
974
|
+
rb_ary_store(ary, i, SIZE2NUM(cw->name[i])); \
|
970
975
|
} \
|
971
976
|
return ary; \
|
972
977
|
}
|