carray 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSES +22 -0
- data/README.md +18 -14
- data/Rakefile +1 -1
- data/carray.gemspec +5 -13
- data/{ca_iter_block.c → ext/ca_iter_block.c} +13 -13
- data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +16 -16
- data/{ca_iter_window.c → ext/ca_iter_window.c} +10 -10
- data/{ca_obj_array.c → ext/ca_obj_array.c} +60 -55
- data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +12 -12
- data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +7 -7
- data/{ca_obj_block.c → ext/ca_obj_block.c} +42 -42
- data/{ca_obj_fake.c → ext/ca_obj_fake.c} +7 -7
- data/{ca_obj_farray.c → ext/ca_obj_farray.c} +18 -18
- data/{ca_obj_field.c → ext/ca_obj_field.c} +15 -15
- data/{ca_obj_grid.c → ext/ca_obj_grid.c} +27 -27
- data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +9 -9
- data/{ca_obj_object.c → ext/ca_obj_object.c} +37 -37
- data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +1 -1
- data/{ca_obj_refer.c → ext/ca_obj_refer.c} +33 -33
- data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +43 -43
- data/{ca_obj_select.c → ext/ca_obj_select.c} +2 -2
- data/{ca_obj_shift.c → ext/ca_obj_shift.c} +23 -23
- data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +23 -23
- data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +55 -55
- data/{ca_obj_window.c → ext/ca_obj_window.c} +26 -26
- data/{carray.h → ext/carray.h} +73 -51
- data/{carray_access.c → ext/carray_access.c} +83 -83
- data/{carray_attribute.c → ext/carray_attribute.c} +12 -12
- data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +0 -0
- data/{carray_cast.c → ext/carray_cast.c} +6 -6
- data/{carray_cast_func.rb → ext/carray_cast_func.rb} +0 -0
- data/{carray_class.c → ext/carray_class.c} +0 -0
- data/{carray_conversion.c → ext/carray_conversion.c} +8 -10
- data/{carray_copy.c → ext/carray_copy.c} +19 -19
- data/{carray_core.c → ext/carray_core.c} +2 -2
- data/ext/carray_data_type.c +66 -0
- data/{carray_element.c → ext/carray_element.c} +9 -9
- data/{carray_generate.c → ext/carray_generate.c} +0 -0
- data/{carray_iterator.c → ext/carray_iterator.c} +40 -38
- data/{carray_loop.c → ext/carray_loop.c} +24 -24
- data/{carray_mask.c → ext/carray_mask.c} +17 -6
- data/{carray_math.rb → ext/carray_math.rb} +3 -3
- data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +0 -0
- data/{carray_numeric.c → ext/carray_numeric.c} +1 -1
- data/{carray_operator.c → ext/carray_operator.c} +9 -9
- data/{carray_order.c → ext/carray_order.c} +2 -153
- data/{carray_sort_addr.c → ext/carray_sort_addr.c} +0 -0
- data/{carray_stat.c → ext/carray_stat.c} +5 -5
- data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +23 -23
- data/{carray_test.c → ext/carray_test.c} +22 -21
- data/{carray_undef.c → ext/carray_undef.c} +0 -0
- data/{carray_utils.c → ext/carray_utils.c} +0 -0
- data/{extconf.rb → ext/extconf.rb} +0 -5
- data/{mkmath.rb → ext/mkmath.rb} +0 -0
- data/{ruby_carray.c → ext/ruby_carray.c} +9 -2
- data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +0 -0
- data/{ruby_float_func.c → ext/ruby_float_func.c} +0 -0
- data/{version.h → ext/version.h} +5 -5
- data/{version.rb → ext/version.rb} +0 -0
- data/lib/carray.rb +48 -37
- data/lib/carray/{base/autoload.rb → autoload.rb} +1 -1
- data/lib/carray/autoload/autoload_base.rb +1 -1
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +4 -3
- data/lib/carray/autoload/autoload_gem_random.rb +8 -0
- data/lib/carray/basic.rb +193 -0
- data/lib/carray/compose.rb +291 -0
- data/lib/carray/construct.rb +445 -0
- data/lib/carray/convert.rb +115 -0
- data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
- data/lib/carray/io/imagemagick.rb +1 -1
- data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
- data/lib/carray/mask.rb +91 -0
- data/lib/carray/{base/math.rb → math.rb} +16 -46
- data/lib/carray/math/histogram.rb +7 -7
- data/lib/carray/mkmf.rb +8 -0
- data/lib/carray/object/ca_obj_pack.rb +8 -8
- data/lib/carray/obsolete.rb +272 -0
- data/lib/carray/ordering.rb +157 -0
- data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
- data/lib/carray/{base/string.rb → string.rb} +12 -64
- data/lib/carray/{base/struct.rb → struct.rb} +16 -16
- data/lib/carray/{io/table.rb → table.rb} +1 -10
- data/lib/carray/testing.rb +56 -0
- data/lib/carray/time.rb +78 -0
- data/lib/carray/transform.rb +100 -0
- data/misc/Methods.ja.md +182 -0
- data/{NOTE → misc/NOTE} +0 -0
- data/test/test_ALL.rb +0 -2
- data/test/test_order.rb +7 -7
- data/test/test_ref_store.rb +13 -13
- data/test/test_stat.rb +7 -15
- data/{devel → utils}/guess_shape.rb +0 -0
- data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
- metadata +88 -151
- data/COPYING +0 -56
- data/GPL +0 -340
- data/LEGAL +0 -50
- data/TODO +0 -5
- data/carray_random.c +0 -531
- data/devel/im2col.rb +0 -17
- data/ext/calculus/carray_calculus.c +0 -931
- data/ext/calculus/carray_interp.c +0 -358
- data/ext/calculus/extconf.rb +0 -12
- data/ext/calculus/lib/math/calculus.rb +0 -119
- data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
- data/ext/mathfunc/extconf.rb +0 -18
- data/ext/mathfunc/test/test_hypot.rb +0 -5
- data/ext/mathfunc/test/test_j0.rb +0 -22
- data/ext/mathfunc/test/test_jn.rb +0 -8
- data/ext/mathfunc/test/test_sph.rb +0 -9
- data/lib/carray/autoload/autoload_io_table.rb +0 -1
- data/lib/carray/autoload/autoload_math_interp.rb +0 -4
- data/lib/carray/base/basic.rb +0 -1146
- data/lib/carray/base/obsolete.rb +0 -131
- data/lib/carray/math/interp.rb +0 -57
- data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
- data/mt19937ar.c +0 -182
- data/mt19937ar.h +0 -86
- data/rdoc_main.rb +0 -27
- data/rdoc_math.rb +0 -5
- data/rdoc_stat.rb +0 -31
- data/test/test_narray.rb +0 -64
- data/test/test_random.rb +0 -15
- data/utils/create_rdoc.sh +0 -9
- data/utils/make_tgz.sh +0 -3
@@ -15,7 +15,7 @@
|
|
15
15
|
typedef struct {
|
16
16
|
int16_t obj_type;
|
17
17
|
int8_t data_type;
|
18
|
-
int8_t
|
18
|
+
int8_t ndim;
|
19
19
|
int32_t flags;
|
20
20
|
ca_size_t bytes;
|
21
21
|
ca_size_t elements;
|
@@ -55,7 +55,7 @@ static uint8_t bits[8] = {
|
|
55
55
|
int
|
56
56
|
ca_bitarray_setup (CABitarray *ca, CArray *parent)
|
57
57
|
{
|
58
|
-
int8_t
|
58
|
+
int8_t ndim;
|
59
59
|
ca_size_t bitlen, elements;
|
60
60
|
|
61
61
|
/* check arguments */
|
@@ -64,19 +64,19 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
|
|
64
64
|
rb_raise(rb_eCADataTypeError, "invalid data_type for bitarray");
|
65
65
|
}
|
66
66
|
|
67
|
-
|
67
|
+
ndim = parent->ndim + 1;
|
68
68
|
bitlen = 8 * parent->bytes;
|
69
69
|
elements = bitlen * parent->elements;
|
70
70
|
|
71
71
|
ca->obj_type = CA_OBJ_BITARRAY;
|
72
72
|
ca->data_type = CA_BOOLEAN;
|
73
73
|
ca->flags = 0;
|
74
|
-
ca->
|
74
|
+
ca->ndim = ndim;
|
75
75
|
ca->bytes = 1;
|
76
76
|
ca->elements = elements;
|
77
77
|
ca->ptr = NULL;
|
78
78
|
ca->mask = NULL;
|
79
|
-
ca->dim = ALLOC_N(ca_size_t,
|
79
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
80
80
|
|
81
81
|
ca->parent = parent;
|
82
82
|
ca->attach = 0;
|
@@ -85,8 +85,8 @@ ca_bitarray_setup (CABitarray *ca, CArray *parent)
|
|
85
85
|
ca->bytelen = parent->bytes;
|
86
86
|
ca->bitlen = bitlen;
|
87
87
|
|
88
|
-
memcpy(ca->dim, parent->dim, (
|
89
|
-
ca->dim[
|
88
|
+
memcpy(ca->dim, parent->dim, (ndim-1) * sizeof(ca_size_t));
|
89
|
+
ca->dim[ndim-1] = bitlen;
|
90
90
|
|
91
91
|
if ( ca_has_mask(parent) ) {
|
92
92
|
ca_create_mask(ca);
|
@@ -158,7 +158,7 @@ ca_bitarray_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
158
158
|
{
|
159
159
|
CABitarray *ca = (CABitarray *) ap;
|
160
160
|
ca_size_t bytes = ca->parent->bytes;
|
161
|
-
ca_size_t offset = idx[ca->
|
161
|
+
ca_size_t offset = idx[ca->ndim-1];
|
162
162
|
ca_size_t major, minor;
|
163
163
|
|
164
164
|
if ( ca_endian == CA_BIG_ENDIAN &&
|
@@ -190,7 +190,7 @@ ca_bitarray_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
190
190
|
{
|
191
191
|
CABitarray *ca = (CABitarray *) ap;
|
192
192
|
uint8_t test = *(uint8_t *) ptr;
|
193
|
-
ca_size_t offset = idx[ca->
|
193
|
+
ca_size_t offset = idx[ca->ndim-1];
|
194
194
|
ca_size_t bytes = ca->parent->bytes;
|
195
195
|
ca_size_t major, minor;
|
196
196
|
|
@@ -310,16 +310,16 @@ ca_bitarray_func_create_mask (void *ap)
|
|
310
310
|
ca_size_t count[CA_RANK_MAX];
|
311
311
|
int8_t i;
|
312
312
|
|
313
|
-
for (i=0; i<ca->
|
313
|
+
for (i=0; i<ca->ndim-1; i++) {
|
314
314
|
count[i] = 0;
|
315
315
|
}
|
316
|
-
count[ca->
|
316
|
+
count[ca->ndim-1] = ca->bitlen;
|
317
317
|
|
318
318
|
ca_update_mask(ca->parent);
|
319
319
|
if ( ! ca->parent->mask ) {
|
320
320
|
ca_create_mask(ca->parent);
|
321
321
|
}
|
322
|
-
ca->mask = (CArray *) ca_repeat_new(ca->parent->mask, ca->
|
322
|
+
ca->mask = (CArray *) ca_repeat_new(ca->parent->mask, ca->ndim, count);
|
323
323
|
|
324
324
|
ca_unset_flag(ca->mask, CA_FLAG_READ_ONLY);
|
325
325
|
}
|
@@ -15,7 +15,7 @@
|
|
15
15
|
typedef struct {
|
16
16
|
int16_t obj_type;
|
17
17
|
int8_t data_type;
|
18
|
-
int8_t
|
18
|
+
int8_t ndim;
|
19
19
|
int32_t flags;
|
20
20
|
ca_size_t bytes;
|
21
21
|
ca_size_t elements;
|
@@ -211,7 +211,7 @@ int
|
|
211
211
|
ca_bitfield_setup (CABitfield *ca, CArray *parent,
|
212
212
|
ca_size_t offset, ca_size_t bitlen)
|
213
213
|
{
|
214
|
-
int8_t
|
214
|
+
int8_t ndim;
|
215
215
|
int8_t data_type;
|
216
216
|
ca_size_t bytes = 0, elements;
|
217
217
|
ca_size_t bitsize;
|
@@ -228,7 +228,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
|
|
228
228
|
}
|
229
229
|
*/
|
230
230
|
|
231
|
-
|
231
|
+
ndim = parent->ndim;
|
232
232
|
bitsize = parent->bytes * 8;
|
233
233
|
elements = parent->elements;
|
234
234
|
|
@@ -293,12 +293,12 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
|
|
293
293
|
ca->obj_type = CA_OBJ_BITFIELD;
|
294
294
|
ca->data_type = data_type;
|
295
295
|
ca->flags = 0;
|
296
|
-
ca->
|
296
|
+
ca->ndim = ndim;
|
297
297
|
ca->bytes = bytes;
|
298
298
|
ca->elements = elements;
|
299
299
|
ca->ptr = NULL;
|
300
300
|
ca->mask = NULL;
|
301
|
-
ca->dim = ALLOC_N(ca_size_t,
|
301
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
302
302
|
|
303
303
|
ca->parent = parent;
|
304
304
|
ca->attach = 0;
|
@@ -308,7 +308,7 @@ ca_bitfield_setup (CABitfield *ca, CArray *parent,
|
|
308
308
|
ca->bit_offset = bit_offset;
|
309
309
|
ca->bit_mask = bit_mask;
|
310
310
|
|
311
|
-
memcpy(ca->dim, parent->dim,
|
311
|
+
memcpy(ca->dim, parent->dim, ndim * sizeof(ca_size_t));
|
312
312
|
|
313
313
|
if ( ca_has_mask(parent) ) {
|
314
314
|
ca_create_mask(ca);
|
@@ -484,7 +484,7 @@ ca_bitfield_func_create_mask (void *ap)
|
|
484
484
|
}
|
485
485
|
|
486
486
|
ca->mask = (CArray *) ca_refer_new(ca->parent->mask,
|
487
|
-
CA_BOOLEAN, ca->
|
487
|
+
CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
|
488
488
|
}
|
489
489
|
|
490
490
|
ca_operation_function_t ca_bitfield_func = {
|
@@ -20,7 +20,7 @@ VALUE rb_cCABlock;
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
static int
|
23
|
-
ca_block_setup (CABlock *ca, CArray *parent, int8_t
|
23
|
+
ca_block_setup (CABlock *ca, CArray *parent, int8_t ndim, ca_size_t *dim,
|
24
24
|
ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
|
25
25
|
{
|
26
26
|
int8_t data_type;
|
@@ -33,7 +33,7 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
33
33
|
bytes = parent->bytes;
|
34
34
|
|
35
35
|
elements = 1;
|
36
|
-
for (i=0; i<
|
36
|
+
for (i=0; i<ndim; i++) {
|
37
37
|
if ( count[i] < 0 ) {
|
38
38
|
rb_raise(rb_eIndexError,
|
39
39
|
"invalid size for %i-th dimension (negative)", i);
|
@@ -41,8 +41,8 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
41
41
|
elements *= count[i];
|
42
42
|
}
|
43
43
|
|
44
|
-
maxdim_index =
|
45
|
-
for (i=
|
44
|
+
maxdim_index = ndim-1;
|
45
|
+
for (i=ndim-2; i>=0; i--) {
|
46
46
|
if ( count[i] > count[maxdim_index] ) {
|
47
47
|
maxdim_index = i;
|
48
48
|
}
|
@@ -50,7 +50,7 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
50
50
|
|
51
51
|
maxdim_step = 1;
|
52
52
|
maxdim_step0 = step[maxdim_index];
|
53
|
-
for (i=maxdim_index+1; i<
|
53
|
+
for (i=maxdim_index+1; i<ndim; i++) {
|
54
54
|
maxdim_step *= count[i];
|
55
55
|
maxdim_step0 *= dim[i];
|
56
56
|
}
|
@@ -58,7 +58,7 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
58
58
|
ca->obj_type = CA_OBJ_BLOCK;
|
59
59
|
ca->data_type = data_type;
|
60
60
|
ca->flags = 0;
|
61
|
-
ca->
|
61
|
+
ca->ndim = ndim;
|
62
62
|
ca->bytes = bytes;
|
63
63
|
ca->elements = elements;
|
64
64
|
ca->ptr = NULL;
|
@@ -67,10 +67,10 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
67
67
|
ca->attach = 0;
|
68
68
|
ca->nosync = 0;
|
69
69
|
ca->offset = offset;
|
70
|
-
ca->start = ALLOC_N(ca_size_t,
|
71
|
-
ca->step = ALLOC_N(ca_size_t,
|
72
|
-
ca->count = ALLOC_N(ca_size_t,
|
73
|
-
ca->size0 = ALLOC_N(ca_size_t,
|
70
|
+
ca->start = ALLOC_N(ca_size_t, ndim);
|
71
|
+
ca->step = ALLOC_N(ca_size_t, ndim);
|
72
|
+
ca->count = ALLOC_N(ca_size_t, ndim);
|
73
|
+
ca->size0 = ALLOC_N(ca_size_t, ndim);
|
74
74
|
|
75
75
|
ca->maxdim_index = maxdim_index;
|
76
76
|
ca->maxdim_step = maxdim_step;
|
@@ -80,10 +80,10 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
80
80
|
|
81
81
|
ca->dim = ca->count; /* ca->dim should not be free */
|
82
82
|
|
83
|
-
memcpy(ca->start, start,
|
84
|
-
memcpy(ca->step, step,
|
85
|
-
memcpy(ca->count, count,
|
86
|
-
memcpy(ca->size0, dim,
|
83
|
+
memcpy(ca->start, start, ndim * sizeof(ca_size_t));
|
84
|
+
memcpy(ca->step, step, ndim * sizeof(ca_size_t));
|
85
|
+
memcpy(ca->count, count, ndim * sizeof(ca_size_t));
|
86
|
+
memcpy(ca->size0, dim, ndim * sizeof(ca_size_t));
|
87
87
|
|
88
88
|
if ( ca_has_mask(parent) ) {
|
89
89
|
ca_create_mask(ca);
|
@@ -93,11 +93,11 @@ ca_block_setup (CABlock *ca, CArray *parent, int8_t rank, ca_size_t *dim,
|
|
93
93
|
}
|
94
94
|
|
95
95
|
CABlock *
|
96
|
-
ca_block_new (CArray *parent, int8_t
|
96
|
+
ca_block_new (CArray *parent, int8_t ndim, ca_size_t *dim,
|
97
97
|
ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
|
98
98
|
{
|
99
99
|
CABlock *ca = ALLOC(CABlock);
|
100
|
-
ca_block_setup(ca, parent,
|
100
|
+
ca_block_setup(ca, parent, ndim, dim, start, step, count, offset);
|
101
101
|
return ca;
|
102
102
|
}
|
103
103
|
|
@@ -126,7 +126,7 @@ ca_block_func_clone (void *ap)
|
|
126
126
|
{
|
127
127
|
CABlock *ca = (CABlock *) ap;
|
128
128
|
return ca_block_new(ca->parent,
|
129
|
-
ca->
|
129
|
+
ca->ndim, ca->size0,
|
130
130
|
ca->start, ca->step, ca->count, ca->offset);
|
131
131
|
}
|
132
132
|
|
@@ -162,7 +162,7 @@ ca_block_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
162
162
|
int8_t i;
|
163
163
|
ca_size_t n;
|
164
164
|
n = start[0] + idx[0]*step[0];
|
165
|
-
for (i=1; i<ca->
|
165
|
+
for (i=1; i<ca->ndim; i++) {
|
166
166
|
n *= size0[i];
|
167
167
|
n += start[i] + idx[i]*step[i];
|
168
168
|
}
|
@@ -186,7 +186,7 @@ ca_block_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
186
186
|
int8_t i;
|
187
187
|
ca_size_t n;
|
188
188
|
n = start[0] + idx[0]*step[0];
|
189
|
-
for (i=1; i<ca->
|
189
|
+
for (i=1; i<ca->ndim; i++) {
|
190
190
|
n *= size0[i];
|
191
191
|
n += start[i] + idx[i]*step[i];
|
192
192
|
}
|
@@ -204,7 +204,7 @@ ca_block_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
204
204
|
int8_t i;
|
205
205
|
ca_size_t n;
|
206
206
|
n = start[0] + idx[0]*step[0];
|
207
|
-
for (i=1; i<ca->
|
207
|
+
for (i=1; i<ca->ndim; i++) {
|
208
208
|
n *= size0[i];
|
209
209
|
n += start[i] + idx[i]*step[i];
|
210
210
|
}
|
@@ -292,7 +292,7 @@ ca_block_func_create_mask (void *ap)
|
|
292
292
|
ca_create_mask(ca->parent);
|
293
293
|
ca->mask =
|
294
294
|
(CArray *) ca_block_new(ca->parent->mask,
|
295
|
-
ca->
|
295
|
+
ca->ndim, ca->size0,
|
296
296
|
ca->start, ca->step, ca->count, ca->offset);
|
297
297
|
}
|
298
298
|
|
@@ -320,7 +320,7 @@ ca_operation_function_t ca_block_func = {
|
|
320
320
|
/* ------------------------------------------------------------------- */
|
321
321
|
|
322
322
|
VALUE
|
323
|
-
rb_ca_block_new (VALUE cary, int8_t
|
323
|
+
rb_ca_block_new (VALUE cary, int8_t ndim, ca_size_t *dim,
|
324
324
|
ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
|
325
325
|
{
|
326
326
|
volatile VALUE obj;
|
@@ -330,7 +330,7 @@ rb_ca_block_new (VALUE cary, int8_t rank, ca_size_t *dim,
|
|
330
330
|
rb_check_carray_object(cary);
|
331
331
|
Data_Get_Struct(cary, CArray, parent);
|
332
332
|
|
333
|
-
ca = ca_block_new(parent,
|
333
|
+
ca = ca_block_new(parent, ndim, dim, start, step, count, offset);
|
334
334
|
obj = ca_wrap_struct(ca);
|
335
335
|
rb_ca_set_parent(obj, cary);
|
336
336
|
rb_ca_data_type_inherit(obj, cary);
|
@@ -351,7 +351,7 @@ ca_block_attach_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t sad
|
|
351
351
|
ca_size_t count = ca->count[level];
|
352
352
|
ca_size_t addr, addr0, i;
|
353
353
|
|
354
|
-
if ( level == ca->
|
354
|
+
if ( level == ca->ndim - 1 ) {
|
355
355
|
if ( ca->parent->ptr ) {
|
356
356
|
addr = saddr * ca->dim[level];
|
357
357
|
addr0 = saddr0 * ca->size0[level] + ca->start[level];
|
@@ -386,7 +386,7 @@ ca_block_attach_loop (CABlock *ca, ca_size_t level, ca_size_t saddr, ca_size_t s
|
|
386
386
|
ca_size_t count = ca->count[level];
|
387
387
|
ca_size_t addr, addr0, i;
|
388
388
|
|
389
|
-
if ( level == ca->
|
389
|
+
if ( level == ca->ndim - 1 ) {
|
390
390
|
if ( level == ca->maxdim_index ) {
|
391
391
|
addr = saddr * ca->dim[level];
|
392
392
|
addr0 = saddr0 * ca->size0[level] + ca->start[level];
|
@@ -431,7 +431,7 @@ static void
|
|
431
431
|
ca_block_attach (CABlock *ca)
|
432
432
|
{
|
433
433
|
ca_size_t addr = 0, addr0 = 0;
|
434
|
-
if ( ca->
|
434
|
+
if ( ca->ndim <= 2 ) {
|
435
435
|
ca_block_attach_loop2(ca, 0, addr, addr0);
|
436
436
|
}
|
437
437
|
else {
|
@@ -445,7 +445,7 @@ ca_block_sync_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t saddr
|
|
445
445
|
ca_size_t count = ca->count[level];
|
446
446
|
ca_size_t addr, addr0, i;
|
447
447
|
|
448
|
-
if ( level == ca->
|
448
|
+
if ( level == ca->ndim - 1 ) {
|
449
449
|
if ( ca->parent->ptr ) {
|
450
450
|
addr = saddr * ca->dim[level];
|
451
451
|
addr0 = saddr0 * ca->size0[level] + ca->start[level];
|
@@ -479,7 +479,7 @@ ca_block_sync_loop (CABlock *ca, int8_t level, ca_size_t saddr, ca_size_t saddr0
|
|
479
479
|
ca_size_t count = ca->count[level];
|
480
480
|
ca_size_t addr, addr0, i;
|
481
481
|
|
482
|
-
if ( level == ca->
|
482
|
+
if ( level == ca->ndim - 1 ) {
|
483
483
|
if ( level == ca->maxdim_index ) {
|
484
484
|
addr = saddr * ca->dim[level];
|
485
485
|
addr0 = saddr0 * ca->size0[level] + ca->start[level];
|
@@ -520,7 +520,7 @@ static void
|
|
520
520
|
ca_block_sync (CABlock *cb)
|
521
521
|
{
|
522
522
|
ca_size_t addr = 0, addr0 = 0;
|
523
|
-
if ( cb->
|
523
|
+
if ( cb->ndim <= 2 ) {
|
524
524
|
ca_block_sync_loop2(cb, 0, addr, addr0);
|
525
525
|
}
|
526
526
|
else {
|
@@ -533,7 +533,7 @@ ca_block_fill_loop2 (CABlock *ca, int8_t level, ca_size_t saddr, char *val)
|
|
533
533
|
{
|
534
534
|
ca_size_t count = ca->count[level];
|
535
535
|
ca_size_t addr, i;
|
536
|
-
if ( level == ca->
|
536
|
+
if ( level == ca->ndim - 1 ) {
|
537
537
|
addr = saddr * ca->dim[level];
|
538
538
|
mfill_step(ca_ptr_at_addr(ca, addr),
|
539
539
|
ca->bytes, count, ca->step[level], val);
|
@@ -551,7 +551,7 @@ ca_block_fill_loop (CABlock *ca, int8_t level, ca_size_t saddr, char *val)
|
|
551
551
|
{
|
552
552
|
ca_size_t count = ca->count[level];
|
553
553
|
ca_size_t addr, i;
|
554
|
-
if ( level == ca->
|
554
|
+
if ( level == ca->ndim - 1 ) {
|
555
555
|
if ( level == ca->maxdim_index ) {
|
556
556
|
addr = saddr * ca->dim[level];
|
557
557
|
mfill_step(ca_ptr_at_addr(ca, addr),
|
@@ -586,7 +586,7 @@ static void
|
|
586
586
|
ca_block_fill (CABlock *ca, char *val)
|
587
587
|
{
|
588
588
|
ca_size_t addr = 0;
|
589
|
-
if ( ca->
|
589
|
+
if ( ca->ndim <= 2 ) {
|
590
590
|
ca_block_fill_loop2(ca, 0, addr, val);
|
591
591
|
}
|
592
592
|
else {
|
@@ -707,12 +707,12 @@ rb_cb_initialize_copy (VALUE self, VALUE other)
|
|
707
707
|
Data_Get_Struct(self, CABlock, ca);
|
708
708
|
Data_Get_Struct(other, CABlock, cs);
|
709
709
|
|
710
|
-
for (i=0; i<cs->
|
710
|
+
for (i=0; i<cs->ndim; i++) {
|
711
711
|
shrink[i] = 0;
|
712
712
|
}
|
713
713
|
|
714
714
|
ca_block_setup(ca, cs->parent,
|
715
|
-
cs->
|
715
|
+
cs->ndim, cs->size0, cs->start, cs->step, cs->count, cs->offset);
|
716
716
|
|
717
717
|
/* CHECK ME : other.parent instead of other ? */
|
718
718
|
rb_ca_set_parent(self, rb_ca_parent(other));
|
@@ -728,8 +728,8 @@ rb_cb_initialize_copy (VALUE self, VALUE other)
|
|
728
728
|
CABlock *cb; \
|
729
729
|
int8_t i; \
|
730
730
|
Data_Get_Struct(self, CABlock, cb); \
|
731
|
-
ary = rb_ary_new2(cb->
|
732
|
-
for (i=0; i<cb->
|
731
|
+
ary = rb_ary_new2(cb->ndim); \
|
732
|
+
for (i=0; i<cb->ndim; i++) { \
|
733
733
|
rb_ary_store(ary, i, LONG2NUM(cb->name[i])); \
|
734
734
|
} \
|
735
735
|
return ary; \
|
@@ -780,13 +780,13 @@ rb_cb_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
780
780
|
|
781
781
|
Data_Get_Struct(self, CABlock, cb);
|
782
782
|
|
783
|
-
if ( argc != cb->
|
783
|
+
if ( argc != cb->ndim ) {
|
784
784
|
rb_raise(rb_eArgError,
|
785
|
-
"invalid # of arguments (should be <%i>)", cb->
|
785
|
+
"invalid # of arguments (should be <%i>)", cb->ndim);
|
786
786
|
}
|
787
787
|
|
788
788
|
addr = 0;
|
789
|
-
for (i=0; i<cb->
|
789
|
+
for (i=0; i<cb->ndim; i++) {
|
790
790
|
idxi = NUM2SIZE(argv[i]);
|
791
791
|
CA_CHECK_INDEX(idxi, cb->dim[i]);
|
792
792
|
addr = cb->size0[i] * addr + cb->start[i] + idxi * cb->step[i];
|
@@ -815,7 +815,7 @@ rb_cb_addr2addr0 (VALUE self, VALUE raddr)
|
|
815
815
|
ca_addr2index((CArray*)cb, addr, idx);
|
816
816
|
|
817
817
|
addr = 0;
|
818
|
-
for (i=0; i<cb->
|
818
|
+
for (i=0; i<cb->ndim; i++) {
|
819
819
|
addr *= cb->size0[i];
|
820
820
|
addr += cb->start[i] + idx[i] * cb->step[i];
|
821
821
|
}
|
@@ -840,13 +840,13 @@ rb_cb_move (int argc, VALUE *argv, VALUE self)
|
|
840
840
|
|
841
841
|
Data_Get_Struct(self, CABlock, cb);
|
842
842
|
|
843
|
-
if ( argc != cb->
|
843
|
+
if ( argc != cb->ndim ) {
|
844
844
|
rb_raise(rb_eArgError, "invalid # of arguments");
|
845
845
|
}
|
846
846
|
|
847
847
|
ca_update_mask(cb);
|
848
848
|
|
849
|
-
for (i=0; i<cb->
|
849
|
+
for (i=0; i<cb->ndim; i++) {
|
850
850
|
start = NUM2SIZE(argv[i]);
|
851
851
|
if ( start < 0 ) {
|
852
852
|
start += cb->size0[i];
|
@@ -15,7 +15,7 @@
|
|
15
15
|
typedef struct {
|
16
16
|
int16_t obj_type;
|
17
17
|
int8_t data_type;
|
18
|
-
int8_t
|
18
|
+
int8_t ndim;
|
19
19
|
int32_t flags;
|
20
20
|
ca_size_t bytes;
|
21
21
|
ca_size_t elements;
|
@@ -41,7 +41,7 @@ static VALUE rb_cCAFake;
|
|
41
41
|
int
|
42
42
|
ca_fake_setup (CAFake *ca, CArray *parent, int8_t data_type, ca_size_t bytes)
|
43
43
|
{
|
44
|
-
int8_t
|
44
|
+
int8_t ndim;
|
45
45
|
ca_size_t *dim, elements;
|
46
46
|
|
47
47
|
/* check arguments */
|
@@ -49,25 +49,25 @@ ca_fake_setup (CAFake *ca, CArray *parent, int8_t data_type, ca_size_t bytes)
|
|
49
49
|
CA_CHECK_DATA_TYPE(data_type);
|
50
50
|
CA_CHECK_BYTES(data_type, bytes);
|
51
51
|
|
52
|
-
|
52
|
+
ndim = parent->ndim;
|
53
53
|
dim = parent->dim;
|
54
54
|
elements = parent->elements;
|
55
55
|
|
56
56
|
ca->obj_type = CA_OBJ_FAKE;
|
57
57
|
ca->data_type = data_type;
|
58
58
|
ca->flags = 0;
|
59
|
-
ca->
|
59
|
+
ca->ndim = ndim;
|
60
60
|
ca->bytes = bytes;
|
61
61
|
ca->elements = elements;
|
62
62
|
ca->ptr = NULL;
|
63
63
|
ca->mask = NULL;
|
64
|
-
ca->dim = ALLOC_N(ca_size_t,
|
64
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
65
65
|
|
66
66
|
ca->parent = parent;
|
67
67
|
ca->attach = 0;
|
68
68
|
ca->nosync = 0;
|
69
69
|
|
70
|
-
memcpy(ca->dim, dim,
|
70
|
+
memcpy(ca->dim, dim, ndim * sizeof(ca_size_t));
|
71
71
|
|
72
72
|
if ( ca_has_mask(parent) ) {
|
73
73
|
ca_create_mask(ca);
|
@@ -288,7 +288,7 @@ ca_fake_func_create_mask (void *ap)
|
|
288
288
|
}
|
289
289
|
ca->mask =
|
290
290
|
(CArray *) ca_refer_new(ca->parent->mask,
|
291
|
-
CA_BOOLEAN, ca->
|
291
|
+
CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
|
292
292
|
}
|
293
293
|
|
294
294
|
ca_operation_function_t ca_fake_func = {
|