carray 1.3.5 → 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 -21
- data/Rakefile +31 -0
- data/carray.gemspec +13 -26
- 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} +77 -51
- data/{carray_access.c → ext/carray_access.c} +133 -91
- 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} +11 -13
- 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} +67 -1
- 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} +25 -25
- 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} +32 -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} +12 -2
- 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 +49 -7
- data/lib/carray/{base/autoload.rb → autoload.rb} +48 -6
- data/lib/carray/autoload/autoload_base.rb +1 -5
- data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
- data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
- data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
- data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
- data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +15 -0
- data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
- data/lib/carray/autoload/autoload_gem_random.rb +8 -0
- data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
- data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -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} +17 -47
- 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/string.rb +190 -0
- data/lib/carray/{base/struct.rb → struct.rb} +20 -20
- data/lib/carray/{io/table.rb → table.rb} +1 -9
- 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 +100 -254
- data/COPYING +0 -56
- data/GPL +0 -340
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -33
- data/LEGAL +0 -50
- data/TODO +0 -5
- data/carray_random.c +0 -531
- 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/autoload/autoload_math_calculus.rb +0 -2
- data/ext/calculus/lib/math/calculus.rb +0 -119
- data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
- data/ext/fortio/extconf.rb +0 -3
- data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
- data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
- data/ext/fortio/lib/fortio.rb +0 -3
- data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
- data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
- data/ext/fortio/lib/fortio/fortran_format.y +0 -215
- data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
- data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
- data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
- data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
- data/ext/fortio/ruby_fortio.c +0 -182
- data/ext/fortio/test/test_H.rb +0 -5
- data/ext/fortio/test/test_T.rb +0 -7
- data/ext/fortio/test/test_fortran_format.rb +0 -86
- data/ext/fortio/test/test_namelist.rb +0 -25
- data/ext/fortio/test/test_namelist_write.rb +0 -10
- data/ext/fortio/test/test_sequential.rb +0 -13
- data/ext/fortio/test/test_sequential2.rb +0 -13
- data/ext/fortio/work/test.rb +0 -10
- data/ext/fortio/work/test_e.rb +0 -19
- data/ext/fortio/work/test_ep.rb +0 -10
- data/ext/fortio/work/test_parse.rb +0 -12
- data/ext/imagemap/carray_imagemap.c +0 -495
- data/ext/imagemap/doc/call_graph.dot +0 -28
- data/ext/imagemap/draw.c +0 -567
- data/ext/imagemap/extconf.rb +0 -13
- data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +0 -1
- data/ext/imagemap/lib/graphics/imagemap.rb +0 -273
- data/ext/imagemap/lib/image_map.rb +0 -4
- data/ext/imagemap/test/swath_index.rb +0 -83
- data/ext/imagemap/test/swath_warp.rb +0 -99
- data/ext/imagemap/test/test.rb +0 -23
- data/ext/imagemap/test/test_image.rb +0 -42
- data/ext/imagemap/test/test_line.rb +0 -14
- data/ext/imagemap/test/test_rotate.rb +0 -17
- data/ext/imagemap/test/test_triangle.rb +0 -20
- data/ext/imagemap/test/test_warp.rb +0 -26
- data/ext/mathfunc/extconf.rb +0 -18
- data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
- data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
- 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/ext/narray/README +0 -22
- data/ext/narray/ca_wrap_narray.c +0 -500
- data/ext/narray/carray_narray.c +0 -21
- data/ext/narray/extconf.rb +0 -57
- data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
- data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
- data/ext/narray/lib/math/narray.rb +0 -17
- data/ext/narray/lib/math/narray_miss.rb +0 -45
- data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
- 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 -1090
- data/lib/carray/base/obsolete.rb +0 -131
- data/lib/carray/graphics/gnuplot.rb +0 -2131
- data/lib/carray/graphics/zimg.rb +0 -296
- data/lib/carray/io/csv.rb +0 -572
- data/lib/carray/io/pg.rb +0 -101
- data/lib/carray/io/sqlite3.rb +0 -215
- 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;
|
@@ -44,7 +44,7 @@ int
|
|
44
44
|
ca_field_setup (CAField *ca, CArray *parent,
|
45
45
|
ca_size_t offset, int8_t data_type, ca_size_t bytes)
|
46
46
|
{
|
47
|
-
int8_t
|
47
|
+
int8_t ndim;
|
48
48
|
ca_size_t elements;
|
49
49
|
|
50
50
|
/* check arguments */
|
@@ -64,25 +64,25 @@ ca_field_setup (CAField *ca, CArray *parent,
|
|
64
64
|
rb_raise(rb_eRuntimeError, "offset or bytes out of range");
|
65
65
|
}
|
66
66
|
|
67
|
-
|
67
|
+
ndim = parent->ndim;
|
68
68
|
elements = parent->elements;
|
69
69
|
|
70
70
|
ca->obj_type = CA_OBJ_FIELD;
|
71
71
|
ca->data_type = data_type;
|
72
72
|
ca->flags = 0;
|
73
|
-
ca->
|
73
|
+
ca->ndim = ndim;
|
74
74
|
ca->bytes = bytes;
|
75
75
|
ca->elements = elements;
|
76
76
|
ca->ptr = NULL;
|
77
77
|
ca->mask = NULL;
|
78
|
-
ca->dim = ALLOC_N(ca_size_t,
|
78
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
79
79
|
|
80
80
|
ca->parent = parent;
|
81
81
|
ca->attach = 0;
|
82
82
|
ca->nosync = 0;
|
83
83
|
ca->offset = offset;
|
84
84
|
|
85
|
-
memcpy(ca->dim, parent->dim,
|
85
|
+
memcpy(ca->dim, parent->dim, ndim * sizeof(ca_size_t));
|
86
86
|
|
87
87
|
if ( ca_has_mask(parent) ) {
|
88
88
|
ca_create_mask(ca);
|
@@ -149,9 +149,9 @@ ca_field_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
149
149
|
ca_size_t *dim = ca->dim;
|
150
150
|
int8_t i;
|
151
151
|
ca_size_t n;
|
152
|
-
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[
|
153
|
-
for (i=1; i<ca->
|
154
|
-
n = dim[i]*n+idx[i]; /* ... + idx[
|
152
|
+
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
|
153
|
+
for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
|
154
|
+
n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
|
155
155
|
}
|
156
156
|
|
157
157
|
if ( ca->parent->ptr == NULL ) {
|
@@ -285,7 +285,7 @@ ca_field_func_create_mask (void *ap)
|
|
285
285
|
}
|
286
286
|
ca->mask =
|
287
287
|
(CArray *) ca_refer_new(ca->parent->mask,
|
288
|
-
CA_BOOLEAN, ca->
|
288
|
+
CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
|
289
289
|
}
|
290
290
|
|
291
291
|
ca_operation_function_t ca_field_func = {
|
@@ -583,21 +583,21 @@ rb_ca_field (int argc, VALUE *argv, VALUE self)
|
|
583
583
|
if ( rb_obj_is_carray(rtype) ) {
|
584
584
|
CArray *ct;
|
585
585
|
ca_size_t dim[CA_RANK_MAX];
|
586
|
-
int8_t
|
586
|
+
int8_t ndim;
|
587
587
|
int8_t i, j;
|
588
588
|
Data_Get_Struct(rtype, CArray, ct);
|
589
589
|
data_type = CA_FIXLEN;
|
590
590
|
bytes = ct->bytes * ct->elements;
|
591
591
|
obj = rb_ca_field_new(self, offset, data_type, bytes);
|
592
592
|
rb_ca_data_type_inherit(obj, rtype);
|
593
|
-
|
594
|
-
for (i=0; i<ca->
|
593
|
+
ndim = ca->ndim + ct->ndim;
|
594
|
+
for (i=0; i<ca->ndim; i++) {
|
595
595
|
dim[i] = ca->dim[i];
|
596
596
|
}
|
597
|
-
for (j=0; j<ct->
|
597
|
+
for (j=0; j<ct->ndim; j++, i++) {
|
598
598
|
dim[i] = ct->dim[j];
|
599
599
|
}
|
600
|
-
obj = rb_ca_refer_new(obj, ct->data_type,
|
600
|
+
obj = rb_ca_refer_new(obj, ct->data_type, ndim, dim, ct->bytes, 0);
|
601
601
|
}
|
602
602
|
else {
|
603
603
|
rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
|
@@ -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;
|
@@ -43,20 +43,20 @@ int
|
|
43
43
|
ca_grid_setup (CAGrid *ca, CArray *parent, ca_size_t *dim,
|
44
44
|
CArray **grid, int8_t *contig, int share)
|
45
45
|
{
|
46
|
-
int8_t
|
46
|
+
int8_t ndim, data_type;
|
47
47
|
ca_size_t *dim0;
|
48
48
|
ca_size_t elements, bytes;
|
49
49
|
double length;
|
50
50
|
int i, j, k;
|
51
51
|
|
52
52
|
data_type = parent->data_type;
|
53
|
-
|
53
|
+
ndim = parent->ndim;
|
54
54
|
bytes = parent->bytes;
|
55
55
|
dim0 = parent->dim;
|
56
56
|
|
57
57
|
elements = 1;
|
58
58
|
length = bytes;
|
59
|
-
for (i=0; i<
|
59
|
+
for (i=0; i<ndim; i++) {
|
60
60
|
if ( dim[i] < 0 ) {
|
61
61
|
rb_raise(rb_eRuntimeError, "negative size for %i-th dimension", i);
|
62
62
|
}
|
@@ -71,12 +71,12 @@ ca_grid_setup (CAGrid *ca, CArray *parent, ca_size_t *dim,
|
|
71
71
|
ca->obj_type = CA_OBJ_GRID;
|
72
72
|
ca->data_type = data_type;
|
73
73
|
ca->flags = 0;
|
74
|
-
ca->
|
74
|
+
ca->ndim = ndim;
|
75
75
|
ca->bytes = bytes;
|
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;
|
@@ -88,14 +88,14 @@ ca_grid_setup (CAGrid *ca, CArray *parent, ca_size_t *dim,
|
|
88
88
|
ca->contig = contig;
|
89
89
|
}
|
90
90
|
else {
|
91
|
-
ca->grid = ALLOC_N(CArray *,
|
92
|
-
ca->contig = ALLOC_N(int8_t,
|
91
|
+
ca->grid = ALLOC_N(CArray *, ndim);
|
92
|
+
ca->contig = ALLOC_N(int8_t, ndim);
|
93
93
|
}
|
94
94
|
|
95
|
-
memcpy(ca->dim, dim,
|
95
|
+
memcpy(ca->dim, dim, ndim * sizeof(ca_size_t));
|
96
96
|
|
97
97
|
if ( ! share ) {
|
98
|
-
for (i=0; i<
|
98
|
+
for (i=0; i<ndim; i++) {
|
99
99
|
if ( grid[i] ) {
|
100
100
|
if ( ca_is_any_masked(grid[i]) ) {
|
101
101
|
ca_size_t gsize = grid[i]->elements - ca_count_masked(grid[i]);
|
@@ -137,7 +137,7 @@ ca_grid_setup (CAGrid *ca, CArray *parent, ca_size_t *dim,
|
|
137
137
|
}
|
138
138
|
}
|
139
139
|
|
140
|
-
if ( ca->
|
140
|
+
if ( ca->ndim == 1 && ca_is_scalar(grid[0]) ) {
|
141
141
|
ca_set_flag(ca, CA_FLAG_SCALAR);
|
142
142
|
}
|
143
143
|
|
@@ -169,7 +169,7 @@ free_ca_grid (void *ap)
|
|
169
169
|
ca_free(ca->mask);
|
170
170
|
if ( ! (ca->flags & CA_FLAG_SHARE_INDEX)) {
|
171
171
|
xfree(ca->contig);
|
172
|
-
for (i=0; i<ca->
|
172
|
+
for (i=0; i<ca->ndim; i++) {
|
173
173
|
ca_free(ca->grid[i]);
|
174
174
|
}
|
175
175
|
xfree(ca->grid);
|
@@ -217,7 +217,7 @@ ca_grid_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
217
217
|
ca_size_t n;
|
218
218
|
|
219
219
|
n = 0;
|
220
|
-
for (i=0; i<ca->
|
220
|
+
for (i=0; i<ca->ndim; i++) {
|
221
221
|
n = dim0[i]*n + *(ca_size_t*) ca_ptr_at_addr(grid[i], idx[i]);
|
222
222
|
}
|
223
223
|
|
@@ -240,7 +240,7 @@ ca_grid_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
240
240
|
CArray **grid = ca->grid;
|
241
241
|
ca_size_t idx0[CA_RANK_MAX];
|
242
242
|
int8_t i;
|
243
|
-
for (i=0; i<ca->
|
243
|
+
for (i=0; i<ca->ndim; i++) {
|
244
244
|
ca_fetch_addr(grid[i], idx[i], &idx0[i]);
|
245
245
|
}
|
246
246
|
ca_fetch_index(ca->parent, idx0, ptr);
|
@@ -253,7 +253,7 @@ ca_grid_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
253
253
|
CArray **grid = ca->grid;
|
254
254
|
ca_size_t idx0[CA_RANK_MAX];
|
255
255
|
int8_t i;
|
256
|
-
for (i=0; i<ca->
|
256
|
+
for (i=0; i<ca->ndim; i++) {
|
257
257
|
ca_fetch_addr(grid[i], idx[i], &idx0[i]);
|
258
258
|
}
|
259
259
|
ca_store_index(ca->parent, idx0, ptr);
|
@@ -386,7 +386,7 @@ ca_grid_attach_loop (CAGrid *ca, int16_t level, ca_size_t *idx, ca_size_t *idx0)
|
|
386
386
|
CArray **grid = ca->grid;
|
387
387
|
ca_size_t i, k;
|
388
388
|
|
389
|
-
if ( level == ca->
|
389
|
+
if ( level == ca->ndim - 1 ) {
|
390
390
|
idx[level] = 0;
|
391
391
|
idx0[level] = 0;
|
392
392
|
if ( ca->contig[level] ) {
|
@@ -460,7 +460,7 @@ ca_grid_sync_loop (CAGrid *ca, int16_t level, ca_size_t *idx, ca_size_t *idx0)
|
|
460
460
|
CArray **grid = ca->grid;
|
461
461
|
ca_size_t i, k;
|
462
462
|
|
463
|
-
if ( level == ca->
|
463
|
+
if ( level == ca->ndim - 1 ) {
|
464
464
|
idx[level] = 0;
|
465
465
|
idx0[level] = 0;
|
466
466
|
if ( ca->contig[level] ) {
|
@@ -532,7 +532,7 @@ ca_grid_fill_loop (CAGrid *ca, char *ptr,
|
|
532
532
|
{
|
533
533
|
CArray **grid = ca->grid;
|
534
534
|
ca_size_t i, k;
|
535
|
-
if ( level == ca->
|
535
|
+
if ( level == ca->ndim - 1 ) {
|
536
536
|
idx0[level] = 0;
|
537
537
|
if ( ca->contig[level] ) {
|
538
538
|
char *p = ca_ptr_at_index(ca->parent, idx0);
|
@@ -624,21 +624,21 @@ rb_ca_grid (int argc, VALUE *argv, VALUE self)
|
|
624
624
|
|
625
625
|
ridx = rb_ary_new4(argc, argv);
|
626
626
|
|
627
|
-
if ( RARRAY_LEN(ridx) > ca->
|
628
|
-
rb_raise(rb_eArgError, "# of arguments doesn't equal to the
|
627
|
+
if ( RARRAY_LEN(ridx) > ca->ndim ) {
|
628
|
+
rb_raise(rb_eArgError, "# of arguments doesn't equal to the ndim");
|
629
629
|
}
|
630
|
-
else if ( RARRAY_LEN(ridx) < ca->
|
630
|
+
else if ( RARRAY_LEN(ridx) < ca->ndim ) {
|
631
631
|
volatile VALUE ref;
|
632
632
|
CArray *cv;
|
633
633
|
ca_size_t rdim[CA_RANK_MAX];
|
634
|
-
ca_size_t
|
634
|
+
ca_size_t rndim = RARRAY_LEN(ridx);
|
635
635
|
ca_size_t j = 0, k;
|
636
|
-
for (i=0; i<
|
636
|
+
for (i=0; i<rndim; i++) {
|
637
637
|
rval = rb_ary_entry(ridx, i);
|
638
638
|
if ( rb_obj_is_carray(rval) ) {
|
639
639
|
Data_Get_Struct(rval, CArray, cv);
|
640
640
|
rdim[i] = 1;
|
641
|
-
for (k=0; k<cv->
|
641
|
+
for (k=0; k<cv->ndim; k++) {
|
642
642
|
rdim[i] *= ca->dim[j];
|
643
643
|
j += 1;
|
644
644
|
}
|
@@ -648,10 +648,10 @@ rb_ca_grid (int argc, VALUE *argv, VALUE self)
|
|
648
648
|
j += 1;
|
649
649
|
}
|
650
650
|
}
|
651
|
-
if ( j != ca->
|
652
|
-
rb_raise(rb_eArgError, "invalid total
|
651
|
+
if ( j != ca->ndim ) {
|
652
|
+
rb_raise(rb_eArgError, "invalid total ndim of args");
|
653
653
|
}
|
654
|
-
ref = rb_ca_refer_new(self, ca->data_type,
|
654
|
+
ref = rb_ca_refer_new(self, ca->data_type, rndim, rdim, ca->bytes, 0);
|
655
655
|
return rb_ca_grid(argc, argv, ref);
|
656
656
|
}
|
657
657
|
|
@@ -21,7 +21,7 @@
|
|
21
21
|
typedef struct {
|
22
22
|
int16_t obj_type;
|
23
23
|
int8_t data_type;
|
24
|
-
int8_t
|
24
|
+
int8_t ndim;
|
25
25
|
int32_t flags;
|
26
26
|
ca_size_t bytes;
|
27
27
|
ca_size_t elements;
|
@@ -49,7 +49,7 @@ static VALUE rb_cCAMapping;
|
|
49
49
|
int
|
50
50
|
ca_mapping_setup (CAMapping *ca, CArray *parent, CArray *mapper, int share)
|
51
51
|
{
|
52
|
-
int8_t
|
52
|
+
int8_t ndim, data_type;
|
53
53
|
ca_size_t elements, bytes;
|
54
54
|
ca_size_t *p;
|
55
55
|
ca_size_t i;
|
@@ -66,19 +66,19 @@ ca_mapping_setup (CAMapping *ca, CArray *parent, CArray *mapper, int share)
|
|
66
66
|
ca->bytes = bytes;
|
67
67
|
ca->ptr = NULL;
|
68
68
|
|
69
|
-
|
69
|
+
ndim = mapper->ndim;
|
70
70
|
elements = mapper->elements;
|
71
71
|
|
72
|
-
ca->
|
72
|
+
ca->ndim = ndim;
|
73
73
|
ca->elements = elements;
|
74
74
|
ca->mask = NULL;
|
75
|
-
ca->dim = ALLOC_N(ca_size_t,
|
75
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
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,
|
81
|
+
memcpy(ca->dim, mapper->dim, ndim * sizeof(ca_size_t));
|
82
82
|
|
83
83
|
if ( share ) {
|
84
84
|
ca_set_flag(ca, CA_FLAG_SHARE_INDEX);
|
@@ -176,7 +176,7 @@ ca_mapping_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
176
176
|
int8_t i;
|
177
177
|
ca_size_t n;
|
178
178
|
n = idx[0];
|
179
|
-
for (i=1; i<ca->
|
179
|
+
for (i=1; i<ca->ndim; i++) {
|
180
180
|
n = dim[i]*n+idx[i];
|
181
181
|
}
|
182
182
|
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
@@ -200,7 +200,7 @@ ca_mapping_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
200
200
|
int8_t i;
|
201
201
|
ca_size_t n;
|
202
202
|
n = idx[0];
|
203
|
-
for (i=1; i<ca->
|
203
|
+
for (i=1; i<ca->ndim; i++) {
|
204
204
|
n = dim[i]*n+idx[i];
|
205
205
|
}
|
206
206
|
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
@@ -215,7 +215,7 @@ ca_mapping_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
215
215
|
int8_t i;
|
216
216
|
ca_size_t n;
|
217
217
|
n = idx[0];
|
218
|
-
for (i=1; i<ca->
|
218
|
+
for (i=1; i<ca->ndim; i++) {
|
219
219
|
n = dim[i]*n+idx[i];
|
220
220
|
}
|
221
221
|
n = *(ca_size_t*) ca_ptr_at_addr(ca->mapper, n);
|
@@ -59,10 +59,10 @@ static VALUE rb_cCAObjectMask;
|
|
59
59
|
|
60
60
|
|
61
61
|
static CAObjectMask *
|
62
|
-
ca_objmask_new (VALUE array, int8_t
|
62
|
+
ca_objmask_new (VALUE array, int8_t ndim, ca_size_t *dim)
|
63
63
|
{
|
64
64
|
CAObjectMask *ca = ALLOC(CAObjectMask);
|
65
|
-
ca_wrap_setup_null((CArray *)ca, CA_BOOLEAN,
|
65
|
+
ca_wrap_setup_null((CArray *)ca, CA_BOOLEAN, ndim, dim, 0, NULL);
|
66
66
|
ca->obj_type = CA_OBJ_OBJECT_MASK;
|
67
67
|
ca->array = array;
|
68
68
|
|
@@ -81,7 +81,7 @@ static void *
|
|
81
81
|
ca_objmask_func_clone (void *ap)
|
82
82
|
{
|
83
83
|
CAObjectMask *ca = (CAObjectMask *) ap;
|
84
|
-
return ca_objmask_new(ca->array, ca->
|
84
|
+
return ca_objmask_new(ca->array, ca->ndim, ca->dim);
|
85
85
|
}
|
86
86
|
|
87
87
|
void
|
@@ -100,8 +100,8 @@ ca_objmask_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
|
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
|
-
ridx = rb_ary_new2(ca->
|
104
|
-
for (i=0; i<ca->
|
103
|
+
ridx = rb_ary_new2(ca->ndim);
|
104
|
+
for (i=0; i<ca->ndim; i++) {
|
105
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);
|
@@ -121,8 +121,8 @@ ca_objmask_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
121
121
|
int i;
|
122
122
|
|
123
123
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_fetch_index"), Qtrue) ) {
|
124
|
-
ridx = rb_ary_new2(ca->
|
125
|
-
for (i=0; i<ca->
|
124
|
+
ridx = rb_ary_new2(ca->ndim);
|
125
|
+
for (i=0; i<ca->ndim; i++) {
|
126
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);
|
@@ -158,8 +158,8 @@ ca_objmask_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
|
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
|
-
ridx = rb_ary_new2(ca->
|
162
|
-
for (i=0; i<ca->
|
161
|
+
ridx = rb_ary_new2(ca->ndim);
|
162
|
+
for (i=0; i<ca->ndim; i++) {
|
163
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);
|
@@ -177,8 +177,8 @@ ca_objmask_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
177
177
|
rval = INT2NUM( *(uint8_t*)ptr );
|
178
178
|
|
179
179
|
if ( rb_obj_respond_to(ca->array, rb_intern("mask_store_index"), Qtrue) ) {
|
180
|
-
ridx = rb_ary_new2(ca->
|
181
|
-
for (i=0; i<ca->
|
180
|
+
ridx = rb_ary_new2(ca->ndim);
|
181
|
+
for (i=0; i<ca->ndim; i++) {
|
182
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);
|
@@ -290,7 +290,7 @@ rb_ca_objmask_initialize_copy (VALUE self, VALUE other)
|
|
290
290
|
Data_Get_Struct(self, CAObjectMask, ca);
|
291
291
|
Data_Get_Struct(other, CAObjectMask, cs);
|
292
292
|
|
293
|
-
carray_setup((CArray *)ca, CA_BOOLEAN, cs->
|
293
|
+
carray_setup((CArray *)ca, CA_BOOLEAN, cs->ndim, cs->dim, 0, NULL);
|
294
294
|
ca->obj_type = CA_OBJ_OBJECT_MASK;
|
295
295
|
ca->array = cs->array;
|
296
296
|
|
@@ -301,7 +301,7 @@ 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
|
304
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes)
|
305
305
|
{
|
306
306
|
ca_size_t elements;
|
307
307
|
double length;
|
@@ -310,15 +310,15 @@ ca_object_setup (CAObject *ca,
|
|
310
310
|
/* check arguments */
|
311
311
|
|
312
312
|
CA_CHECK_DATA_TYPE(data_type);
|
313
|
-
CA_CHECK_RANK(
|
314
|
-
CA_CHECK_DIM(
|
313
|
+
CA_CHECK_RANK(ndim);
|
314
|
+
CA_CHECK_DIM(ndim, dim);
|
315
315
|
CA_CHECK_BYTES(data_type, bytes);
|
316
316
|
|
317
317
|
/* calculate total number of elements */
|
318
318
|
|
319
319
|
elements = 1;
|
320
320
|
length = bytes;
|
321
|
-
for (i=0; i<
|
321
|
+
for (i=0; i<ndim; i++) {
|
322
322
|
elements *= dim[i];
|
323
323
|
length *= dim[i];
|
324
324
|
}
|
@@ -330,7 +330,7 @@ ca_object_setup (CAObject *ca,
|
|
330
330
|
ca->obj_type = CA_OBJ_OBJECT;
|
331
331
|
ca->data_type = data_type;
|
332
332
|
ca->flags = 0;
|
333
|
-
ca->
|
333
|
+
ca->ndim = ndim;
|
334
334
|
ca->bytes = bytes;
|
335
335
|
ca->elements = elements;
|
336
336
|
ca->ptr = NULL;
|
@@ -339,20 +339,20 @@ ca_object_setup (CAObject *ca,
|
|
339
339
|
ca->attach = 0;
|
340
340
|
ca->nosync = 0;
|
341
341
|
|
342
|
-
ca->dim = ALLOC_N(ca_size_t,
|
342
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
343
343
|
|
344
|
-
ca->data = ca_wrap_new_null(data_type,
|
344
|
+
ca->data = ca_wrap_new_null(data_type, ndim, dim, bytes, NULL);
|
345
345
|
|
346
|
-
memcpy(ca->dim, dim,
|
346
|
+
memcpy(ca->dim, dim, ndim * 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
|
352
|
+
ca_object_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes)
|
353
353
|
{
|
354
354
|
CAObject *ca = ALLOC(CAObject);
|
355
|
-
ca_object_setup(ca, data_type,
|
355
|
+
ca_object_setup(ca, data_type, ndim, dim, bytes);
|
356
356
|
return ca;
|
357
357
|
}
|
358
358
|
|
@@ -373,7 +373,7 @@ static void *
|
|
373
373
|
ca_object_func_clone (void *ap)
|
374
374
|
{
|
375
375
|
CAObject *ca = (CAObject *) ap;
|
376
|
-
return ca_object_new(ca->bytes, ca->
|
376
|
+
return ca_object_new(ca->bytes, ca->ndim, ca->dim, ca->bytes);
|
377
377
|
}
|
378
378
|
|
379
379
|
#define ca_object_func_ptr_at_addr ca_array_func_ptr_at_addr
|
@@ -408,8 +408,8 @@ ca_object_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
|
408
408
|
else {
|
409
409
|
ca_size_t idx[CA_RANK_MAX];
|
410
410
|
ca_addr2index(ca, addr, idx);
|
411
|
-
ridx = rb_ary_new2(ca->
|
412
|
-
for (i=0; i<ca->
|
411
|
+
ridx = rb_ary_new2(ca->ndim);
|
412
|
+
for (i=0; i<ca->ndim; i++) {
|
413
413
|
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
414
414
|
}
|
415
415
|
rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
|
@@ -439,8 +439,8 @@ ca_object_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
439
439
|
volatile VALUE ridx, raddr, rval;
|
440
440
|
int i;
|
441
441
|
if ( rb_obj_respond_to(ca->self, rb_intern("fetch_index"), Qtrue) ) {
|
442
|
-
ridx = rb_ary_new2(ca->
|
443
|
-
for (i=0; i<ca->
|
442
|
+
ridx = rb_ary_new2(ca->ndim);
|
443
|
+
for (i=0; i<ca->ndim; i++) {
|
444
444
|
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
445
445
|
}
|
446
446
|
rval = rb_funcall(ca->self, rb_intern("fetch_index"), 1, ridx);
|
@@ -498,8 +498,8 @@ ca_object_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
|
498
498
|
else {
|
499
499
|
ca_size_t idx[CA_RANK_MAX];
|
500
500
|
ca_addr2index(ca, addr, idx);
|
501
|
-
ridx = rb_ary_new2(ca->
|
502
|
-
for (i=0; i<ca->
|
501
|
+
ridx = rb_ary_new2(ca->ndim);
|
502
|
+
for (i=0; i<ca->ndim; i++) {
|
503
503
|
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
504
504
|
}
|
505
505
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
@@ -514,8 +514,8 @@ ca_object_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
514
514
|
volatile VALUE ridx, raddr, rval;
|
515
515
|
int i;
|
516
516
|
if ( rb_obj_respond_to(ca->self, rb_intern("store_index"), Qtrue) ) {
|
517
|
-
ridx = rb_ary_new2(ca->
|
518
|
-
for (i=0; i<ca->
|
517
|
+
ridx = rb_ary_new2(ca->ndim);
|
518
|
+
for (i=0; i<ca->ndim; i++) {
|
519
519
|
rb_ary_store(ridx, i, SIZE2NUM(idx[i]));
|
520
520
|
}
|
521
521
|
rval = rb_ca_ptr2obj(ca->self, ptr);
|
@@ -634,7 +634,7 @@ ca_object_func_create_mask (void *ap)
|
|
634
634
|
if ( ! ca->data->mask ) {
|
635
635
|
ca_create_mask(ca->data);
|
636
636
|
}
|
637
|
-
ca->mask = (CArray*) ca_objmask_new(ca->self, ca->
|
637
|
+
ca->mask = (CArray*) ca_objmask_new(ca->self, ca->ndim, ca->dim);
|
638
638
|
ca->mask->ptr = ca->data->mask->ptr;
|
639
639
|
rmask = ca_wrap_struct(ca->mask);
|
640
640
|
rb_ivar_set(ca->self, rb_intern("mask"), rmask);
|
@@ -679,7 +679,7 @@ rb_ca_object_initialize_copy (VALUE self, VALUE other)
|
|
679
679
|
Data_Get_Struct(self, CAObject, ca);
|
680
680
|
Data_Get_Struct(other, CAObject, cs);
|
681
681
|
|
682
|
-
ca_object_setup(ca, cs->data_type, cs->
|
682
|
+
ca_object_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes);
|
683
683
|
ca->self = self;
|
684
684
|
|
685
685
|
rb_ca_data_type_inherit(self, other);
|
@@ -703,7 +703,7 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
|
|
703
703
|
{
|
704
704
|
volatile VALUE rtype, rdim, ropt, rbytes = Qnil, rrdonly = Qnil, rparent = Qnil, rdata;
|
705
705
|
CAObject *ca;
|
706
|
-
int8_t data_type,
|
706
|
+
int8_t data_type, ndim;
|
707
707
|
ca_size_t dim[CA_RANK_MAX];
|
708
708
|
ca_size_t bytes;
|
709
709
|
int i;
|
@@ -721,13 +721,13 @@ rb_ca_object_initialize (int argc, VALUE *argv, VALUE self)
|
|
721
721
|
|
722
722
|
Check_Type(rdim, T_ARRAY);
|
723
723
|
|
724
|
-
|
725
|
-
for (i=0; i<
|
724
|
+
ndim = RARRAY_LEN(rdim);
|
725
|
+
for (i=0; i<ndim; i++) {
|
726
726
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
727
727
|
}
|
728
728
|
|
729
729
|
Data_Get_Struct(self, CAObject, ca);
|
730
|
-
ca_object_setup(ca, data_type,
|
730
|
+
ca_object_setup(ca, data_type, ndim, dim, bytes);
|
731
731
|
ca->self = self;
|
732
732
|
|
733
733
|
rdata = ca_wrap_struct(ca->data);
|