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
@@ -29,18 +29,18 @@ 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
|
-
int8_t data_type,
|
32
|
+
int8_t data_type, ndim;
|
33
33
|
ca_size_t *dim;
|
34
34
|
ca_size_t bytes, elements;
|
35
35
|
int i;
|
36
36
|
|
37
37
|
data_type = parent->data_type;
|
38
|
-
|
38
|
+
ndim = parent->ndim;
|
39
39
|
bytes = parent->bytes;
|
40
40
|
dim = parent->dim;
|
41
41
|
|
42
42
|
elements = 1;
|
43
|
-
for (i=0; i<
|
43
|
+
for (i=0; i<ndim; i++) {
|
44
44
|
if ( count[i] <= 0 ) {
|
45
45
|
rb_raise(rb_eIndexError,
|
46
46
|
"invalid size for %i-th dimension (negative or zero)", i);
|
@@ -51,7 +51,7 @@ ca_window_setup (CAWindow *ca, CArray *parent,
|
|
51
51
|
ca->obj_type = CA_OBJ_WINDOW;
|
52
52
|
ca->data_type = data_type;
|
53
53
|
ca->flags = 0;
|
54
|
-
ca->
|
54
|
+
ca->ndim = ndim;
|
55
55
|
ca->bytes = bytes;
|
56
56
|
ca->elements = elements;
|
57
57
|
ca->ptr = NULL;
|
@@ -62,16 +62,16 @@ 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(ca_size_t,
|
66
|
-
ca->count = ALLOC_N(ca_size_t,
|
67
|
-
ca->size0 = ALLOC_N(ca_size_t,
|
65
|
+
ca->start = ALLOC_N(ca_size_t, ndim);
|
66
|
+
ca->count = ALLOC_N(ca_size_t, ndim);
|
67
|
+
ca->size0 = ALLOC_N(ca_size_t, ndim);
|
68
68
|
ca->fill = ALLOC_N(char, ca->bytes);
|
69
69
|
|
70
70
|
ca->dim = ca->count;
|
71
71
|
|
72
|
-
memcpy(ca->start, start,
|
73
|
-
memcpy(ca->count, count,
|
74
|
-
memcpy(ca->size0, dim,
|
72
|
+
memcpy(ca->start, start, ndim * sizeof(ca_size_t));
|
73
|
+
memcpy(ca->count, count, ndim * sizeof(ca_size_t));
|
74
|
+
memcpy(ca->size0, dim, ndim * sizeof(ca_size_t));
|
75
75
|
|
76
76
|
if ( fill ) {
|
77
77
|
memcpy(ca->fill, fill, ca->bytes);
|
@@ -157,7 +157,7 @@ ca_window_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
157
157
|
int8_t i;
|
158
158
|
ca_size_t n;
|
159
159
|
n = 0;
|
160
|
-
for (i=0; i<ca->
|
160
|
+
for (i=0; i<ca->ndim; i++) {
|
161
161
|
k = start[i] + idx[i];
|
162
162
|
k = ca_bounds_normalize_index(ca->bounds, size0[i], k);
|
163
163
|
if ( k < 0 || k >= size0[i] ) {
|
@@ -187,7 +187,7 @@ ca_window_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
187
187
|
ca_size_t idx0[CA_RANK_MAX];
|
188
188
|
int8_t i;
|
189
189
|
ca_size_t k;
|
190
|
-
for (i=0; i<ca->
|
190
|
+
for (i=0; i<ca->ndim; i++) {
|
191
191
|
k = start[i] + idx[i];
|
192
192
|
k = ca_bounds_normalize_index(ca->bounds, size0[i], k);
|
193
193
|
if ( k < 0 || k >= size0[i] ) {
|
@@ -208,7 +208,7 @@ ca_window_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
208
208
|
ca_size_t idx0[CA_RANK_MAX];
|
209
209
|
int8_t i;
|
210
210
|
ca_size_t k;
|
211
|
-
for (i=0; i<ca->
|
211
|
+
for (i=0; i<ca->ndim; i++) {
|
212
212
|
k = start[i] + idx[i];
|
213
213
|
k = ca_bounds_normalize_index(ca->bounds, size0[i], k);
|
214
214
|
if ( k < 0 || k >= size0[i] ) {
|
@@ -397,7 +397,7 @@ ca_window_attach_loop (CAWindow *cb, int8_t level,
|
|
397
397
|
ca_size_t count = cb->count[level];
|
398
398
|
ca_size_t i, k;
|
399
399
|
|
400
|
-
if ( level == cb->
|
400
|
+
if ( level == cb->ndim - 1 ) {
|
401
401
|
switch ( cb->data_type ) {
|
402
402
|
case CA_BOOLEAN:
|
403
403
|
case CA_INT8: proc_window_attach_get(int8_t); break;
|
@@ -525,7 +525,7 @@ ca_window_sync_loop (CAWindow *cb, int8_t level,
|
|
525
525
|
ca_size_t size0 = cb->size0[level];
|
526
526
|
ca_size_t i, k;
|
527
527
|
|
528
|
-
if ( level == cb->
|
528
|
+
if ( level == cb->ndim - 1 ) {
|
529
529
|
switch ( cb->data_type ) {
|
530
530
|
case CA_BOOLEAN:
|
531
531
|
case CA_INT8: proc_window_sync_set(int8_t); break;
|
@@ -629,7 +629,7 @@ ca_window_fill_loop (CAWindow *cb, char *ptr,
|
|
629
629
|
ca_size_t size0 = cb->size0[level];
|
630
630
|
ca_size_t i, k;
|
631
631
|
|
632
|
-
if ( level == cb->
|
632
|
+
if ( level == cb->ndim - 1 ) {
|
633
633
|
switch ( cb->data_type ) {
|
634
634
|
case CA_BOOLEAN:
|
635
635
|
case CA_INT8: proc_window_fill_set(int8_t); break;
|
@@ -728,8 +728,8 @@ rb_ca_window (int argc, VALUE *argv, VALUE self)
|
|
728
728
|
ropt = rb_pop_options(&argc, &argv);
|
729
729
|
rb_scan_options(ropt, "bounds,fill_value", &rbounds, &rfval);
|
730
730
|
|
731
|
-
if ( argc != ca->
|
732
|
-
rb_raise(rb_eArgError, "
|
731
|
+
if ( argc != ca->ndim ) {
|
732
|
+
rb_raise(rb_eArgError, "ndim mismatch");
|
733
733
|
}
|
734
734
|
|
735
735
|
for (i=0; i<argc; i++) {
|
@@ -854,13 +854,13 @@ rb_ca_window_idx2addr0 (int argc, VALUE *argv, VALUE self)
|
|
854
854
|
|
855
855
|
Data_Get_Struct(self, CAWindow, cw);
|
856
856
|
|
857
|
-
if ( argc != cw->
|
857
|
+
if ( argc != cw->ndim ) {
|
858
858
|
rb_raise(rb_eArgError,
|
859
|
-
"invalid # of arguments (should be <%i>)", cw->
|
859
|
+
"invalid # of arguments (should be <%i>)", cw->ndim);
|
860
860
|
}
|
861
861
|
|
862
862
|
addr = 0;
|
863
|
-
for (i=0; i<cw->
|
863
|
+
for (i=0; i<cw->ndim; i++) {
|
864
864
|
idxi = NUM2SIZE(argv[i]);
|
865
865
|
CA_CHECK_INDEX(idxi, cw->dim[i]);
|
866
866
|
addr = cw->size0[i] * addr + cw->start[i] + idxi;
|
@@ -894,7 +894,7 @@ rb_ca_window_addr2addr0 (VALUE self, VALUE raddr)
|
|
894
894
|
ca_addr2index((CArray*)cw, addr, idx);
|
895
895
|
|
896
896
|
addr = 0;
|
897
|
-
for (i=0; i<cw->
|
897
|
+
for (i=0; i<cw->ndim; i++) {
|
898
898
|
addr *= cw->size0[i];
|
899
899
|
addr += cw->start[i] + idx[i];
|
900
900
|
}
|
@@ -912,12 +912,12 @@ rb_ca_window_move (int argc, VALUE *argv, VALUE self)
|
|
912
912
|
|
913
913
|
Data_Get_Struct(self, CAWindow, cw);
|
914
914
|
|
915
|
-
if ( argc != cw->
|
915
|
+
if ( argc != cw->ndim ) {
|
916
916
|
rb_raise(rb_eArgError, "invalid # of arguments");
|
917
917
|
}
|
918
918
|
|
919
919
|
ca_update_mask(cw);
|
920
|
-
for (i=0; i<cw->
|
920
|
+
for (i=0; i<cw->ndim; i++) {
|
921
921
|
start = NUM2SIZE(argv[i]);
|
922
922
|
cw->start[i] = start;
|
923
923
|
if ( cw->mask ) {
|
@@ -969,8 +969,8 @@ rb_ca_window_get_bounds (VALUE self)
|
|
969
969
|
CAWindow *cw; \
|
970
970
|
int8_t i; \
|
971
971
|
Data_Get_Struct(self, CAWindow, cw); \
|
972
|
-
ary = rb_ary_new2(cw->
|
973
|
-
for (i=0; i<cw->
|
972
|
+
ary = rb_ary_new2(cw->ndim); \
|
973
|
+
for (i=0; i<cw->ndim; i++) { \
|
974
974
|
rb_ary_store(ary, i, SIZE2NUM(cw->name[i])); \
|
975
975
|
} \
|
976
976
|
return ary; \
|
data/{carray.h → ext/carray.h}
RENAMED
@@ -198,7 +198,8 @@ typedef int8_t boolean8_t;
|
|
198
198
|
/* -------------------------------------------------------------------- */
|
199
199
|
|
200
200
|
#define CA_OBJ_TYPE_MAX 256
|
201
|
-
#define
|
201
|
+
#define CA_DIM_MAX 16
|
202
|
+
#define CA_RANK_MAX CA_DIM_MAX
|
202
203
|
#define CA_ATTACH_MAX 0x80000000
|
203
204
|
|
204
205
|
#define CA_FLAG_SCALAR 1
|
@@ -337,21 +338,21 @@ typedef struct _CArray CArray;
|
|
337
338
|
struct _CArray {
|
338
339
|
int16_t obj_type;
|
339
340
|
int8_t data_type;
|
340
|
-
int8_t
|
341
|
+
int8_t ndim;
|
341
342
|
int32_t flags;
|
342
343
|
ca_size_t bytes;
|
343
344
|
ca_size_t elements;
|
344
345
|
ca_size_t *dim;
|
345
346
|
char *ptr;
|
346
347
|
CArray *mask;
|
347
|
-
}; /* 28 + 4*
|
348
|
+
}; /* 28 + 4*ndim (bytes) */
|
348
349
|
|
349
350
|
typedef CArray CAWrap;
|
350
351
|
|
351
352
|
typedef struct {
|
352
353
|
int16_t obj_type;
|
353
354
|
int8_t data_type;
|
354
|
-
int8_t
|
355
|
+
int8_t ndim;
|
355
356
|
int32_t flags;
|
356
357
|
ca_size_t bytes;
|
357
358
|
ca_size_t elements;
|
@@ -364,7 +365,7 @@ typedef struct {
|
|
364
365
|
typedef struct {
|
365
366
|
int16_t obj_type;
|
366
367
|
int8_t data_type;
|
367
|
-
int8_t
|
368
|
+
int8_t ndim;
|
368
369
|
int32_t flags;
|
369
370
|
ca_size_t bytes;
|
370
371
|
ca_size_t elements;
|
@@ -374,12 +375,12 @@ typedef struct {
|
|
374
375
|
CArray *parent;
|
375
376
|
uint32_t attach;
|
376
377
|
uint8_t nosync;
|
377
|
-
} CAVirtual; /* 40 + 4*(
|
378
|
+
} CAVirtual; /* 40 + 4*(ndim) (bytes) */
|
378
379
|
|
379
380
|
typedef struct {
|
380
381
|
int16_t obj_type;
|
381
382
|
int8_t data_type;
|
382
|
-
int8_t
|
383
|
+
int8_t ndim;
|
383
384
|
int32_t flags;
|
384
385
|
ca_size_t bytes;
|
385
386
|
ca_size_t elements;
|
@@ -397,12 +398,12 @@ typedef struct {
|
|
397
398
|
ca_size_t ratio;
|
398
399
|
ca_size_t offset;
|
399
400
|
CArray *mask0;
|
400
|
-
} CARefer; /* 52 + 4*(
|
401
|
+
} CARefer; /* 52 + 4*(ndim) (bytes) */
|
401
402
|
|
402
403
|
typedef struct {
|
403
404
|
int16_t obj_type;
|
404
405
|
int8_t data_type;
|
405
|
-
int8_t
|
406
|
+
int8_t ndim;
|
406
407
|
int32_t flags;
|
407
408
|
ca_size_t bytes;
|
408
409
|
ca_size_t elements;
|
@@ -421,12 +422,12 @@ typedef struct {
|
|
421
422
|
ca_size_t *step;
|
422
423
|
ca_size_t *count;
|
423
424
|
ca_size_t *size0;
|
424
|
-
} CABlock; /* 68 + 20*(
|
425
|
+
} CABlock; /* 68 + 20*(ndim) (bytes) */
|
425
426
|
|
426
427
|
typedef struct {
|
427
428
|
int16_t obj_type;
|
428
429
|
int8_t data_type;
|
429
|
-
int8_t
|
430
|
+
int8_t ndim;
|
430
431
|
int32_t flags;
|
431
432
|
ca_size_t bytes;
|
432
433
|
ca_size_t elements;
|
@@ -442,12 +443,12 @@ typedef struct {
|
|
442
443
|
ca_size_t *count;
|
443
444
|
ca_size_t *size0;
|
444
445
|
char *fill;
|
445
|
-
} CAWindow; /* 56 + 16*(
|
446
|
+
} CAWindow; /* 56 + 16*(ndim) + 1*(bytes) (bytes) */
|
446
447
|
|
447
448
|
typedef struct {
|
448
449
|
int16_t obj_type;
|
449
450
|
int8_t data_type;
|
450
|
-
int8_t
|
451
|
+
int8_t ndim;
|
451
452
|
int32_t flags;
|
452
453
|
ca_size_t bytes;
|
453
454
|
ca_size_t elements;
|
@@ -460,7 +461,7 @@ typedef struct {
|
|
460
461
|
/* -------------*/
|
461
462
|
CArray *data;
|
462
463
|
VALUE self;
|
463
|
-
} CAObject; /* 48 + 4*(
|
464
|
+
} CAObject; /* 48 + 4*(ndim) (bytes) */
|
464
465
|
|
465
466
|
/*
|
466
467
|
CAObjectMask is an internal class
|
@@ -470,7 +471,7 @@ typedef struct {
|
|
470
471
|
typedef struct {
|
471
472
|
int16_t obj_type;
|
472
473
|
int8_t data_type;
|
473
|
-
int8_t
|
474
|
+
int8_t ndim;
|
474
475
|
int32_t flags;
|
475
476
|
ca_size_t bytes;
|
476
477
|
ca_size_t elements;
|
@@ -484,7 +485,7 @@ typedef struct {
|
|
484
485
|
typedef struct {
|
485
486
|
int16_t obj_type;
|
486
487
|
int8_t data_type;
|
487
|
-
int8_t
|
488
|
+
int8_t ndim;
|
488
489
|
int32_t flags;
|
489
490
|
ca_size_t bytes;
|
490
491
|
ca_size_t elements;
|
@@ -500,12 +501,12 @@ typedef struct {
|
|
500
501
|
ca_size_t repeat_num;
|
501
502
|
ca_size_t contig_level;
|
502
503
|
ca_size_t contig_num;
|
503
|
-
} CARepeat; /* 60 + 8*(
|
504
|
+
} CARepeat; /* 60 + 8*(ndim) (bytes) */
|
504
505
|
|
505
506
|
typedef struct {
|
506
507
|
int16_t obj_type;
|
507
508
|
int8_t data_type;
|
508
|
-
int8_t
|
509
|
+
int8_t ndim;
|
509
510
|
int32_t flags;
|
510
511
|
ca_size_t bytes;
|
511
512
|
ca_size_t elements;
|
@@ -516,9 +517,9 @@ typedef struct {
|
|
516
517
|
uint32_t attach;
|
517
518
|
uint8_t nosync;
|
518
519
|
/* -------------*/
|
519
|
-
int8_t
|
520
|
+
int8_t rep_ndim;
|
520
521
|
ca_size_t *rep_dim;
|
521
|
-
} CAUnboundRepeat; /* 44 + 8*(
|
522
|
+
} CAUnboundRepeat; /* 44 + 8*(ndim) (bytes) */
|
522
523
|
|
523
524
|
/*
|
524
525
|
CAReduce is an internal class
|
@@ -528,7 +529,7 @@ typedef struct {
|
|
528
529
|
typedef struct {
|
529
530
|
int16_t obj_type;
|
530
531
|
int8_t data_type;
|
531
|
-
int8_t
|
532
|
+
int8_t ndim;
|
532
533
|
int32_t flags;
|
533
534
|
ca_size_t bytes;
|
534
535
|
ca_size_t elements;
|
@@ -546,7 +547,7 @@ typedef struct {
|
|
546
547
|
/* -------------------------------------------------------------------- */
|
547
548
|
|
548
549
|
typedef struct {
|
549
|
-
int8_t
|
550
|
+
int8_t ndim;
|
550
551
|
ca_size_t dim[CA_RANK_MAX];
|
551
552
|
CArray *reference;
|
552
553
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -573,6 +574,23 @@ extern VALUE rb_mCA;
|
|
573
574
|
extern VALUE rb_mCAMath;
|
574
575
|
extern VALUE rb_eCADataTypeError;
|
575
576
|
|
577
|
+
extern VALUE rb_cCArrayBoolean;
|
578
|
+
extern VALUE rb_cCArrayUInt8;
|
579
|
+
extern VALUE rb_cCArrayUInt16;
|
580
|
+
extern VALUE rb_cCArrayUInt32;
|
581
|
+
extern VALUE rb_cCArrayUInt64;
|
582
|
+
extern VALUE rb_cCArrayInt8;
|
583
|
+
extern VALUE rb_cCArrayInt16;
|
584
|
+
extern VALUE rb_cCArrayInt32;
|
585
|
+
extern VALUE rb_cCArrayInt64;
|
586
|
+
extern VALUE rb_cCArrayFloat32;
|
587
|
+
extern VALUE rb_cCArrayFloat64;
|
588
|
+
extern VALUE rb_cCArrayFloat128;
|
589
|
+
extern VALUE rb_cCArrayCmplx64;
|
590
|
+
extern VALUE rb_cCArrayCmplx128;
|
591
|
+
extern VALUE rb_cCArrayCmplx256;
|
592
|
+
extern VALUE rb_cCArrayObject;
|
593
|
+
|
576
594
|
/* -------------------------------------------------------------------- */
|
577
595
|
|
578
596
|
extern const int ca_endian;
|
@@ -607,15 +625,15 @@ extern int ca_obj_num;
|
|
607
625
|
rb_raise(rb_eRuntimeError, "invalid numeric data type"); \
|
608
626
|
}
|
609
627
|
|
610
|
-
#define CA_CHECK_RANK(
|
611
|
-
if (
|
612
|
-
rb_raise(rb_eRuntimeError, "invalid
|
628
|
+
#define CA_CHECK_RANK(ndim) \
|
629
|
+
if ( ndim <= 0 || ndim > CA_RANK_MAX ) { \
|
630
|
+
rb_raise(rb_eRuntimeError, "invalid ndim"); \
|
613
631
|
}
|
614
632
|
|
615
|
-
#define CA_CHECK_DIM(
|
633
|
+
#define CA_CHECK_DIM(ndim, dim) \
|
616
634
|
{ \
|
617
635
|
int8_t i_; \
|
618
|
-
for (i_=0; i_<
|
636
|
+
for (i_=0; i_<ndim; i_++) { \
|
619
637
|
if ( dim[i_] < 0 ) { \
|
620
638
|
rb_raise(rb_eRuntimeError, "negative size dimension at %i-dim", i_); \
|
621
639
|
} \
|
@@ -646,7 +664,7 @@ extern int ca_obj_num;
|
|
646
664
|
#define CA_CHECK_BOUND(ca, idx) \
|
647
665
|
{ \
|
648
666
|
int8_t i; \
|
649
|
-
for (i=0; i<ca->
|
667
|
+
for (i=0; i<ca->ndim; i++) { \
|
650
668
|
if ( idx[i] < 0 || idx[i] >= ca->dim[i] ) { \
|
651
669
|
rb_raise(rb_eRuntimeError, "index out of range at %i-dim ( %i <=> 0..%i )", i, idx[i], ca->dim[i]-1); \
|
652
670
|
} \
|
@@ -710,6 +728,7 @@ enum {
|
|
710
728
|
CA_REG_METHOD_CALL,
|
711
729
|
CA_REG_UNBOUND_REPEAT,
|
712
730
|
CA_REG_MEMBER,
|
731
|
+
CA_REG_ATTRIBUTE,
|
713
732
|
}; /* CA_REGION_TYPE */
|
714
733
|
|
715
734
|
enum {
|
@@ -735,7 +754,7 @@ typedef union {
|
|
735
754
|
|
736
755
|
typedef struct {
|
737
756
|
int16_t type;
|
738
|
-
int16_t
|
757
|
+
int16_t ndim;
|
739
758
|
int32_t index_type[CA_RANK_MAX];
|
740
759
|
CAIndex index[CA_RANK_MAX];
|
741
760
|
CArray *select;
|
@@ -777,35 +796,35 @@ VALUE ca_math_call (VALUE mod, VALUE arg, ID id);
|
|
777
796
|
/* --- ca_obj_array.c --- */
|
778
797
|
|
779
798
|
int carray_setup (CArray *ca,
|
780
|
-
int8_t data_type, int8_t
|
799
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim,
|
781
800
|
ca_size_t bytes, CArray *mask);
|
782
801
|
|
783
802
|
int carray_safe_setup (CArray *ca,
|
784
|
-
int8_t data_type, int8_t
|
803
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim,
|
785
804
|
ca_size_t bytes, CArray *mask);
|
786
805
|
|
787
806
|
int ca_wrap_setup_null (CArray *ca,
|
788
|
-
int8_t data_type, int8_t
|
807
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim,
|
789
808
|
ca_size_t bytes, CArray *mask);
|
790
809
|
|
791
810
|
void free_carray (void *ap);
|
792
811
|
void free_ca_wrap (void *ap);
|
793
812
|
|
794
813
|
CArray *carray_new (int8_t data_type,
|
795
|
-
int8_t
|
814
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *ma);
|
796
815
|
CArray *carray_new_safe (int8_t data_type,
|
797
|
-
int8_t
|
816
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask);
|
798
817
|
VALUE rb_carray_new (int8_t data_type,
|
799
|
-
int8_t
|
818
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask);
|
800
819
|
VALUE rb_carray_new_safe (int8_t data_type,
|
801
|
-
int8_t
|
820
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask);
|
802
821
|
|
803
822
|
CAWrap *ca_wrap_new (int8_t data_type,
|
804
|
-
int8_t
|
823
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
805
824
|
CArray *mask, char *ptr);
|
806
825
|
|
807
826
|
CAWrap *ca_wrap_new_null (int8_t data_type,
|
808
|
-
int8_t
|
827
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
809
828
|
CArray *mask);
|
810
829
|
|
811
830
|
CScalar *cscalar_new (int8_t data_type, ca_size_t bytes, CArray *ma);
|
@@ -816,10 +835,10 @@ VALUE rb_cscalar_new_with_value (int8_t data_type, ca_size_t bytes, VALUE rva
|
|
816
835
|
/* --- ca_obj_refer.c --- */
|
817
836
|
|
818
837
|
CARefer *ca_refer_new (CArray *ca,
|
819
|
-
int8_t data_type, int8_t
|
838
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim,
|
820
839
|
ca_size_t bytes, ca_size_t offset);
|
821
840
|
VALUE rb_ca_refer_new (VALUE self,
|
822
|
-
int8_t data_type, int8_t
|
841
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim,
|
823
842
|
ca_size_t bytes, ca_size_t offset);
|
824
843
|
|
825
844
|
/* --- ca_obj_farray.c --- */
|
@@ -829,10 +848,10 @@ VALUE rb_ca_farray (VALUE self);
|
|
829
848
|
/* --- ca_obj_block.c --- */
|
830
849
|
|
831
850
|
CABlock *ca_block_new (CArray *carray,
|
832
|
-
int8_t
|
851
|
+
int8_t ndim, ca_size_t *dim,
|
833
852
|
ca_size_t *start, ca_size_t *step, ca_size_t *count,
|
834
853
|
ca_size_t offset);
|
835
|
-
VALUE rb_ca_block_new (VALUE cary, int8_t
|
854
|
+
VALUE rb_ca_block_new (VALUE cary, int8_t ndim, ca_size_t *dim,
|
836
855
|
ca_size_t *start, ca_size_t *step, ca_size_t *count,
|
837
856
|
ca_size_t offset);
|
838
857
|
|
@@ -864,12 +883,12 @@ VALUE rb_ca_fake_type (VALUE self, VALUE rtype, VALUE rbytes);
|
|
864
883
|
|
865
884
|
/* --- ca_obj_repeat.c --- */
|
866
885
|
|
867
|
-
CARepeat *ca_repeat_new (CArray *carray, int8_t
|
886
|
+
CARepeat *ca_repeat_new (CArray *carray, int8_t ndim, ca_size_t *count);
|
868
887
|
|
869
|
-
VALUE rb_ca_repeat_new (VALUE cary, int8_t
|
888
|
+
VALUE rb_ca_repeat_new (VALUE cary, int8_t ndim, ca_size_t *count);
|
870
889
|
VALUE rb_ca_repeat (int argc, VALUE *argv, VALUE self);
|
871
890
|
|
872
|
-
VALUE rb_ca_ubrep_new (VALUE cary, int32_t
|
891
|
+
VALUE rb_ca_ubrep_new (VALUE cary, int32_t rep_ndim, ca_size_t *rep_dim);
|
873
892
|
VALUE ca_ubrep_bind_with (VALUE self, VALUE other);
|
874
893
|
|
875
894
|
/* --- ca_obj_reduce.c --- */
|
@@ -887,6 +906,7 @@ VALUE rb_dim_iter_new (VALUE vca, CAIndexInfo *info);
|
|
887
906
|
void * malloc_with_check(size_t size);
|
888
907
|
|
889
908
|
int ca_install_obj_type (VALUE klass, ca_operation_function_t func);
|
909
|
+
VALUE ca_data_type_class (int8_t data_type);
|
890
910
|
|
891
911
|
void ca_mark (void *ap);
|
892
912
|
void ca_free (void *ap);
|
@@ -921,16 +941,19 @@ int ca_is_object_type (void *ap);
|
|
921
941
|
|
922
942
|
void ca_check_type (void *ap, int8_t data_type);
|
923
943
|
#define ca_check_data_type(ap, data_type) ca_check_type(ap, data_type)
|
924
|
-
void
|
925
|
-
void ca_check_shape (void *ap, int
|
944
|
+
void ca_check_ndim (void *ap, int ndim);
|
945
|
+
void ca_check_shape (void *ap, int ndim, ca_size_t *dim);
|
926
946
|
void ca_check_same_data_type (void *ap1, void *ap2);
|
927
|
-
void
|
947
|
+
void ca_check_same_ndim (void *ap1, void *ap2);
|
928
948
|
void ca_check_same_elements (void *ap1, void *ap2);
|
929
949
|
void ca_check_same_shape (void *ap1, void *ap2);
|
930
950
|
void ca_check_index (void *ap, ca_size_t *idx);
|
931
951
|
void ca_check_data_class (VALUE rtype);
|
932
952
|
int ca_is_valid_index (void *ap, ca_size_t *idx);
|
933
953
|
|
954
|
+
#define ca_ndim(ca) ((ca)->ndim)
|
955
|
+
#define ca_shape(ca) ((ca)->dim)
|
956
|
+
|
934
957
|
/* API : allocate, attach, update, sync, detach */
|
935
958
|
|
936
959
|
void ca_allocate (void *ap);
|
@@ -1021,7 +1044,7 @@ void ca_block_from_carray(CArray *cs,
|
|
1021
1044
|
(obj = rb_ca_wrap_readonly(obj, INT2NUM(data_type)), (CArray*) DATA_PTR(obj))
|
1022
1045
|
|
1023
1046
|
VALUE rb_carray_wrap_ptr (int8_t data_type,
|
1024
|
-
int8_t
|
1047
|
+
int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
1025
1048
|
CArray *mask, char *ptr, VALUE refer);
|
1026
1049
|
|
1027
1050
|
void * ca_to_cptr (void *ap);
|
@@ -1067,10 +1090,13 @@ void rb_ca_guess_type_and_bytes (VALUE rtype, VALUE rbytes,
|
|
1067
1090
|
int rb_ca_is_type (VALUE arg, int type);
|
1068
1091
|
|
1069
1092
|
/* scan index */
|
1070
|
-
void rb_ca_scan_index (int
|
1093
|
+
void rb_ca_scan_index (int ca_ndim, ca_size_t *ca_dim, ca_size_t elements,
|
1071
1094
|
long argc, VALUE *argv, CAIndexInfo *info);
|
1072
1095
|
|
1096
|
+
|
1073
1097
|
/* cast */
|
1098
|
+
int rb_ca_test_castable (VALUE other);
|
1099
|
+
VALUE rb_ca_binop_pass_to_other (VALUE self, VALUE other, ID method);
|
1074
1100
|
void rb_ca_cast_self (volatile VALUE *self);
|
1075
1101
|
void rb_ca_cast_self_or_other (volatile VALUE *self, volatile VALUE *other);
|
1076
1102
|
void rb_ca_cast_other (VALUE *self, volatile VALUE *other);
|
@@ -1091,7 +1117,7 @@ void rb_ca_modify (VALUE self);
|
|
1091
1117
|
/* attributes */
|
1092
1118
|
VALUE rb_ca_obj_type (VALUE self);
|
1093
1119
|
VALUE rb_ca_data_type (VALUE self);
|
1094
|
-
VALUE
|
1120
|
+
VALUE rb_ca_ndim (VALUE self);
|
1095
1121
|
VALUE rb_ca_bytes (VALUE self);
|
1096
1122
|
VALUE rb_ca_elements (VALUE self);
|
1097
1123
|
VALUE rb_ca_dim (VALUE self);
|