carray 1.3.6 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +32 -0
- data/LICENSE +22 -0
- data/NEWS.md +65 -0
- data/README.md +23 -26
- data/Rakefile +31 -0
- data/TODO.md +17 -0
- data/carray.gemspec +24 -31
- data/{ca_iter_block.c → ext/ca_iter_block.c} +16 -18
- data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +20 -21
- data/{ca_iter_window.c → ext/ca_iter_window.c} +12 -14
- data/{ca_obj_array.c → ext/ca_obj_array.c} +451 -176
- data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +18 -23
- data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +12 -16
- data/{ca_obj_block.c → ext/ca_obj_block.c} +47 -54
- data/{ca_obj_fake.c → ext/ca_obj_fake.c} +10 -12
- data/{ca_obj_farray.c → ext/ca_obj_farray.c} +21 -23
- data/{ca_obj_field.c → ext/ca_obj_field.c} +30 -32
- data/{ca_obj_grid.c → ext/ca_obj_grid.c} +32 -33
- data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +11 -13
- data/{ca_obj_object.c → ext/ca_obj_object.c} +40 -42
- data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +3 -5
- data/{ca_obj_refer.c → ext/ca_obj_refer.c} +38 -40
- data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +45 -47
- data/{ca_obj_select.c → ext/ca_obj_select.c} +4 -6
- data/{ca_obj_shift.c → ext/ca_obj_shift.c} +26 -28
- data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +26 -28
- data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +106 -160
- data/{ca_obj_window.c → ext/ca_obj_window.c} +33 -35
- data/{carray.h → ext/carray.h} +90 -59
- data/{carray_access.c → ext/carray_access.c} +244 -109
- data/{carray_attribute.c → ext/carray_attribute.c} +161 -207
- data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +1 -3
- data/{carray_cast.c → ext/carray_cast.c} +350 -149
- data/{carray_cast_func.rb → ext/carray_cast_func.rb} +1 -2
- data/{carray_class.c → ext/carray_class.c} +28 -36
- data/{carray_conversion.c → ext/carray_conversion.c} +58 -70
- data/{carray_copy.c → ext/carray_copy.c} +34 -50
- data/{carray_core.c → ext/carray_core.c} +75 -62
- data/ext/carray_data_type.c +66 -0
- data/{carray_element.c → ext/carray_element.c} +34 -53
- data/{carray_generate.c → ext/carray_generate.c} +137 -50
- data/{carray_iterator.c → ext/carray_iterator.c} +53 -53
- data/{carray_loop.c → ext/carray_loop.c} +77 -106
- data/{carray_mask.c → ext/carray_mask.c} +95 -114
- data/{carray_math.rb → ext/carray_math.rb} +47 -31
- data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +1 -3
- data/{carray_numeric.c → ext/carray_numeric.c} +43 -46
- data/{carray_operator.c → ext/carray_operator.c} +72 -36
- data/{carray_order.c → ext/carray_order.c} +73 -217
- data/{carray_sort_addr.c → ext/carray_sort_addr.c} +14 -21
- data/{carray_stat.c → ext/carray_stat.c} +6 -8
- data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +25 -27
- data/{carray_test.c → ext/carray_test.c} +59 -51
- data/{carray_undef.c → ext/carray_undef.c} +1 -11
- data/{carray_utils.c → ext/carray_utils.c} +12 -4
- data/{extconf.rb → ext/extconf.rb} +1 -6
- data/{mkmath.rb → ext/mkmath.rb} +13 -3
- data/{ruby_carray.c → ext/ruby_carray.c} +20 -8
- data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +1 -3
- data/{ruby_float_func.c → ext/ruby_float_func.c} +1 -3
- data/ext/version.h +16 -0
- data/{version.rb → ext/version.rb} +0 -0
- data/lib/carray.rb +52 -10
- data/lib/carray/{base/autoload.rb → autoload.rb} +48 -8
- 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 +191 -0
- data/lib/carray/broadcast.rb +82 -0
- data/lib/carray/compose.rb +315 -0
- data/lib/carray/construct.rb +460 -0
- data/lib/carray/convert.rb +115 -0
- data/lib/carray/info.rb +1 -3
- data/lib/carray/{base/inspect.rb → inspect.rb} +9 -11
- data/lib/carray/io/imagemagick.rb +2 -4
- data/lib/carray/{base/iterator.rb → iterator.rb} +6 -6
- data/lib/carray/mask.rb +102 -0
- data/lib/carray/{base/math.rb → math.rb} +21 -53
- data/lib/carray/math/histogram.rb +8 -10
- data/lib/carray/math/recurrence.rb +1 -3
- data/lib/carray/mkmf.rb +9 -3
- data/lib/carray/object/ca_obj_iterator.rb +1 -3
- data/lib/carray/object/ca_obj_link.rb +1 -3
- data/lib/carray/object/ca_obj_pack.rb +9 -11
- data/lib/carray/obsolete.rb +270 -0
- data/lib/carray/ordering.rb +181 -0
- data/lib/carray/{base/serialize.rb → serialize.rb} +50 -66
- data/lib/carray/string.rb +188 -0
- data/lib/carray/{base/struct.rb → struct.rb} +19 -21
- data/lib/carray/{io/table.rb → table.rb} +1 -9
- data/lib/carray/testing.rb +51 -0
- data/lib/carray/time.rb +76 -0
- data/lib/carray/transform.rb +98 -0
- data/misc/Methods.ja.md +182 -0
- data/{NOTE → misc/NOTE} +0 -0
- data/spec/Classes/CABitfield_spec.rb +58 -0
- data/spec/Classes/CABlockIterator_spec.rb +114 -0
- data/spec/Classes/CABlock_spec.rb +205 -0
- data/spec/Classes/CAField_spec.rb +39 -0
- data/spec/Classes/CAGrid_spec.rb +75 -0
- data/spec/Classes/CAMap_spec.rb +0 -0
- data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
- data/spec/Classes/CAObject_attribute_spec.rb +33 -0
- data/spec/Classes/CAObject_spec.rb +33 -0
- data/spec/Classes/CARefer_spec.rb +93 -0
- data/spec/Classes/CARepeat_spec.rb +65 -0
- data/spec/Classes/CASelect_spec.rb +22 -0
- data/spec/Classes/CAShift_spec.rb +16 -0
- data/spec/Classes/CAStruct_spec.rb +71 -0
- data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
- data/spec/Classes/CAUnboudRepeat_spec.rb +102 -0
- data/spec/Classes/CAWindow_spec.rb +54 -0
- data/spec/Classes/CAWrap_spec.rb +8 -0
- data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
- data/spec/Classes/CScalar_spec.rb +55 -0
- data/spec/Features/feature_130_spec.rb +19 -0
- data/spec/Features/feature_attributes_spec.rb +280 -0
- data/spec/Features/feature_boolean_spec.rb +98 -0
- data/spec/Features/feature_broadcast.rb +116 -0
- data/spec/Features/feature_cast_function.rb +19 -0
- data/spec/Features/feature_cast_spec.rb +33 -0
- data/spec/Features/feature_class_spec.rb +84 -0
- data/spec/Features/feature_complex_spec.rb +42 -0
- data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
- data/spec/Features/feature_convert_spec.rb +46 -0
- data/spec/Features/feature_copy_spec.rb +123 -0
- data/spec/Features/feature_creation_spec.rb +84 -0
- data/spec/Features/feature_element_spec.rb +144 -0
- data/spec/Features/feature_extream_spec.rb +54 -0
- data/spec/Features/feature_generate_spec.rb +74 -0
- data/spec/Features/feature_index_spec.rb +69 -0
- data/spec/Features/feature_mask_spec.rb +580 -0
- data/spec/Features/feature_math_spec.rb +97 -0
- data/spec/Features/feature_order_spec.rb +146 -0
- data/spec/Features/feature_ref_store_spec.rb +209 -0
- data/spec/Features/feature_serialization_spec.rb +125 -0
- data/spec/Features/feature_stat_spec.rb +397 -0
- data/spec/Features/feature_virtual_spec.rb +48 -0
- data/spec/Features/method_eq_spec.rb +81 -0
- data/spec/Features/method_is_nan_spec.rb +12 -0
- data/spec/Features/method_map_spec.rb +54 -0
- data/spec/Features/method_max_with.rb +20 -0
- data/spec/Features/method_min_with.rb +19 -0
- data/spec/Features/method_ne_spec.rb +18 -0
- data/spec/Features/method_project_spec.rb +188 -0
- data/spec/Features/method_ref_spec.rb +27 -0
- data/spec/Features/method_round_spec.rb +11 -0
- data/spec/Features/method_s_linspace_spec.rb +48 -0
- data/spec/Features/method_s_span_spec.rb +14 -0
- data/spec/Features/method_seq_spec.rb +47 -0
- data/spec/Features/method_sort_with.rb +43 -0
- data/spec/Features/method_sorted_with.rb +29 -0
- data/spec/Features/method_span_spec.rb +42 -0
- data/spec/Features/method_wrap_readonly_spec.rb +43 -0
- data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
- data/spec/spec_all.rb +0 -1
- data/utils/convert_test.rb +73 -0
- data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
- data/{devel → utils}/guess_shape.rb +0 -0
- data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
- metadata +173 -316
- data/COPYING +0 -56
- data/GPL +0 -340
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -33
- data/LEGAL +0 -50
- data/Makefile +0 -451
- data/TODO +0 -5
- data/carray_cast_func.c +0 -8670
- data/carray_config.h +0 -26
- data/carray_math.c +0 -24805
- data/carray_random.c +0 -531
- data/carray_stat_proc.c +0 -12170
- 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/mkmf.log +0 -375
- data/mt19937ar.c +0 -182
- data/mt19937ar.h +0 -86
- data/rdoc_ext.rb +0 -1115
- data/rdoc_main.rb +0 -27
- data/rdoc_math.rb +0 -5
- data/rdoc_stat.rb +0 -31
- data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
- data/spec/CArray/bug/store_spec.rb +0 -27
- data/spec/CArray/index/repeat_spec.rb +0 -10
- data/spec/CArray/method/eq_spec.rb +0 -80
- data/spec/CArray/method/is_nan_spec.rb +0 -12
- data/spec/CArray/method/ne_spec.rb +0 -18
- data/spec/CArray/method/round_spec.rb +0 -11
- data/spec/CArray/object/_attribute_spec.rb +0 -32
- data/spec/CArray/object/s_new_spec.rb +0 -31
- data/spec/CArray/serialize/Serialization_spec.rb +0 -89
- data/test/test_130.rb +0 -23
- data/test/test_ALL.rb +0 -51
- data/test/test_CABitfield.rb +0 -59
- data/test/test_CABlock.rb +0 -208
- data/test/test_CAField.rb +0 -40
- data/test/test_CAGrid.rb +0 -76
- data/test/test_CAMmap.rb +0 -11
- data/test/test_CARefer.rb +0 -94
- data/test/test_CARepeat.rb +0 -66
- data/test/test_CASelect.rb +0 -23
- data/test/test_CAShift.rb +0 -17
- data/test/test_CAWindow.rb +0 -55
- data/test/test_CAWrap.rb +0 -9
- data/test/test_CComplex.rb +0 -83
- data/test/test_CScalar.rb +0 -91
- data/test/test_attribute.rb +0 -281
- data/test/test_block_iterator.rb +0 -17
- data/test/test_boolean.rb +0 -99
- data/test/test_cast.rb +0 -33
- data/test/test_class.rb +0 -85
- data/test/test_complex.rb +0 -43
- data/test/test_convert.rb +0 -79
- data/test/test_copy.rb +0 -141
- data/test/test_creation.rb +0 -85
- data/test/test_element.rb +0 -146
- data/test/test_extream.rb +0 -55
- data/test/test_generate.rb +0 -75
- data/test/test_index.rb +0 -71
- data/test/test_mask.rb +0 -578
- data/test/test_math.rb +0 -98
- data/test/test_narray.rb +0 -64
- data/test/test_order.rb +0 -147
- data/test/test_random.rb +0 -15
- data/test/test_ref_store.rb +0 -211
- data/test/test_stat.rb +0 -414
- data/test/test_struct.rb +0 -72
- data/test/test_virtual.rb +0 -49
- data/utils/create_rdoc.sh +0 -9
- data/utils/make_tgz.sh +0 -3
- data/version.h +0 -18
@@ -3,10 +3,8 @@
|
|
3
3
|
ca_iter_dimension.c
|
4
4
|
|
5
5
|
This file is part of Ruby/CArray extension library.
|
6
|
-
You can redistribute it and/or modify it under the terms of
|
7
|
-
the Ruby Licence.
|
8
6
|
|
9
|
-
Copyright (C) 2005 Hiroki Motoyoshi
|
7
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
10
8
|
|
11
9
|
---------------------------------------------------------------------------- */
|
12
10
|
|
@@ -15,13 +13,13 @@
|
|
15
13
|
|
16
14
|
VALUE rb_cCADimIterator;
|
17
15
|
|
18
|
-
/*
|
16
|
+
/* yard:
|
19
17
|
class CADimensionIterator < CAIterator # :nodoc:
|
20
18
|
end
|
21
19
|
*/
|
22
20
|
|
23
21
|
typedef struct {
|
24
|
-
int8_t
|
22
|
+
int8_t ndim;
|
25
23
|
ca_size_t dim[CA_RANK_MAX];
|
26
24
|
CArray *reference;
|
27
25
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -50,14 +48,14 @@ ca_di_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
|
|
50
48
|
else {
|
51
49
|
CABlock *ck = (CABlock *)dit->kernel;
|
52
50
|
kernel = ca_block_new(ref,
|
53
|
-
ck->
|
51
|
+
ck->ndim, ck->size0,
|
54
52
|
ck->start, ck->step, ck->count,
|
55
53
|
ck->offset);
|
56
54
|
}
|
57
55
|
|
58
56
|
ca_update_mask(kernel);
|
59
57
|
|
60
|
-
for (i=0; i<dit->
|
58
|
+
for (i=0; i<dit->ndim; i++) {
|
61
59
|
val = idx[i];
|
62
60
|
CA_CHECK_INDEX(val, dit->dim[i]);
|
63
61
|
kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
|
@@ -77,7 +75,7 @@ ca_di_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
|
|
77
75
|
ca_size_t *dim = dit->dim;
|
78
76
|
ca_size_t idx[CA_RANK_MAX];
|
79
77
|
int8_t i;
|
80
|
-
for (i=dit->
|
78
|
+
for (i=dit->ndim-1; i>=0; i--) {
|
81
79
|
idx[i] = addr % dim[i];
|
82
80
|
addr /= dim[i];
|
83
81
|
}
|
@@ -94,7 +92,7 @@ ca_di_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
|
|
94
92
|
|
95
93
|
ca_update_mask(kernel);
|
96
94
|
|
97
|
-
for (i=0; i<dit->
|
95
|
+
for (i=0; i<dit->ndim; i++) {
|
98
96
|
val = idx[i];
|
99
97
|
CA_CHECK_INDEX(val, dit->dim[i]);
|
100
98
|
kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
|
@@ -114,7 +112,7 @@ ca_di_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
|
|
114
112
|
ca_size_t *dim = dit->dim;
|
115
113
|
ca_size_t idx[CA_RANK_MAX];
|
116
114
|
int8_t i;
|
117
|
-
for (i=dit->
|
115
|
+
for (i=dit->ndim-1; i>=0; i--) {
|
118
116
|
idx[i] = addr % dim[i];
|
119
117
|
addr /= dim[i];
|
120
118
|
}
|
@@ -129,7 +127,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
129
127
|
volatile VALUE rindex, rker, rsymtbl;
|
130
128
|
CADimIterator *it;
|
131
129
|
CAIndexInfo blk_spec;
|
132
|
-
int8_t
|
130
|
+
int8_t ndim;
|
133
131
|
int i, j, k;
|
134
132
|
|
135
133
|
Data_Get_Struct(self, CADimIterator, it);
|
@@ -142,7 +140,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
142
140
|
|
143
141
|
blk_spec = *info;
|
144
142
|
blk_spec.type = CA_REG_BLOCK;
|
145
|
-
for (i=0; i<info->
|
143
|
+
for (i=0; i<info->ndim; i++) {
|
146
144
|
if ( info->index_type[i] == CA_IDX_SYMBOL ) {
|
147
145
|
blk_spec.index_type[i] = CA_IDX_ALL;
|
148
146
|
rb_hash_aset(rsymtbl, ID2SYM(blk_spec.index[i].symbol.id), INT2NUM(i));
|
@@ -151,13 +149,13 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
151
149
|
|
152
150
|
rref = rb_ca_ref_block(rref, &blk_spec);
|
153
151
|
|
154
|
-
rindex = rb_ary_new2(info->
|
155
|
-
|
152
|
+
rindex = rb_ary_new2(info->ndim);
|
153
|
+
ndim = 0;
|
156
154
|
|
157
155
|
j = 0;
|
158
156
|
k = 0;
|
159
157
|
|
160
|
-
for (i=0; i<info->
|
158
|
+
for (i=0; i<info->ndim; i++) {
|
161
159
|
if ( info->index_type[i] == CA_IDX_SCALAR ) {
|
162
160
|
rb_ary_store(rindex, i, SIZE2NUM(info->index[i].scalar));
|
163
161
|
continue; /* escape from j++ */
|
@@ -165,8 +163,8 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
165
163
|
else if ( info->index_type[i] == CA_IDX_SYMBOL ) {
|
166
164
|
rb_ary_store(rindex, i, rb_ary_new3(1, SIZE2NUM(0)));
|
167
165
|
it->symflag[j] = 1;
|
168
|
-
it->symindex[
|
169
|
-
|
166
|
+
it->symindex[ndim] = j;
|
167
|
+
ndim++;
|
170
168
|
}
|
171
169
|
else if ( info->index_type[i] == CA_IDX_ALL ) {
|
172
170
|
rb_ary_store(rindex, i, Qnil);
|
@@ -184,7 +182,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
184
182
|
|
185
183
|
rker = rb_apply(rref, rb_intern("[]"), rindex);
|
186
184
|
|
187
|
-
it->
|
185
|
+
it->ndim = ndim;
|
188
186
|
Data_Get_Struct(rref, CArray, it->reference);
|
189
187
|
Data_Get_Struct(rker, CArray, it->kernel);
|
190
188
|
it->kernel_at_addr = ca_di_kernel_at_addr;
|
@@ -192,7 +190,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
192
190
|
it->kernel_move_to_addr = ca_di_kernel_move_to_addr;
|
193
191
|
it->kernel_move_to_index = ca_di_kernel_move_to_index;
|
194
192
|
|
195
|
-
for (i=0; i<it->
|
193
|
+
for (i=0; i<it->ndim; i++) {
|
196
194
|
it->dim[i] = it->reference->dim[it->symindex[i]];
|
197
195
|
}
|
198
196
|
|
@@ -239,7 +237,8 @@ rb_ca_dim_iterator (int argc, VALUE *argv, VALUE self)
|
|
239
237
|
|
240
238
|
Data_Get_Struct(self, CArray, ca);
|
241
239
|
|
242
|
-
|
240
|
+
info.range_check = 1;
|
241
|
+
rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
|
243
242
|
|
244
243
|
obj = rb_di_s_allocate(rb_cCADimIterator);
|
245
244
|
ca_di_setup(obj, self, &info);
|
@@ -258,7 +257,7 @@ rb_dim_iter_new (VALUE rref, CAIndexInfo *info)
|
|
258
257
|
return obj;
|
259
258
|
}
|
260
259
|
|
261
|
-
/*
|
260
|
+
/* yard:
|
262
261
|
class CADimensionIterator
|
263
262
|
def sym2dim (sym)
|
264
263
|
end
|
@@ -3,17 +3,15 @@
|
|
3
3
|
ca_iter_window.c
|
4
4
|
|
5
5
|
This file is part of Ruby/CArray extension library.
|
6
|
-
You can redistribute it and/or modify it under the terms of
|
7
|
-
the Ruby Licence.
|
8
6
|
|
9
|
-
Copyright (C) 2005 Hiroki Motoyoshi
|
7
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
10
8
|
|
11
9
|
---------------------------------------------------------------------------- */
|
12
10
|
|
13
11
|
#include "carray.h"
|
14
12
|
|
15
13
|
typedef struct {
|
16
|
-
int8_t
|
14
|
+
int8_t ndim;
|
17
15
|
ca_size_t dim[CA_RANK_MAX];
|
18
16
|
CArray *reference;
|
19
17
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -27,7 +25,7 @@ typedef struct {
|
|
27
25
|
|
28
26
|
VALUE rb_cCAWindowIterator;
|
29
27
|
|
30
|
-
/*
|
28
|
+
/* yard:
|
31
29
|
class CAWindowIterator < CAIterator # :nodoc:
|
32
30
|
end
|
33
31
|
*/
|
@@ -59,7 +57,7 @@ ca_vi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
|
|
59
57
|
|
60
58
|
ca_update_mask(kernel);
|
61
59
|
|
62
|
-
for (i=0; i<kernel->
|
60
|
+
for (i=0; i<kernel->ndim; i++) {
|
63
61
|
j = idx[i];
|
64
62
|
CA_CHECK_INDEX(j, vit->dim[i]);
|
65
63
|
kernel->start[i] = j - vit->offset[i];
|
@@ -78,7 +76,7 @@ ca_vi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
|
|
78
76
|
ca_size_t *dim = vit->dim;
|
79
77
|
ca_size_t idx[CA_RANK_MAX];
|
80
78
|
int8_t i;
|
81
|
-
for (i=vit->
|
79
|
+
for (i=vit->ndim-1; i>=0; i--) {
|
82
80
|
idx[i] = addr % dim[i];
|
83
81
|
addr /= dim[i];
|
84
82
|
}
|
@@ -97,7 +95,7 @@ ca_vi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
|
|
97
95
|
|
98
96
|
ca_update_mask(kernel);
|
99
97
|
|
100
|
-
for (i=0; i<kernel->
|
98
|
+
for (i=0; i<kernel->ndim; i++) {
|
101
99
|
j = idx[i];
|
102
100
|
CA_CHECK_INDEX(j, dim[i]);
|
103
101
|
kernel->start[i] = j - offset[i];
|
@@ -116,7 +114,7 @@ ca_vi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
|
|
116
114
|
ca_size_t *dim = vit->dim;
|
117
115
|
ca_size_t idx[CA_RANK_MAX];
|
118
116
|
int8_t i;
|
119
|
-
for (i=vit->
|
117
|
+
for (i=vit->ndim-1; i>=0; i--) {
|
120
118
|
idx[i] = addr % dim[i];
|
121
119
|
addr /= dim[i];
|
122
120
|
}
|
@@ -136,12 +134,12 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
136
134
|
Data_Get_Struct(rref, CArray, ref);
|
137
135
|
Data_Get_Struct(rker, CArray, ker);
|
138
136
|
|
139
|
-
if ( ref->
|
140
|
-
rb_raise(rb_eRuntimeError, "
|
137
|
+
if ( ref->ndim != ker->ndim ) {
|
138
|
+
rb_raise(rb_eRuntimeError, "ndim mismatch between reference and kernel");
|
141
139
|
}
|
142
140
|
|
143
|
-
it->
|
144
|
-
memcpy(it->dim, ref->dim, it->
|
141
|
+
it->ndim = ref->ndim;
|
142
|
+
memcpy(it->dim, ref->dim, it->ndim * sizeof(ca_size_t));
|
145
143
|
it->reference = ref;
|
146
144
|
it->kernel = ker;
|
147
145
|
it->kernel_at_addr = ca_vi_kernel_at_addr;
|
@@ -149,7 +147,7 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
149
147
|
it->kernel_move_to_addr = ca_vi_kernel_move_to_addr;
|
150
148
|
it->kernel_move_to_index = ca_vi_kernel_move_to_index;
|
151
149
|
|
152
|
-
for (i=0; i<it->
|
150
|
+
for (i=0; i<it->ndim; i++) {
|
153
151
|
it->offset[i] = -(((CAWindow*)ker)->start[i]);
|
154
152
|
}
|
155
153
|
|
@@ -3,10 +3,8 @@
|
|
3
3
|
ca_obj_array.c
|
4
4
|
|
5
5
|
This file is part of Ruby/CArray extension library.
|
6
|
-
You can redistribute it and/or modify it under the terms of
|
7
|
-
the Ruby Licence.
|
8
6
|
|
9
|
-
Copyright (C) 2005 Hiroki Motoyoshi
|
7
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
10
8
|
|
11
9
|
---------------------------------------------------------------------------- */
|
12
10
|
|
@@ -19,7 +17,7 @@
|
|
19
17
|
|
20
18
|
VALUE rb_cCArray, rb_cCAWrap, rb_cCScalar, rb_cCAVirtual;
|
21
19
|
|
22
|
-
/*
|
20
|
+
/* yard:
|
23
21
|
class CArray
|
24
22
|
end
|
25
23
|
class CAWrap < CArray # :nodoc:
|
@@ -42,7 +40,7 @@ double ca_mem_count = 0.0;
|
|
42
40
|
|
43
41
|
/* Threshold for forced garbage collection and its default value */
|
44
42
|
double ca_gc_interval;
|
45
|
-
const double ca_default_gc_interval =
|
43
|
+
const double ca_default_gc_interval = 100.0; /* 100MB */
|
46
44
|
|
47
45
|
#define MB (1024*1024)
|
48
46
|
|
@@ -60,27 +58,22 @@ ca_check_mem_count()
|
|
60
58
|
}
|
61
59
|
}
|
62
60
|
|
63
|
-
/*
|
64
|
-
# returns the threshold of incremented memory (MB) used by carray object
|
65
|
-
# until start GC.
|
66
|
-
def CArray.gc_interval ()
|
67
|
-
end
|
68
|
-
# set the threshold of incremented memory (MB) used by carray object
|
69
|
-
# until start GC.
|
70
|
-
def CArray.gc_interval= (val)
|
71
|
-
end
|
72
|
-
# reset the counter for the GC start when the incremented memory
|
73
|
-
# get larger than `CArray.gc_interval`.
|
74
|
-
def CArray.reset_gc_interval ()
|
75
|
-
end
|
76
|
-
*/
|
61
|
+
/* @private gc_interval
|
77
62
|
|
63
|
+
Returns the threshold of incremented memory (MB) used by carray object
|
64
|
+
until start GC.
|
65
|
+
*/
|
78
66
|
static VALUE
|
79
67
|
rb_ca_get_gc_interval (VALUE self)
|
80
68
|
{
|
81
69
|
return rb_float_new(ca_gc_interval);
|
82
70
|
}
|
83
71
|
|
72
|
+
/* @private gc_interval= (val)
|
73
|
+
|
74
|
+
Sets the threshold of incremented memory (MB) used by carray object
|
75
|
+
until start GC.
|
76
|
+
*/
|
84
77
|
static VALUE
|
85
78
|
rb_ca_set_gc_interval (VALUE self, VALUE rth)
|
86
79
|
{
|
@@ -92,6 +85,11 @@ rb_ca_set_gc_interval (VALUE self, VALUE rth)
|
|
92
85
|
return rb_float_new(ca_gc_interval);
|
93
86
|
}
|
94
87
|
|
88
|
+
/* @private reset_gc_inverval
|
89
|
+
|
90
|
+
Reset the counter for the GC start when the incremented memory
|
91
|
+
get larger than `CArray.gc_interval`.
|
92
|
+
*/
|
95
93
|
static VALUE
|
96
94
|
rb_ca_reset_gc_interval (VALUE self)
|
97
95
|
{
|
@@ -117,7 +115,7 @@ rb_ca_reset_gc_interval (VALUE self)
|
|
117
115
|
|
118
116
|
static int
|
119
117
|
carray_setup_i (CArray *ca,
|
120
|
-
int8_t data_type, int8_t
|
118
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
121
119
|
CArray *mask, int allocate, int use_calloc)
|
122
120
|
{
|
123
121
|
ca_size_t elements;
|
@@ -127,14 +125,14 @@ carray_setup_i (CArray *ca,
|
|
127
125
|
|
128
126
|
/* check arguments */
|
129
127
|
CA_CHECK_DATA_TYPE(data_type);
|
130
|
-
CA_CHECK_RANK(
|
131
|
-
CA_CHECK_DIM(
|
128
|
+
CA_CHECK_RANK(ndim);
|
129
|
+
CA_CHECK_DIM(ndim, dim);
|
132
130
|
CA_CHECK_BYTES(data_type, bytes);
|
133
131
|
|
134
132
|
/* calculate total number of elements */
|
135
133
|
elements = 1;
|
136
134
|
length = bytes;
|
137
|
-
for (i=0; i<
|
135
|
+
for (i=0; i<ndim; i++) {
|
138
136
|
elements *= dim[i];
|
139
137
|
length *= dim[i];
|
140
138
|
}
|
@@ -153,11 +151,11 @@ carray_setup_i (CArray *ca,
|
|
153
151
|
|
154
152
|
ca->data_type = data_type;
|
155
153
|
ca->flags = 0;
|
156
|
-
ca->
|
154
|
+
ca->ndim = ndim;
|
157
155
|
ca->bytes = bytes;
|
158
156
|
ca->elements = elements;
|
159
|
-
ca->dim = ALLOC_N(ca_size_t,
|
160
|
-
memcpy(ca->dim, dim,
|
157
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
158
|
+
memcpy(ca->dim, dim, ndim*sizeof(ca_size_t));
|
161
159
|
|
162
160
|
if ( allocate ) { /* allocate == true */
|
163
161
|
|
@@ -201,26 +199,26 @@ carray_setup_i (CArray *ca,
|
|
201
199
|
|
202
200
|
int
|
203
201
|
carray_setup (CArray *ca,
|
204
|
-
int8_t data_type, int8_t
|
202
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
|
205
203
|
{
|
206
|
-
return carray_setup_i(ca, data_type,
|
204
|
+
return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 0);
|
207
205
|
}
|
208
206
|
|
209
207
|
int
|
210
208
|
carray_safe_setup (CArray *ca,
|
211
|
-
int8_t data_type, int8_t
|
209
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
|
212
210
|
{
|
213
|
-
return carray_setup_i(ca, data_type,
|
211
|
+
return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 1);
|
214
212
|
}
|
215
213
|
|
216
214
|
int
|
217
215
|
ca_wrap_setup (CArray *ca,
|
218
|
-
int8_t data_type, int8_t
|
216
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
219
217
|
CArray *mask, char *ptr)
|
220
218
|
{
|
221
219
|
int ret;
|
222
220
|
|
223
|
-
ret = carray_setup_i(ca, data_type,
|
221
|
+
ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
|
224
222
|
if ( (!ptr) && (ca->elements != 0) ) {
|
225
223
|
rb_raise(rb_eRuntimeError, "wrapping NULL pointer with an non-empty array");
|
226
224
|
}
|
@@ -230,49 +228,49 @@ ca_wrap_setup (CArray *ca,
|
|
230
228
|
|
231
229
|
int
|
232
230
|
ca_wrap_setup_null (CArray *ca,
|
233
|
-
int8_t data_type, int8_t
|
231
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
234
232
|
CArray *mask)
|
235
233
|
{
|
236
234
|
int ret;
|
237
235
|
|
238
|
-
ret = carray_setup_i(ca, data_type,
|
236
|
+
ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
|
239
237
|
ca->ptr = NULL;
|
240
238
|
return ret;
|
241
239
|
}
|
242
240
|
|
243
241
|
CArray *
|
244
|
-
carray_new (int8_t data_type, int8_t
|
242
|
+
carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
245
243
|
CArray *mask)
|
246
244
|
{
|
247
245
|
CArray *ca = ALLOC(CArray);
|
248
|
-
carray_setup(ca, data_type,
|
246
|
+
carray_setup(ca, data_type, ndim, dim, bytes, mask);
|
249
247
|
return ca;
|
250
248
|
}
|
251
249
|
|
252
250
|
CArray *
|
253
|
-
carray_new_safe (int8_t data_type, int8_t
|
251
|
+
carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
254
252
|
CArray *mask)
|
255
253
|
{
|
256
254
|
CArray *ca = ALLOC(CArray);
|
257
|
-
carray_safe_setup(ca, data_type,
|
255
|
+
carray_safe_setup(ca, data_type, ndim, dim, bytes, mask);
|
258
256
|
return ca;
|
259
257
|
}
|
260
258
|
|
261
259
|
CAWrap *
|
262
|
-
ca_wrap_new (int8_t data_type, int8_t
|
260
|
+
ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
263
261
|
CArray *mask, char *ptr)
|
264
262
|
{
|
265
263
|
CAWrap *ca = ALLOC(CAWrap);
|
266
|
-
ca_wrap_setup(ca, data_type,
|
264
|
+
ca_wrap_setup(ca, data_type, ndim, dim, bytes, mask, ptr);
|
267
265
|
return ca;
|
268
266
|
}
|
269
267
|
|
270
268
|
CAWrap *
|
271
|
-
ca_wrap_new_null (int8_t data_type, int8_t
|
269
|
+
ca_wrap_new_null (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
272
270
|
CArray *mask)
|
273
271
|
{
|
274
272
|
CAWrap *ca = ALLOC(CAWrap);
|
275
|
-
ca_wrap_setup_null(ca, data_type,
|
273
|
+
ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, mask);
|
276
274
|
return ca;
|
277
275
|
}
|
278
276
|
|
@@ -313,7 +311,7 @@ cscalar_setup (CScalar *ca,
|
|
313
311
|
ca->obj_type = CA_OBJ_SCALAR;
|
314
312
|
ca->data_type = data_type;
|
315
313
|
ca->flags = 0;
|
316
|
-
ca->
|
314
|
+
ca->ndim = 1;
|
317
315
|
ca->bytes = bytes;
|
318
316
|
ca->elements = 1;
|
319
317
|
ca->dim = &(ca->_dim);
|
@@ -388,7 +386,7 @@ ca_array_func_clone (void *ap)
|
|
388
386
|
{
|
389
387
|
CArray *ca = (CArray *) ap;
|
390
388
|
CArray *co;
|
391
|
-
co = carray_new(ca->data_type, ca->
|
389
|
+
co = carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->mask);
|
392
390
|
memcpy(co->ptr, ca->ptr, ca_length(ca));
|
393
391
|
return co;
|
394
392
|
}
|
@@ -407,9 +405,9 @@ ca_array_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
407
405
|
ca_size_t *dim = ca->dim;
|
408
406
|
int8_t i;
|
409
407
|
ca_size_t n;
|
410
|
-
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[
|
411
|
-
for (i=1; i<ca->
|
412
|
-
n = dim[i]*n+idx[i]; /* ... + idx[
|
408
|
+
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
|
409
|
+
for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
|
410
|
+
n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
|
413
411
|
}
|
414
412
|
return ca->ptr + ca->bytes * n;
|
415
413
|
}
|
@@ -429,7 +427,7 @@ ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
429
427
|
int8_t i;
|
430
428
|
ca_size_t n;
|
431
429
|
n = idx[0];
|
432
|
-
for (i=1; i<ca->
|
430
|
+
for (i=1; i<ca->ndim; i++) {
|
433
431
|
n = dim[i]*n+idx[i];
|
434
432
|
}
|
435
433
|
memcpy(ptr, ca->ptr + ca->bytes * n, ca->bytes);
|
@@ -450,7 +448,7 @@ ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
450
448
|
int8_t i;
|
451
449
|
ca_size_t n;
|
452
450
|
n = idx[0];
|
453
|
-
for (i=1; i<ca->
|
451
|
+
for (i=1; i<ca->ndim; i++) {
|
454
452
|
n = dim[i]*n+idx[i];
|
455
453
|
}
|
456
454
|
memcpy(ca->ptr + ca->bytes * n, ptr, ca->bytes);
|
@@ -547,7 +545,7 @@ void
|
|
547
545
|
ca_array_func_create_mask (void *ap)
|
548
546
|
{
|
549
547
|
CArray *ca = (CArray *) ap;
|
550
|
-
ca->mask = carray_new_safe(CA_BOOLEAN, ca->
|
548
|
+
ca->mask = carray_new_safe(CA_BOOLEAN, ca->ndim, ca->dim, 0, NULL);
|
551
549
|
}
|
552
550
|
|
553
551
|
ca_operation_function_t ca_array_func = {
|
@@ -654,18 +652,27 @@ ca_operation_function_t ca_scalar_func = {
|
|
654
652
|
/* ------------------------------------------------------------------- */
|
655
653
|
|
656
654
|
VALUE
|
657
|
-
rb_carray_new (int8_t data_type, int8_t
|
655
|
+
rb_carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
658
656
|
CArray *mask)
|
659
657
|
{
|
660
|
-
CArray *ca = carray_new(data_type,
|
658
|
+
CArray *ca = carray_new(data_type, ndim, dim, bytes, mask);
|
661
659
|
return ca_wrap_struct(ca);
|
662
660
|
}
|
663
661
|
|
664
662
|
VALUE
|
665
|
-
rb_carray_new_safe (int8_t data_type, int8_t
|
663
|
+
rb_carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
666
664
|
CArray *mask)
|
667
665
|
{
|
668
|
-
CArray *ca = carray_new_safe(data_type,
|
666
|
+
CArray *ca = carray_new_safe(data_type, ndim, dim, bytes, mask);
|
667
|
+
return ca_wrap_struct(ca);
|
668
|
+
}
|
669
|
+
|
670
|
+
|
671
|
+
VALUE
|
672
|
+
rb_ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
673
|
+
CArray *mask, char *ptr)
|
674
|
+
{
|
675
|
+
CAWrap *ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
|
669
676
|
return ca_wrap_struct(ca);
|
670
677
|
}
|
671
678
|
|
@@ -699,20 +706,16 @@ rb_ca_s_allocate (VALUE klass)
|
|
699
706
|
return Data_Make_Struct(klass, CArray, ca_mark, ca_free, ca);
|
700
707
|
}
|
701
708
|
|
702
|
-
/*
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
# effect. If the block is given, the new CArray
|
713
|
-
# object will be initialized by the value returned from the block.
|
714
|
-
def CArray.new(data_type, dim, bytes=0)
|
715
|
-
end
|
709
|
+
/* @overload initialize(data_type, dim, bytes=0) { ... }
|
710
|
+
|
711
|
+
Constructs a new CArray object of <i>data_type</i>, which has the
|
712
|
+
ndim and the dimensions specified by an <code>Array</code> of
|
713
|
+
<code>Integer</code> or an argument list of <code>Integer</code>.
|
714
|
+
The byte size of each element for the fixed length data type
|
715
|
+
(<code>data_type == CA_FIXLEN</code>) is specified optional argument
|
716
|
+
<i>bytes</i>. Otherwise, this optional argument has no
|
717
|
+
effect. If the block is given, the new CArray
|
718
|
+
object will be initialized by the value returned from the block.
|
716
719
|
*/
|
717
720
|
|
718
721
|
static VALUE
|
@@ -720,7 +723,7 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
|
|
720
723
|
{
|
721
724
|
volatile VALUE rtype, rdim, ropt, rbytes = Qnil;
|
722
725
|
CArray *ca;
|
723
|
-
int8_t data_type,
|
726
|
+
int8_t data_type, ndim;
|
724
727
|
ca_size_t dim[CA_RANK_MAX];
|
725
728
|
ca_size_t bytes;
|
726
729
|
int8_t i;
|
@@ -732,13 +735,13 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
|
|
732
735
|
rb_ca_data_type_import(self, rtype);
|
733
736
|
|
734
737
|
Check_Type(rdim, T_ARRAY);
|
735
|
-
|
736
|
-
for (i=0; i<
|
738
|
+
ndim = RARRAY_LEN(rdim);
|
739
|
+
for (i=0; i<ndim; i++) {
|
737
740
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
738
741
|
}
|
739
742
|
|
740
743
|
Data_Get_Struct(self, CArray, ca);
|
741
|
-
carray_safe_setup(ca, data_type,
|
744
|
+
carray_safe_setup(ca, data_type, ndim, dim, bytes, NULL);
|
742
745
|
|
743
746
|
if ( rb_block_given_p() ) {
|
744
747
|
volatile VALUE rval = rb_yield(self);
|
@@ -750,6 +753,12 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
|
|
750
753
|
return Qnil;
|
751
754
|
}
|
752
755
|
|
756
|
+
/* @overload fixlen(*dim, bytes: ) { ... }
|
757
|
+
|
758
|
+
(Construction)
|
759
|
+
Short-Hand of `CArray.new(:fixlen, dim, bytes: ) { ... }`
|
760
|
+
*/
|
761
|
+
|
753
762
|
static VALUE
|
754
763
|
rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
|
755
764
|
{
|
@@ -759,56 +768,184 @@ rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
|
|
759
768
|
return rb_class_new_instance(3, args, klass);
|
760
769
|
}
|
761
770
|
|
762
|
-
#define
|
763
|
-
|
764
|
-
{
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
771
|
+
#define rb_ca_s_body(code) \
|
772
|
+
{ \
|
773
|
+
if ( argc == 0 ) { \
|
774
|
+
return ca_data_type_class(code); \
|
775
|
+
} \
|
776
|
+
else { \
|
777
|
+
volatile VALUE ropt = rb_pop_options(&argc, &argv); \
|
778
|
+
volatile VALUE rdim = rb_ary_new4(argc, argv); \
|
779
|
+
VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
|
780
|
+
return rb_class_new_instance(3, args, klass); \
|
781
|
+
} \
|
769
782
|
}
|
770
783
|
|
771
|
-
/*
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
*
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
784
|
+
/* @overload boolean(*dim) { ... }
|
785
|
+
|
786
|
+
(Construction)
|
787
|
+
Short-Hand of `CArray.new(:boolean, dim, bytes: bytes) { ... }`
|
788
|
+
*/
|
789
|
+
static VALUE rb_ca_s_boolean (int argc, VALUE *argv, VALUE klass)
|
790
|
+
{
|
791
|
+
rb_ca_s_body(CA_BOOLEAN);
|
792
|
+
}
|
793
|
+
|
794
|
+
/* @overload int8(*dim) { ... }
|
795
|
+
|
796
|
+
(Construction)
|
797
|
+
Short-Hand of `CArray.new(:int8, dim, bytes: bytes) { ... }`
|
798
|
+
*/
|
799
|
+
static VALUE rb_ca_s_int8 (int argc, VALUE *argv, VALUE klass)
|
800
|
+
{
|
801
|
+
rb_ca_s_body(CA_INT8);
|
802
|
+
}
|
803
|
+
|
804
|
+
/* @overload uint8(*dim) { ... }
|
805
|
+
|
806
|
+
(Construction)
|
807
|
+
Short-Hand of `CArray.new(:uint8, dim, bytes: bytes) { ... }`
|
808
|
+
*/
|
809
|
+
static VALUE rb_ca_s_uint8 (int argc, VALUE *argv, VALUE klass)
|
810
|
+
{
|
811
|
+
rb_ca_s_body(CA_UINT8);
|
812
|
+
}
|
813
|
+
|
814
|
+
/* @overload int16(*dim) { ... }
|
815
|
+
|
816
|
+
(Construction)
|
817
|
+
Short-Hand of `CArray.new(:int16, dim, bytes: bytes) { ... }`
|
818
|
+
*/
|
819
|
+
static VALUE rb_ca_s_int16 (int argc, VALUE *argv, VALUE klass)
|
820
|
+
{
|
821
|
+
rb_ca_s_body(CA_INT16);
|
822
|
+
}
|
823
|
+
|
824
|
+
/* @overload uint16(*dim) { ... }
|
825
|
+
|
826
|
+
(Construction)
|
827
|
+
Short-Hand of `CArray.new(:uint16, dim, bytes: bytes) { ... }`
|
828
|
+
*/
|
829
|
+
static VALUE rb_ca_s_uint16 (int argc, VALUE *argv, VALUE klass)
|
830
|
+
{
|
831
|
+
rb_ca_s_body(CA_UINT16);
|
832
|
+
}
|
833
|
+
|
834
|
+
/* @overload int32(*dim) { ... }
|
835
|
+
|
836
|
+
(Construction)
|
837
|
+
Short-Hand of `CArray.new(:int32, dim, bytes: bytes) { ... }`
|
838
|
+
*/
|
839
|
+
static VALUE rb_ca_s_int32 (int argc, VALUE *argv, VALUE klass)
|
840
|
+
{
|
841
|
+
rb_ca_s_body(CA_INT32);
|
842
|
+
}
|
843
|
+
|
844
|
+
/* @overload uint32(*dim) { ... }
|
845
|
+
|
846
|
+
(Construction)
|
847
|
+
Short-Hand of `CArray.new(:uint32, dim, bytes: bytes) { ... }`
|
848
|
+
*/
|
849
|
+
static VALUE rb_ca_s_uint32 (int argc, VALUE *argv, VALUE klass)
|
850
|
+
{
|
851
|
+
rb_ca_s_body(CA_UINT32);
|
852
|
+
}
|
853
|
+
|
854
|
+
/* @overload int64(*dim) { ... }
|
855
|
+
|
856
|
+
(Construction)
|
857
|
+
Short-Hand of `CArray.new(:int64, dim, bytes: bytes) { ... }`
|
858
|
+
*/
|
859
|
+
static VALUE rb_ca_s_int64 (int argc, VALUE *argv, VALUE klass)
|
860
|
+
{
|
861
|
+
rb_ca_s_body(CA_INT64);
|
862
|
+
}
|
863
|
+
|
864
|
+
/* @overload uint64(*dim) { ... }
|
865
|
+
|
866
|
+
(Construction)
|
867
|
+
Short-Hand of `CArray.new(:uint64, dim, bytes: bytes) { ... }`
|
868
|
+
*/
|
869
|
+
static VALUE rb_ca_s_uint64 (int argc, VALUE *argv, VALUE klass)
|
870
|
+
{
|
871
|
+
rb_ca_s_body(CA_UINT64);
|
872
|
+
}
|
873
|
+
|
874
|
+
/* @overload float32(*dim) { ... }
|
875
|
+
|
876
|
+
(Construction)
|
877
|
+
Short-Hand of `CArray.new(:float32, dim, bytes: bytes) { ... }`
|
878
|
+
*/
|
879
|
+
static VALUE rb_ca_s_float32 (int argc, VALUE *argv, VALUE klass)
|
880
|
+
{
|
881
|
+
rb_ca_s_body(CA_FLOAT32);
|
882
|
+
}
|
883
|
+
|
884
|
+
/* @overload float64(*dim) { ... }
|
885
|
+
|
886
|
+
(Construction)
|
887
|
+
Short-Hand of `CArray.new(:float64, dim, bytes: bytes) { ... }`
|
888
|
+
*/
|
889
|
+
static VALUE rb_ca_s_float64 (int argc, VALUE *argv, VALUE klass)
|
890
|
+
{
|
891
|
+
rb_ca_s_body(CA_FLOAT64);
|
892
|
+
}
|
893
|
+
|
894
|
+
/* @overload float128(*dim) { ... }
|
895
|
+
|
896
|
+
(Construction)
|
897
|
+
Short-Hand of `CArray.new(:float128, dim, bytes: bytes) { ... }`
|
898
|
+
*/
|
899
|
+
static VALUE rb_ca_s_float128 (int argc, VALUE *argv, VALUE klass)
|
900
|
+
{
|
901
|
+
rb_ca_s_body(CA_FLOAT128);
|
902
|
+
}
|
790
903
|
|
791
|
-
static VALUE rb_ca_s_VALUE();
|
792
|
-
|
793
|
-
static VALUE rb_ca_s_type(boolean, CA_BOOLEAN);
|
794
|
-
static VALUE rb_ca_s_type(int8, CA_INT8);
|
795
|
-
static VALUE rb_ca_s_type(uint8, CA_UINT8);
|
796
|
-
static VALUE rb_ca_s_type(int16, CA_INT16);
|
797
|
-
static VALUE rb_ca_s_type(uint16, CA_UINT16);
|
798
|
-
static VALUE rb_ca_s_type(int32, CA_INT32);
|
799
|
-
static VALUE rb_ca_s_type(uint32, CA_UINT32);
|
800
|
-
static VALUE rb_ca_s_type(int64, CA_INT64);
|
801
|
-
static VALUE rb_ca_s_type(uint64, CA_UINT64);
|
802
|
-
static VALUE rb_ca_s_type(float32, CA_FLOAT32);
|
803
|
-
static VALUE rb_ca_s_type(float64, CA_FLOAT64);
|
804
|
-
static VALUE rb_ca_s_type(float128, CA_FLOAT128);
|
805
904
|
#ifdef HAVE_COMPLEX_H
|
806
|
-
|
807
|
-
|
808
|
-
|
905
|
+
/* @overload cmplx64(*dim) { ... }
|
906
|
+
|
907
|
+
(Construction)
|
908
|
+
Short-Hand of `CArray.new(:cmplx64, dim, bytes: bytes) { ... }`
|
909
|
+
*/
|
910
|
+
static VALUE rb_ca_s_cmplx64 (int argc, VALUE *argv, VALUE klass)
|
911
|
+
{
|
912
|
+
rb_ca_s_body(CA_CMPLX64);
|
913
|
+
}
|
914
|
+
|
915
|
+
/* @overload cmplx128(*dim) { ... }
|
916
|
+
|
917
|
+
(Construction)
|
918
|
+
Short-Hand of `CArray.new(:cmplx128, dim, bytes: bytes) { ... }`
|
919
|
+
*/
|
920
|
+
static VALUE rb_ca_s_cmplx128 (int argc, VALUE *argv, VALUE klass)
|
921
|
+
{
|
922
|
+
rb_ca_s_body(CA_CMPLX128);
|
923
|
+
}
|
924
|
+
|
925
|
+
/* @overload cmplx256(*dim) { ... }
|
926
|
+
|
927
|
+
(Construction)
|
928
|
+
Short-Hand of `CArray.new(:cmplx256, dim, bytes: bytes) { ... }`
|
929
|
+
*/
|
930
|
+
static VALUE rb_ca_s_cmplx256 (int argc, VALUE *argv, VALUE klass)
|
931
|
+
{
|
932
|
+
rb_ca_s_body(CA_CMPLX256);
|
933
|
+
}
|
809
934
|
#endif
|
810
|
-
static VALUE rb_ca_s_type(VALUE, CA_OBJECT);
|
811
935
|
|
936
|
+
/* @overload object(*dim) { ... }
|
937
|
+
|
938
|
+
(Construction)
|
939
|
+
Short-Hand of `CArray.new(:object, dim, bytes: bytes) { ... }`
|
940
|
+
*/
|
941
|
+
static VALUE rb_ca_s_VALUE (int argc, VALUE *argv, VALUE klass)
|
942
|
+
{
|
943
|
+
rb_ca_s_body(CA_OBJECT);
|
944
|
+
}
|
945
|
+
|
946
|
+
/* @overload initialize_copy(other)
|
947
|
+
|
948
|
+
*/
|
812
949
|
static VALUE
|
813
950
|
rb_ca_initialize_copy (VALUE self, VALUE other)
|
814
951
|
{
|
@@ -820,16 +957,17 @@ rb_ca_initialize_copy (VALUE self, VALUE other)
|
|
820
957
|
Data_Get_Struct(other, CArray, cs);
|
821
958
|
|
822
959
|
ca_update_mask(cs);
|
823
|
-
carray_setup(ca, cs->data_type, cs->
|
960
|
+
carray_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes, cs->mask);
|
824
961
|
|
825
962
|
memcpy(ca->ptr, cs->ptr, ca_length(cs));
|
826
963
|
|
827
964
|
return self;
|
828
965
|
}
|
829
966
|
|
830
|
-
/*
|
831
|
-
|
832
|
-
|
967
|
+
/* @overload wrap (data_type, dim, bytes=0) { target }
|
968
|
+
|
969
|
+
[TBD] (Construction)
|
970
|
+
target should have method "wrap_as_carray(obj)"
|
833
971
|
*/
|
834
972
|
|
835
973
|
static VALUE
|
@@ -837,7 +975,7 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
837
975
|
{
|
838
976
|
volatile VALUE obj, target, rtype, rdim, ropt, rbytes = Qnil;
|
839
977
|
CArray *ca;
|
840
|
-
int8_t data_type,
|
978
|
+
int8_t data_type, ndim;
|
841
979
|
ca_size_t dim[CA_RANK_MAX];
|
842
980
|
ca_size_t bytes;
|
843
981
|
int8_t i;
|
@@ -848,15 +986,15 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
848
986
|
rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
|
849
987
|
|
850
988
|
Check_Type(rdim, T_ARRAY);
|
851
|
-
|
852
|
-
for (i=0; i<
|
989
|
+
ndim = RARRAY_LEN(rdim);
|
990
|
+
for (i=0; i<ndim; i++) {
|
853
991
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
854
992
|
}
|
855
993
|
|
856
994
|
target = rb_yield_values(0);
|
857
995
|
|
858
996
|
obj = Data_Make_Struct(rb_cCAWrap, CAWrap, ca_mark, ca_free, ca);
|
859
|
-
ca_wrap_setup_null(ca, data_type,
|
997
|
+
ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, NULL);
|
860
998
|
|
861
999
|
rb_funcall(target, rb_intern("wrap_as_carray"), 1, obj);
|
862
1000
|
rb_ivar_set(obj, rb_intern("referred_object"), target);
|
@@ -865,13 +1003,13 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
865
1003
|
}
|
866
1004
|
|
867
1005
|
VALUE
|
868
|
-
rb_carray_wrap_ptr (int8_t data_type, int8_t
|
1006
|
+
rb_carray_wrap_ptr (int8_t data_type, int8_t ndim, ca_size_t *dim,
|
869
1007
|
ca_size_t bytes, CArray *mask, char *ptr, VALUE refer)
|
870
1008
|
{
|
871
1009
|
volatile VALUE obj;
|
872
1010
|
CArray *ca;
|
873
1011
|
|
874
|
-
ca = ca_wrap_new(data_type,
|
1012
|
+
ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
|
875
1013
|
obj = ca_wrap_struct(ca);
|
876
1014
|
|
877
1015
|
rb_ivar_set(obj, rb_intern("referred_object"), refer);
|
@@ -888,16 +1026,16 @@ rb_cs_s_allocate (VALUE klass)
|
|
888
1026
|
return Data_Make_Struct(klass, CScalar, ca_mark, ca_free, ca);
|
889
1027
|
}
|
890
1028
|
|
891
|
-
/*
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
1029
|
+
/*
|
1030
|
+
call-seq:
|
1031
|
+
CScalar.new(data_type, bytes=0) { ... }
|
1032
|
+
|
1033
|
+
Constructs a new CScalar object of <i>data_type</i>.
|
1034
|
+
The byte size of each element for the fixed length data type
|
1035
|
+
(<code>data_type == CA_FIXLEN</code>) is specified optional argument
|
1036
|
+
<i>bytes</i>. Otherwise, this optional argument has no
|
1037
|
+
effect. If the block is given, the new CScalar
|
1038
|
+
object will be initialized by the value returned from the block.
|
901
1039
|
def CScalar.new(data_type,bytes=0)
|
902
1040
|
end
|
903
1041
|
*/
|
@@ -929,6 +1067,12 @@ rb_cs_initialize (int argc, VALUE *argv, VALUE self)
|
|
929
1067
|
return Qnil;
|
930
1068
|
}
|
931
1069
|
|
1070
|
+
/* @overload fixlen(*dim, bytes: ) { ... }
|
1071
|
+
|
1072
|
+
(Construction)
|
1073
|
+
Short-Hand of `CScalar.new(:fixlen, bytes: ) { ... }`
|
1074
|
+
*/
|
1075
|
+
|
932
1076
|
static VALUE
|
933
1077
|
rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
|
934
1078
|
{
|
@@ -940,8 +1084,7 @@ rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
|
|
940
1084
|
return rb_class_new_instance(2, args, klass);
|
941
1085
|
}
|
942
1086
|
|
943
|
-
#define
|
944
|
-
rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
|
1087
|
+
#define rb_cs_s_body(code) \
|
945
1088
|
{ \
|
946
1089
|
volatile VALUE ropt = rb_pop_options(&argc, &argv); \
|
947
1090
|
VALUE args[2] = { INT2NUM(code), ropt }; \
|
@@ -951,47 +1094,172 @@ rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
|
|
951
1094
|
return rb_class_new_instance(2, args, klass); \
|
952
1095
|
}
|
953
1096
|
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
static VALUE
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
1097
|
+
/* @overload boolean() { ... }
|
1098
|
+
|
1099
|
+
(Construction)
|
1100
|
+
Short-Hand of `CArray.new(:boolean) { ... }`
|
1101
|
+
*/
|
1102
|
+
static VALUE
|
1103
|
+
rb_cs_s_boolean (int argc, VALUE *argv, VALUE klass) {
|
1104
|
+
rb_cs_s_body(CA_BOOLEAN);
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
/* @overload int8() { ... }
|
1108
|
+
|
1109
|
+
(Construction)
|
1110
|
+
Short-Hand of `CScalar.new(:int8) { ... }`
|
1111
|
+
*/
|
1112
|
+
static VALUE
|
1113
|
+
rb_cs_s_int8 (int argc, VALUE *argv, VALUE klass) {
|
1114
|
+
rb_cs_s_body(CA_INT8);
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
/* @overload uint8() { ... }
|
1118
|
+
|
1119
|
+
(Construction)
|
1120
|
+
Short-Hand of `CScalar.new(:uint8) { ... }`
|
1121
|
+
*/
|
1122
|
+
static VALUE
|
1123
|
+
rb_cs_s_uint8 (int argc, VALUE *argv, VALUE klass) {
|
1124
|
+
rb_cs_s_body(CA_UINT8);
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
|
1128
|
+
/* @overload int16() { ... }
|
1129
|
+
|
1130
|
+
(Construction)
|
1131
|
+
Short-Hand of `CScalar.new(:int16) { ... }`
|
1132
|
+
*/
|
1133
|
+
static VALUE
|
1134
|
+
rb_cs_s_int16 (int argc, VALUE *argv, VALUE klass) {
|
1135
|
+
rb_cs_s_body(CA_INT16);
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
/* @overload uint16() { ... }
|
1139
|
+
|
1140
|
+
(Construction)
|
1141
|
+
Short-Hand of `CScalar.new(:uint16) { ... }`
|
1142
|
+
*/
|
1143
|
+
static VALUE
|
1144
|
+
rb_cs_s_uint16 (int argc, VALUE *argv, VALUE klass) {
|
1145
|
+
rb_cs_s_body(CA_UINT16);
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
/* @overload int32() { ... }
|
1149
|
+
|
1150
|
+
(Construction)
|
1151
|
+
Short-Hand of `CScalar.new(:int32) { ... }`
|
1152
|
+
*/
|
1153
|
+
static VALUE
|
1154
|
+
rb_cs_s_int32 (int argc, VALUE *argv, VALUE klass) {
|
1155
|
+
rb_cs_s_body(CA_INT32);
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
/* @overload uint32() { ... }
|
1159
|
+
|
1160
|
+
(Construction)
|
1161
|
+
Short-Hand of `CScalar.new(:uint32) { ... }`
|
1162
|
+
*/
|
1163
|
+
static VALUE
|
1164
|
+
rb_cs_s_uint32 (int argc, VALUE *argv, VALUE klass) {
|
1165
|
+
rb_cs_s_body(CA_UINT32);
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
/* @overload int64() { ... }
|
1169
|
+
|
1170
|
+
(Construction)
|
1171
|
+
Short-Hand of `CScalar.new(:int64) { ... }`
|
1172
|
+
*/
|
1173
|
+
static VALUE
|
1174
|
+
rb_cs_s_int64 (int argc, VALUE *argv, VALUE klass) {
|
1175
|
+
rb_cs_s_body(CA_INT64);
|
1176
|
+
}
|
1177
|
+
|
1178
|
+
/* @overload uint64() { ... }
|
1179
|
+
|
1180
|
+
(Construction)
|
1181
|
+
Short-Hand of `CScalar.new(:uint64) { ... }`
|
1182
|
+
*/
|
1183
|
+
static VALUE
|
1184
|
+
rb_cs_s_uint64 (int argc, VALUE *argv, VALUE klass) {
|
1185
|
+
rb_cs_s_body(CA_UINT64);
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
/* @overload float32() { ... }
|
1189
|
+
|
1190
|
+
(Construction)
|
1191
|
+
Short-Hand of `CScalar.new(:float32) { ... }`
|
1192
|
+
*/
|
1193
|
+
static VALUE
|
1194
|
+
rb_cs_s_float32 (int argc, VALUE *argv, VALUE klass) {
|
1195
|
+
rb_cs_s_body(CA_FLOAT32);
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
/* @overload float64() { ... }
|
1199
|
+
|
1200
|
+
(Construction)
|
1201
|
+
Short-Hand of `CScalar.new(:float64) { ... }`
|
1202
|
+
*/
|
1203
|
+
static VALUE
|
1204
|
+
rb_cs_s_float64 (int argc, VALUE *argv, VALUE klass) {
|
1205
|
+
rb_cs_s_body(CA_FLOAT64);
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
/* @overload float128() { ... }
|
1209
|
+
|
1210
|
+
(Construction)
|
1211
|
+
Short-Hand of `CScalar.new(:float128) { ... }`
|
1212
|
+
*/
|
1213
|
+
static VALUE
|
1214
|
+
rb_cs_s_float128 (int argc, VALUE *argv, VALUE klass) {
|
1215
|
+
rb_cs_s_body(CA_FLOAT128);
|
1216
|
+
}
|
1217
|
+
|
966
1218
|
#ifdef HAVE_COMPLEX_H
|
967
|
-
|
968
|
-
|
969
|
-
|
1219
|
+
/* @overload cmplx64() { ... }
|
1220
|
+
|
1221
|
+
(Construction)
|
1222
|
+
Short-Hand of `CScalar.new(:cmplx64) { ... }`
|
1223
|
+
*/
|
1224
|
+
static VALUE
|
1225
|
+
rb_cs_s_cmplx64 (int argc, VALUE *argv, VALUE klass) {
|
1226
|
+
rb_cs_s_body(CA_CMPLX64);
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
/* @overload cmplx128() { ... }
|
1230
|
+
|
1231
|
+
(Construction)
|
1232
|
+
Short-Hand of `CScalar.new(:cmplx128) { ... }`
|
1233
|
+
*/
|
1234
|
+
static VALUE
|
1235
|
+
rb_cs_s_cmplx128 (int argc, VALUE *argv, VALUE klass) {
|
1236
|
+
rb_cs_s_body(CA_CMPLX128);
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
/* @overload cmplx256() { ... }
|
1240
|
+
|
1241
|
+
(Construction)
|
1242
|
+
Short-Hand of `CScalar.new(:cmplx256) { ... }`
|
1243
|
+
*/
|
1244
|
+
static VALUE
|
1245
|
+
rb_cs_s_cmplx256 (int argc, VALUE *argv, VALUE klass) {
|
1246
|
+
rb_cs_s_body(CA_CMPLX256);
|
1247
|
+
}
|
970
1248
|
#endif
|
971
|
-
static VALUE rb_cs_s_type(VALUE, CA_OBJECT);
|
972
1249
|
|
973
|
-
/*
|
974
|
-
* call-seq:
|
975
|
-
* CScalar.int8() { ... } -> CScalar
|
976
|
-
* CScalar.uint8() { ... } -> CScalar
|
977
|
-
* CScalar.int16() { ... } -> CScalar
|
978
|
-
* CScalar.uint16() { ... } -> CScalar
|
979
|
-
* CScalar.int32() { ... } -> CScalar
|
980
|
-
* CScalar.uint32() { ... } -> CScalar
|
981
|
-
* CScalar.int64() { ... } -> CScalar
|
982
|
-
* CScalar.uint64() { ... } -> CScalar
|
983
|
-
* CScalar.float32() { ... } -> CScalar
|
984
|
-
* CScalar.float64() { ... } -> CScalar
|
985
|
-
* CScalar.float128() { ... } -> CScalar
|
986
|
-
* CScalar.cmplx64() { ... } -> CScalar
|
987
|
-
* CScalar.cmplx128() { ... } -> CScalar
|
988
|
-
* CScalar.cmplx256() { ... } -> CScalar
|
989
|
-
* CScalar.object() { ... } -> CScalar
|
990
|
-
*
|
991
|
-
*/
|
1250
|
+
/* @overload object() { ... }
|
992
1251
|
|
993
|
-
|
994
|
-
|
1252
|
+
(Construction)
|
1253
|
+
Short-Hand of `CScalar.new(:object) { ... }`
|
1254
|
+
*/
|
1255
|
+
static VALUE
|
1256
|
+
rb_cs_s_VALUE (int argc, VALUE *argv, VALUE klass) {
|
1257
|
+
rb_cs_s_body(CA_OBJECT);
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
/* @overload initialize_copy(other)
|
1261
|
+
|
1262
|
+
*/
|
995
1263
|
|
996
1264
|
static VALUE
|
997
1265
|
rb_cs_initialize_copy (VALUE self, VALUE other)
|
@@ -1026,6 +1294,10 @@ rb_cs_coerce (VALUE self, VALUE other)
|
|
1026
1294
|
}
|
1027
1295
|
*/
|
1028
1296
|
|
1297
|
+
/* @private
|
1298
|
+
@overload mem_usage
|
1299
|
+
*/
|
1300
|
+
|
1029
1301
|
static VALUE
|
1030
1302
|
rb_ca_mem_usage (VALUE self)
|
1031
1303
|
{
|
@@ -1041,7 +1313,10 @@ Init_ca_obj_array ()
|
|
1041
1313
|
|
1042
1314
|
/* ------------------------------------------------------------------- */
|
1043
1315
|
ca_gc_interval = ca_default_gc_interval;
|
1316
|
+
|
1317
|
+
/* @private */
|
1044
1318
|
rb_define_const(rb_cCArray, "DEFAULT_GC_INTERVAL", rb_float_new(ca_default_gc_interval));
|
1319
|
+
|
1045
1320
|
rb_define_singleton_method(rb_cCArray, "gc_interval", rb_ca_get_gc_interval, 0);
|
1046
1321
|
rb_define_singleton_method(rb_cCArray, "gc_interval=", rb_ca_set_gc_interval, 1);
|
1047
1322
|
rb_define_singleton_method(rb_cCArray, "reset_gc_interval", rb_ca_reset_gc_interval, 0);
|
@@ -1130,7 +1405,7 @@ Init_ca_obj_array ()
|
|
1130
1405
|
}
|
1131
1406
|
|
1132
1407
|
|
1133
|
-
/*
|
1408
|
+
/* yard:
|
1134
1409
|
# call-seq:
|
1135
1410
|
# CArray.boolean(...) { init_value }
|
1136
1411
|
# CArray.int8(...) { init_value }
|