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
@@ -40,7 +40,7 @@ ca_reduce_setup (CAReduce *ca, CArray *parent, ca_size_t count, ca_size_t offset
|
|
40
40
|
ca->obj_type = CA_OBJ_REDUCE;
|
41
41
|
ca->data_type = CA_BOOLEAN; /* data type is fixed to boolean */
|
42
42
|
ca->flags = 0;
|
43
|
-
ca->
|
43
|
+
ca->ndim = 1;
|
44
44
|
ca->bytes = ca_sizeof[CA_BOOLEAN];
|
45
45
|
ca->elements = elements;
|
46
46
|
ca->ptr = NULL;
|
@@ -21,7 +21,7 @@ VALUE rb_cCARefer;
|
|
21
21
|
|
22
22
|
static int
|
23
23
|
ca_refer_setup (CARefer *ca, CArray *parent,
|
24
|
-
int8_t data_type, int8_t
|
24
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
25
25
|
ca_size_t offset)
|
26
26
|
{
|
27
27
|
ca_size_t elements, ratio;
|
@@ -29,8 +29,8 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
29
29
|
int is_deformed;
|
30
30
|
|
31
31
|
CA_CHECK_DATA_TYPE(data_type);
|
32
|
-
CA_CHECK_RANK(
|
33
|
-
CA_CHECK_DIM(
|
32
|
+
CA_CHECK_RANK(ndim);
|
33
|
+
CA_CHECK_DIM(ndim, dim);
|
34
34
|
CA_CHECK_BYTES(data_type, bytes);
|
35
35
|
|
36
36
|
if ( ca_is_object_type(parent) && data_type != CA_OBJECT ) {
|
@@ -42,10 +42,10 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
42
42
|
}
|
43
43
|
|
44
44
|
/* calc datanum and check deformation */
|
45
|
-
is_deformed = (
|
45
|
+
is_deformed = ( ndim == parent->ndim ) ? 0 : 1;
|
46
46
|
ratio = 1;
|
47
47
|
elements = 1;
|
48
|
-
for (i=0; i<
|
48
|
+
for (i=0; i<ndim; i++) {
|
49
49
|
elements *= dim[i];
|
50
50
|
if ( dim[i] != parent->dim[i] ) {
|
51
51
|
is_deformed |= 1;
|
@@ -79,10 +79,10 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
79
79
|
ca->obj_type = CA_OBJ_REFER;
|
80
80
|
ca->data_type = data_type;
|
81
81
|
ca->flags = 0;
|
82
|
-
ca->
|
82
|
+
ca->ndim = ndim;
|
83
83
|
ca->bytes = bytes;
|
84
84
|
ca->elements = elements;
|
85
|
-
ca->dim = ALLOC_N(ca_size_t,
|
85
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
86
86
|
ca->ptr = NULL;
|
87
87
|
ca->mask = NULL;
|
88
88
|
ca->mask0 = NULL;
|
@@ -99,7 +99,7 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
99
99
|
ca->is_deformed = 1;
|
100
100
|
}
|
101
101
|
|
102
|
-
memcpy(ca->dim, dim,
|
102
|
+
memcpy(ca->dim, dim, ndim * sizeof(ca_size_t));
|
103
103
|
|
104
104
|
if ( ca_is_scalar(parent) ) {
|
105
105
|
ca_set_flag(ca, CA_FLAG_SCALAR);
|
@@ -110,11 +110,11 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
110
110
|
|
111
111
|
CARefer *
|
112
112
|
ca_refer_new (CArray *parent,
|
113
|
-
int8_t data_type, int8_t
|
113
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
114
114
|
ca_size_t offset)
|
115
115
|
{
|
116
116
|
CARefer *ca = ALLOC(CARefer);
|
117
|
-
ca_refer_setup(ca, parent, data_type,
|
117
|
+
ca_refer_setup(ca, parent, data_type, ndim, dim, bytes, offset);
|
118
118
|
return ca;
|
119
119
|
}
|
120
120
|
|
@@ -137,7 +137,7 @@ ca_refer_func_clone (void *ap)
|
|
137
137
|
{
|
138
138
|
CARefer *ca = (CARefer *) ap;
|
139
139
|
return ca_refer_new(ca->parent,
|
140
|
-
ca->data_type, ca->
|
140
|
+
ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->offset);
|
141
141
|
}
|
142
142
|
|
143
143
|
static char *
|
@@ -167,9 +167,9 @@ ca_refer_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
167
167
|
ca_size_t *dim = ca->dim;
|
168
168
|
int8_t i;
|
169
169
|
ca_size_t n;
|
170
|
-
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[
|
171
|
-
for (i=1; i<ca->
|
172
|
-
n = dim[i]*n+idx[i]; /* ... + idx[
|
170
|
+
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
|
171
|
+
for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
|
172
|
+
n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
|
173
173
|
}
|
174
174
|
return ca->ptr + ca->bytes * n;
|
175
175
|
}
|
@@ -222,7 +222,7 @@ ca_refer_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
222
222
|
int8_t i;
|
223
223
|
ca_size_t n;
|
224
224
|
n = idx[0];
|
225
|
-
for (i=1; i<ca->
|
225
|
+
for (i=1; i<ca->ndim; i++) {
|
226
226
|
n = dim[i]*n+idx[i];
|
227
227
|
}
|
228
228
|
ca_refer_func_fetch_addr(ca, n, ptr);
|
@@ -283,7 +283,7 @@ ca_refer_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
283
283
|
int8_t i;
|
284
284
|
ca_size_t n;
|
285
285
|
n = idx[0];
|
286
|
-
for (i=1; i<ca->
|
286
|
+
for (i=1; i<ca->ndim; i++) {
|
287
287
|
n = dim[i]*n+idx[i];
|
288
288
|
}
|
289
289
|
ca_refer_func_store_addr(ca, n, ptr);
|
@@ -421,29 +421,29 @@ ca_refer_func_create_mask (void *ap)
|
|
421
421
|
if ( ca->bytes == ca->parent->bytes ) {
|
422
422
|
ca->mask =
|
423
423
|
(CArray *) ca_refer_new(ca->parent->mask,
|
424
|
-
CA_BOOLEAN, ca->
|
424
|
+
CA_BOOLEAN, ca->ndim, ca->dim, 0, ca->offset);
|
425
425
|
}
|
426
426
|
else if ( ca->is_deformed == -2 ) {
|
427
427
|
ca_size_t count[CA_RANK_MAX];
|
428
428
|
int i;
|
429
|
-
for (i=0; i<ca->parent->
|
429
|
+
for (i=0; i<ca->parent->ndim; i++) {
|
430
430
|
count[i] = 0;
|
431
431
|
}
|
432
|
-
count[ca->parent->
|
432
|
+
count[ca->parent->ndim] = ca->ratio;
|
433
433
|
ca->mask0 =
|
434
|
-
(CArray *) ca_repeat_new(ca->parent->mask, ca->parent->
|
434
|
+
(CArray *) ca_repeat_new(ca->parent->mask, ca->parent->ndim+1, count);
|
435
435
|
ca_unset_flag(ca->mask0, CA_FLAG_READ_ONLY);
|
436
436
|
|
437
437
|
ca->mask =
|
438
438
|
(CArray *) ca_refer_new(ca->mask0,
|
439
|
-
CA_BOOLEAN, ca->
|
439
|
+
CA_BOOLEAN, ca->ndim, ca->dim, 0, ca->offset);
|
440
440
|
}
|
441
441
|
else if ( ca->is_deformed == 2 ) {
|
442
442
|
/* TODO */
|
443
443
|
ca->mask0 =
|
444
444
|
(CArray *) ca_reduce_new(ca->parent->mask, ca->ratio, ca->offset);
|
445
445
|
ca->mask =
|
446
|
-
(CArray *) ca_refer_new(ca->mask0, CA_BOOLEAN, ca->
|
446
|
+
(CArray *) ca_refer_new(ca->mask0, CA_BOOLEAN, ca->ndim, ca->dim, 0, 0);
|
447
447
|
}
|
448
448
|
}
|
449
449
|
|
@@ -485,7 +485,7 @@ rb_ca_refer_initialize_copy (VALUE self, VALUE other)
|
|
485
485
|
Data_Get_Struct(self, CARefer, ca);
|
486
486
|
Data_Get_Struct(other, CARefer, cs);
|
487
487
|
|
488
|
-
ca_refer_setup(ca, cs->parent, cs->data_type, cs->
|
488
|
+
ca_refer_setup(ca, cs->parent, cs->data_type, cs->ndim, cs->dim,
|
489
489
|
cs->bytes, cs->offset);
|
490
490
|
|
491
491
|
return self;
|
@@ -514,7 +514,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
514
514
|
CArray *ca;
|
515
515
|
CARefer *cr;
|
516
516
|
int8_t data_type;
|
517
|
-
int8_t
|
517
|
+
int8_t ndim;
|
518
518
|
ca_size_t dim[CA_RANK_MAX];
|
519
519
|
ca_size_t bytes, offset = 0;
|
520
520
|
int8_t i;
|
@@ -524,11 +524,11 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
524
524
|
if ( argc == 0 ) { /* CArray#refer() */
|
525
525
|
data_type = ca->data_type;
|
526
526
|
bytes = ca->bytes;
|
527
|
-
|
528
|
-
for (i=0; i<
|
527
|
+
ndim = ca->ndim;
|
528
|
+
for (i=0; i<ndim; i++) {
|
529
529
|
dim[i] = ca->dim[i];
|
530
530
|
}
|
531
|
-
cr = ca_refer_new((CArray*)ca, data_type,
|
531
|
+
cr = ca_refer_new((CArray*)ca, data_type, ndim, dim, bytes, offset);
|
532
532
|
obj = ca_wrap_struct(cr);
|
533
533
|
rb_ca_set_parent(obj, self);
|
534
534
|
rb_ca_data_type_inherit(obj, self);
|
@@ -558,10 +558,10 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
558
558
|
}
|
559
559
|
|
560
560
|
Check_Type(rdim, T_ARRAY);
|
561
|
-
|
561
|
+
ndim = RARRAY_LEN(rdim);
|
562
562
|
|
563
563
|
elements = 1;
|
564
|
-
for (i=0; i<
|
564
|
+
for (i=0; i<ndim; i++) {
|
565
565
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
566
566
|
elements *= dim[i];
|
567
567
|
}
|
@@ -570,7 +570,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
570
570
|
offset = NUM2SIZE(roffset);
|
571
571
|
}
|
572
572
|
|
573
|
-
cr = ca_refer_new((CArray*)ca, data_type,
|
573
|
+
cr = ca_refer_new((CArray*)ca, data_type, ndim, dim, bytes, offset);
|
574
574
|
obj = ca_wrap_struct(cr);
|
575
575
|
rb_ca_set_parent(obj, self);
|
576
576
|
rb_ca_data_type_import(obj, rtype);
|
@@ -584,7 +584,7 @@ rb_ca_refer (int argc, VALUE *argv, VALUE self)
|
|
584
584
|
|
585
585
|
VALUE
|
586
586
|
rb_ca_refer_new (VALUE self,
|
587
|
-
int8_t data_type, int8_t
|
587
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
588
588
|
ca_size_t offset)
|
589
589
|
{
|
590
590
|
volatile VALUE list, rdim, ropt;
|
@@ -593,8 +593,8 @@ rb_ca_refer_new (VALUE self,
|
|
593
593
|
|
594
594
|
Data_Get_Struct(self, CArray, ca);
|
595
595
|
|
596
|
-
rdim = rb_ary_new2(
|
597
|
-
for (i=0; i<
|
596
|
+
rdim = rb_ary_new2(ndim);
|
597
|
+
for (i=0; i<ndim; i++) {
|
598
598
|
rb_ary_store(rdim, i, SIZE2NUM(dim[i]));
|
599
599
|
}
|
600
600
|
|
@@ -20,16 +20,16 @@ VALUE rb_cCARepeat;
|
|
20
20
|
*/
|
21
21
|
|
22
22
|
int
|
23
|
-
ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t
|
23
|
+
ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t ndim, ca_size_t *count)
|
24
24
|
{
|
25
25
|
int8_t data_type;
|
26
26
|
ca_size_t elements, bytes, nrpt, repeat_level, repeat_num,
|
27
|
-
contig_level, contig_num,
|
27
|
+
contig_level, contig_num, data_ndim;
|
28
28
|
int i, j;
|
29
29
|
|
30
30
|
nrpt = 1;
|
31
|
-
|
32
|
-
for (i=0; i<
|
31
|
+
data_ndim = 0;
|
32
|
+
for (i=0; i<ndim; i++) {
|
33
33
|
if ( count[i] < 0 ) {
|
34
34
|
rb_raise(rb_eRuntimeError,
|
35
35
|
"negative size for %i-th dimension specified", i);
|
@@ -39,27 +39,27 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
|
|
39
39
|
nrpt *= count[i];
|
40
40
|
}
|
41
41
|
else {
|
42
|
-
|
42
|
+
data_ndim += 1;
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
46
|
repeat_level = 0;
|
47
47
|
repeat_num = 1;
|
48
|
-
for (i=0; i<
|
48
|
+
for (i=0; i<ndim && count[i]; i++) {
|
49
49
|
repeat_level = i+1;
|
50
50
|
repeat_num *= count[i];
|
51
51
|
}
|
52
52
|
|
53
|
-
contig_level =
|
53
|
+
contig_level = ndim-1;
|
54
54
|
contig_num = 1;
|
55
|
-
for (i=
|
55
|
+
for (i=ndim-1; i >= 0 && count[i]; i--) {
|
56
56
|
contig_level = i;
|
57
57
|
contig_num *= count[i];
|
58
58
|
}
|
59
59
|
|
60
|
-
if (
|
60
|
+
if ( data_ndim != parent->ndim ) {
|
61
61
|
rb_raise(rb_eRuntimeError,
|
62
|
-
"mismatch in
|
62
|
+
"mismatch in ndim between original array and determined by # of dummies");
|
63
63
|
}
|
64
64
|
|
65
65
|
if ( ((double) parent->elements) * nrpt > CA_LENGTH_MAX ) {
|
@@ -73,24 +73,24 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
|
|
73
73
|
ca->obj_type = CA_OBJ_REPEAT;
|
74
74
|
ca->data_type = data_type;
|
75
75
|
ca->flags = 0;
|
76
|
-
ca->
|
76
|
+
ca->ndim = ndim;
|
77
77
|
ca->bytes = bytes;
|
78
78
|
ca->elements = elements;
|
79
79
|
ca->ptr = NULL;
|
80
80
|
ca->mask = NULL;
|
81
|
-
ca->dim = ALLOC_N(ca_size_t,
|
81
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
82
82
|
|
83
83
|
ca->parent = parent;
|
84
84
|
ca->attach = 0;
|
85
85
|
ca->nosync = 0;
|
86
|
-
ca->count = ALLOC_N(ca_size_t,
|
86
|
+
ca->count = ALLOC_N(ca_size_t, ndim);
|
87
87
|
ca->repeat_level = repeat_level;
|
88
88
|
ca->repeat_num = repeat_num;
|
89
89
|
ca->contig_level = contig_level;
|
90
90
|
ca->contig_num = contig_num;
|
91
91
|
|
92
92
|
j = 0;
|
93
|
-
for (i=0; i<
|
93
|
+
for (i=0; i<ndim; i++) {
|
94
94
|
if ( count[i] ) {
|
95
95
|
ca->dim[i] = count[i];
|
96
96
|
}
|
@@ -99,7 +99,7 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
|
102
|
-
memcpy(ca->count, count,
|
102
|
+
memcpy(ca->count, count, ndim * sizeof(ca_size_t));
|
103
103
|
|
104
104
|
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
105
105
|
|
@@ -112,10 +112,10 @@ ca_repeat_setup (CARepeat *ca, CArray *parent, int8_t rank, ca_size_t *count)
|
|
112
112
|
|
113
113
|
|
114
114
|
CARepeat *
|
115
|
-
ca_repeat_new (CArray *parent, int8_t
|
115
|
+
ca_repeat_new (CArray *parent, int8_t ndim, ca_size_t *count)
|
116
116
|
{
|
117
117
|
CARepeat *ca = ALLOC(CARepeat);
|
118
|
-
ca_repeat_setup(ca, parent,
|
118
|
+
ca_repeat_setup(ca, parent, ndim, count);
|
119
119
|
return ca;
|
120
120
|
}
|
121
121
|
|
@@ -141,7 +141,7 @@ static void *
|
|
141
141
|
ca_repeat_func_clone (void *ap)
|
142
142
|
{
|
143
143
|
CARepeat *ca = (CARepeat *) ap;
|
144
|
-
return ca_repeat_new(ca->parent, ca->
|
144
|
+
return ca_repeat_new(ca->parent, ca->ndim, ca->count);
|
145
145
|
}
|
146
146
|
|
147
147
|
static char *
|
@@ -173,7 +173,7 @@ ca_repeat_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
173
173
|
|
174
174
|
j = 0;
|
175
175
|
n = 0;
|
176
|
-
for (i=0; i<ca->
|
176
|
+
for (i=0; i<ca->ndim; i++) {
|
177
177
|
if ( ! count[i] ) {
|
178
178
|
n = dim0[j]*n + idx[i];
|
179
179
|
j++;
|
@@ -199,7 +199,7 @@ ca_repeat_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
199
199
|
ca_size_t n, j;
|
200
200
|
j = 0;
|
201
201
|
n = 0;
|
202
|
-
for (i=0; i<ca->
|
202
|
+
for (i=0; i<ca->ndim; i++) {
|
203
203
|
if ( ! count[i] ) {
|
204
204
|
idx0[j++] = idx[i];
|
205
205
|
}
|
@@ -217,7 +217,7 @@ ca_repeat_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
217
217
|
ca_size_t n, j;
|
218
218
|
j = 0;
|
219
219
|
n = 0;
|
220
|
-
for (i=0; i<ca->
|
220
|
+
for (i=0; i<ca->ndim; i++) {
|
221
221
|
if ( ! count[i] ) {
|
222
222
|
idx0[j++] = idx[i];
|
223
223
|
}
|
@@ -305,7 +305,7 @@ ca_repeat_func_create_mask (void *ap)
|
|
305
305
|
ca_create_mask(ca->parent);
|
306
306
|
}
|
307
307
|
ca->mask =
|
308
|
-
(CArray *) ca_repeat_new(ca->parent->mask, ca->
|
308
|
+
(CArray *) ca_repeat_new(ca->parent->mask, ca->ndim, ca->count);
|
309
309
|
}
|
310
310
|
|
311
311
|
ca_operation_function_t ca_repeat_func = {
|
@@ -410,7 +410,7 @@ ca_repeat_attach (CARepeat *ca)
|
|
410
410
|
ca_size_t i;
|
411
411
|
char *dp, *sp;
|
412
412
|
|
413
|
-
for (i=0; i<ca->
|
413
|
+
for (i=0; i<ca->ndim; i++) {
|
414
414
|
idx[i] = 0;
|
415
415
|
idx0[i] = 0;
|
416
416
|
}
|
@@ -459,7 +459,7 @@ ca_repeat_sync (CARepeat *ca)
|
|
459
459
|
ca_size_t idx[CA_RANK_MAX];
|
460
460
|
ca_size_t idx0[CA_RANK_MAX];
|
461
461
|
int8_t i;
|
462
|
-
for (i=0; i<ca->
|
462
|
+
for (i=0; i<ca->ndim; i++) {
|
463
463
|
idx[i] = 0;
|
464
464
|
idx0[i] = 0;
|
465
465
|
}
|
@@ -475,14 +475,14 @@ ca_repeat_fill (CARepeat *ca, char *ptr)
|
|
475
475
|
/* ------------------------------------------------------------------- */
|
476
476
|
|
477
477
|
VALUE
|
478
|
-
rb_ca_repeat_new (VALUE cary, int8_t
|
478
|
+
rb_ca_repeat_new (VALUE cary, int8_t ndim, ca_size_t *count)
|
479
479
|
{
|
480
480
|
volatile VALUE obj;
|
481
481
|
CArray *parent;
|
482
482
|
CARepeat *ca;
|
483
483
|
rb_check_carray_object(cary);
|
484
484
|
Data_Get_Struct(cary, CArray, parent);
|
485
|
-
ca = ca_repeat_new(parent,
|
485
|
+
ca = ca_repeat_new(parent, ndim, count);
|
486
486
|
obj = ca_wrap_struct(ca);
|
487
487
|
rb_ca_set_parent(obj, cary);
|
488
488
|
rb_ca_data_type_inherit(obj, cary);
|
@@ -507,7 +507,7 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
507
507
|
) ) {
|
508
508
|
volatile VALUE args;
|
509
509
|
CArray *ct;
|
510
|
-
ca_size_t
|
510
|
+
ca_size_t ndim, dim[CA_RANK_MAX];
|
511
511
|
int k;
|
512
512
|
if ( argv[0] == ID2SYM(rb_intern("%") ) ) {
|
513
513
|
Data_Get_Struct(argv[1], CArray, ct);
|
@@ -515,34 +515,34 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
515
515
|
else {
|
516
516
|
Data_Get_Struct(argv[0], CArray, ct);
|
517
517
|
}
|
518
|
-
if ( ct->
|
519
|
-
rb_raise(rb_eRuntimeError, "invalid
|
518
|
+
if ( ct->ndim < ca->ndim ) {
|
519
|
+
rb_raise(rb_eRuntimeError, "invalid ndim to template");
|
520
520
|
}
|
521
521
|
args = rb_ary_new();
|
522
|
-
|
522
|
+
ndim = 0;
|
523
523
|
if ( argv[0] == ID2SYM(rb_intern("%") ) ) {
|
524
524
|
k = 0;
|
525
|
-
for (i=0; i<ct->
|
525
|
+
for (i=0; i<ct->ndim; i++) {
|
526
526
|
if ( ca->dim[k] == 1 ) {
|
527
527
|
rb_ary_push(args, SIZE2NUM(ct->dim[i]));
|
528
528
|
k++;
|
529
529
|
}
|
530
530
|
else if ( ct->dim[i] == ca->dim[k] ) {
|
531
531
|
rb_ary_push(args, ID2SYM(rb_intern("%")));
|
532
|
-
dim[
|
533
|
-
k++;
|
532
|
+
dim[ndim] = ca->dim[k];
|
533
|
+
k++; ndim++;
|
534
534
|
}
|
535
535
|
else {
|
536
536
|
rb_ary_push(args, SIZE2NUM(ct->dim[i]));
|
537
537
|
}
|
538
538
|
}
|
539
|
-
if (
|
540
|
-
self = rb_ca_refer_new(self, ca->data_type,
|
539
|
+
if ( ndim != ca->ndim ) {
|
540
|
+
self = rb_ca_refer_new(self, ca->data_type, ndim, dim, ca->bytes, 0);
|
541
541
|
}
|
542
542
|
}
|
543
543
|
else {
|
544
|
-
k = ca->
|
545
|
-
for (i=ct->
|
544
|
+
k = ca->ndim - 1;
|
545
|
+
for (i=ct->ndim-1; i>=0; i--) {
|
546
546
|
if ( ca->dim[k] == 1 ) {
|
547
547
|
rb_ary_unshift(args, SIZE2NUM(ct->dim[i]));
|
548
548
|
k--;
|
@@ -556,14 +556,14 @@ rb_ca_repeat (int argc, VALUE *argv, VALUE self)
|
|
556
556
|
}
|
557
557
|
}
|
558
558
|
if ( k != 0 ) {
|
559
|
-
|
560
|
-
for (i=0; i<ca->
|
559
|
+
ndim = 0;
|
560
|
+
for (i=0; i<ca->ndim; i++) {
|
561
561
|
if ( ca->dim[i] != 1 ) {
|
562
|
-
dim[
|
563
|
-
|
562
|
+
dim[ndim] = ca->dim[i];
|
563
|
+
ndim++;
|
564
564
|
}
|
565
565
|
}
|
566
|
-
self = rb_ca_refer_new(self, ca->data_type,
|
566
|
+
self = rb_ca_refer_new(self, ca->data_type, ndim, dim, ca->bytes, 0);
|
567
567
|
}
|
568
568
|
}
|
569
569
|
return rb_ca_repeat((int)RARRAY_LEN(args), RARRAY_PTR(args), self);
|
@@ -625,7 +625,7 @@ rb_ca_repeat_initialize_copy (VALUE self, VALUE other)
|
|
625
625
|
Data_Get_Struct(self, CARepeat, ca);
|
626
626
|
Data_Get_Struct(other, CARepeat, cs);
|
627
627
|
|
628
|
-
ca_repeat_setup(ca, cs->parent, cs->
|
628
|
+
ca_repeat_setup(ca, cs->parent, cs->ndim, cs->count);
|
629
629
|
|
630
630
|
return self;
|
631
631
|
}
|