carray 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSES +22 -0
- data/README.md +18 -14
- data/Rakefile +1 -1
- data/carray.gemspec +5 -13
- data/{ca_iter_block.c → ext/ca_iter_block.c} +13 -13
- data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +16 -16
- data/{ca_iter_window.c → ext/ca_iter_window.c} +10 -10
- data/{ca_obj_array.c → ext/ca_obj_array.c} +60 -55
- data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +12 -12
- data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +7 -7
- data/{ca_obj_block.c → ext/ca_obj_block.c} +42 -42
- data/{ca_obj_fake.c → ext/ca_obj_fake.c} +7 -7
- data/{ca_obj_farray.c → ext/ca_obj_farray.c} +18 -18
- data/{ca_obj_field.c → ext/ca_obj_field.c} +15 -15
- data/{ca_obj_grid.c → ext/ca_obj_grid.c} +27 -27
- data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +9 -9
- data/{ca_obj_object.c → ext/ca_obj_object.c} +37 -37
- data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +1 -1
- data/{ca_obj_refer.c → ext/ca_obj_refer.c} +33 -33
- data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +43 -43
- data/{ca_obj_select.c → ext/ca_obj_select.c} +2 -2
- data/{ca_obj_shift.c → ext/ca_obj_shift.c} +23 -23
- data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +23 -23
- data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +55 -55
- data/{ca_obj_window.c → ext/ca_obj_window.c} +26 -26
- data/{carray.h → ext/carray.h} +73 -51
- data/{carray_access.c → ext/carray_access.c} +83 -83
- data/{carray_attribute.c → ext/carray_attribute.c} +12 -12
- data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +0 -0
- data/{carray_cast.c → ext/carray_cast.c} +6 -6
- data/{carray_cast_func.rb → ext/carray_cast_func.rb} +0 -0
- data/{carray_class.c → ext/carray_class.c} +0 -0
- data/{carray_conversion.c → ext/carray_conversion.c} +8 -10
- data/{carray_copy.c → ext/carray_copy.c} +19 -19
- data/{carray_core.c → ext/carray_core.c} +2 -2
- data/ext/carray_data_type.c +66 -0
- data/{carray_element.c → ext/carray_element.c} +9 -9
- data/{carray_generate.c → ext/carray_generate.c} +0 -0
- data/{carray_iterator.c → ext/carray_iterator.c} +40 -38
- data/{carray_loop.c → ext/carray_loop.c} +24 -24
- data/{carray_mask.c → ext/carray_mask.c} +17 -6
- data/{carray_math.rb → ext/carray_math.rb} +3 -3
- data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +0 -0
- data/{carray_numeric.c → ext/carray_numeric.c} +1 -1
- data/{carray_operator.c → ext/carray_operator.c} +9 -9
- data/{carray_order.c → ext/carray_order.c} +2 -153
- data/{carray_sort_addr.c → ext/carray_sort_addr.c} +0 -0
- data/{carray_stat.c → ext/carray_stat.c} +5 -5
- data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +23 -23
- data/{carray_test.c → ext/carray_test.c} +22 -21
- data/{carray_undef.c → ext/carray_undef.c} +0 -0
- data/{carray_utils.c → ext/carray_utils.c} +0 -0
- data/{extconf.rb → ext/extconf.rb} +0 -5
- data/{mkmath.rb → ext/mkmath.rb} +0 -0
- data/{ruby_carray.c → ext/ruby_carray.c} +9 -2
- data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +0 -0
- data/{ruby_float_func.c → ext/ruby_float_func.c} +0 -0
- data/{version.h → ext/version.h} +5 -5
- data/{version.rb → ext/version.rb} +0 -0
- data/lib/carray.rb +48 -37
- data/lib/carray/{base/autoload.rb → autoload.rb} +1 -1
- data/lib/carray/autoload/autoload_base.rb +1 -1
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +4 -3
- data/lib/carray/autoload/autoload_gem_random.rb +8 -0
- data/lib/carray/basic.rb +193 -0
- data/lib/carray/compose.rb +291 -0
- data/lib/carray/construct.rb +445 -0
- data/lib/carray/convert.rb +115 -0
- data/lib/carray/{base/inspect.rb → inspect.rb} +6 -6
- data/lib/carray/io/imagemagick.rb +1 -1
- data/lib/carray/{base/iterator.rb → iterator.rb} +3 -3
- data/lib/carray/mask.rb +91 -0
- data/lib/carray/{base/math.rb → math.rb} +16 -46
- data/lib/carray/math/histogram.rb +7 -7
- data/lib/carray/mkmf.rb +8 -0
- data/lib/carray/object/ca_obj_pack.rb +8 -8
- data/lib/carray/obsolete.rb +272 -0
- data/lib/carray/ordering.rb +157 -0
- data/lib/carray/{base/serialize.rb → serialize.rb} +28 -53
- data/lib/carray/{base/string.rb → string.rb} +12 -64
- data/lib/carray/{base/struct.rb → struct.rb} +16 -16
- data/lib/carray/{io/table.rb → table.rb} +1 -10
- data/lib/carray/testing.rb +56 -0
- data/lib/carray/time.rb +78 -0
- data/lib/carray/transform.rb +100 -0
- data/misc/Methods.ja.md +182 -0
- data/{NOTE → misc/NOTE} +0 -0
- data/test/test_ALL.rb +0 -2
- data/test/test_order.rb +7 -7
- data/test/test_ref_store.rb +13 -13
- data/test/test_stat.rb +7 -15
- data/{devel → utils}/guess_shape.rb +0 -0
- data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
- metadata +88 -151
- data/COPYING +0 -56
- data/GPL +0 -340
- data/LEGAL +0 -50
- data/TODO +0 -5
- data/carray_random.c +0 -531
- data/devel/im2col.rb +0 -17
- data/ext/calculus/carray_calculus.c +0 -931
- data/ext/calculus/carray_interp.c +0 -358
- data/ext/calculus/extconf.rb +0 -12
- data/ext/calculus/lib/math/calculus.rb +0 -119
- data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
- data/ext/mathfunc/extconf.rb +0 -18
- data/ext/mathfunc/test/test_hypot.rb +0 -5
- data/ext/mathfunc/test/test_j0.rb +0 -22
- data/ext/mathfunc/test/test_jn.rb +0 -8
- data/ext/mathfunc/test/test_sph.rb +0 -9
- data/lib/carray/autoload/autoload_io_table.rb +0 -1
- data/lib/carray/autoload/autoload_math_interp.rb +0 -4
- data/lib/carray/base/basic.rb +0 -1146
- data/lib/carray/base/obsolete.rb +0 -131
- data/lib/carray/math/interp.rb +0 -57
- data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
- data/mt19937ar.c +0 -182
- data/mt19937ar.h +0 -86
- data/rdoc_main.rb +0 -27
- data/rdoc_math.rb +0 -5
- data/rdoc_stat.rb +0 -31
- data/test/test_narray.rb +0 -64
- data/test/test_random.rb +0 -15
- data/utils/create_rdoc.sh +0 -9
- data/utils/make_tgz.sh +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9609f31c4eacaf87ca9881eff5e29e30cfde413086a30b0ee99e02d9142b105f
|
4
|
+
data.tar.gz: 68c4a6919c28b78ee9c9fd7a469b65ef8069a6ceba880f37a1a32f37f3de24d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910d317c356accdc8852490a209991443f964e2e9e3896b41b62456104699049fa99d59341a176eba752d83b49765044c1282b9b1a439f8ba949c661b2950689
|
7
|
+
data.tar.gz: 7036c72836edf32445979d8d72312da7b2c8a68e9a15101f75caa4a6ea804d97254ba9cc76c99b8bde691d0049ca8474ab88924c0acfdc6e73b84d9098077d37
|
data/LICENSES
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2020 Hiroki Motoyoshi.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -3,34 +3,38 @@ Ruby/CArray
|
|
3
3
|
|
4
4
|
Ruby/CArray is an extension library for the multi-dimensional array class.
|
5
5
|
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
|
9
|
+
* Multidimensional array for storing uniform data
|
10
|
+
* Various ways to access data elements
|
11
|
+
* Masks for each element to handle missing values
|
12
|
+
* Element-wise operations and mathematical functions
|
13
|
+
* Statistical functions for the elements
|
14
|
+
* Indirect data manipulation for original array by virtual array
|
15
|
+
* Special iterators (dimension, block, window, categorical)
|
16
|
+
* User-defined array
|
17
|
+
* Storing fixed length data with data_class
|
18
|
+
* Memory sharing with other objects (Experimental)
|
19
|
+
|
6
20
|
Requirements
|
7
21
|
------------
|
8
22
|
|
9
|
-
* Ruby 2.
|
23
|
+
* Ruby 2.4.0 or later
|
10
24
|
* C compiler
|
11
25
|
+ IEEE754 floating point number
|
12
26
|
+ C99 complex number
|
13
|
-
* Optional command
|
14
|
-
+ ImageMagick (stream, convert, display, identify)
|
15
27
|
|
16
28
|
Directories
|
17
29
|
-----------
|
18
30
|
|
19
31
|
. - Ruby/CArray extension source codes
|
20
32
|
lib - Ruby/CArray standard library in Ruby
|
21
|
-
ext - optional extension libraries for Ruby/CArray
|
22
|
-
examples - some examples
|
23
33
|
test - some unit tests (incomplete)
|
24
34
|
spec - some rspec (incomplete)
|
25
35
|
utils - support tools for development.
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Hiroki Motoyoshi
|
31
|
-
|
32
|
-
Copying
|
33
|
-
-------
|
37
|
+
Licenses
|
38
|
+
--------
|
34
39
|
|
35
|
-
|
36
|
-
the Ruby Licence. See the file 'COPYING' in this directory.
|
40
|
+
MIT (after version 1.5.0)
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ GEMSPEC = "carray.gemspec"
|
|
6
6
|
|
7
7
|
task :install do
|
8
8
|
spec = eval File.read(GEMSPEC)
|
9
|
-
version_h = `ruby version.rb`.chomp
|
9
|
+
version_h = `ruby ext/version.rb`.chomp
|
10
10
|
if spec.version.to_s != version_h
|
11
11
|
STDERR.puts "Mismatch in version between carray.gemspec and version.h"
|
12
12
|
STDERR.puts " carray.gemspec - #{spec.version.to_s }"
|
data/carray.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification::new do |s|
|
2
2
|
|
3
|
-
version = "1.
|
3
|
+
version = "1.5.1"
|
4
4
|
|
5
5
|
files = Dir.glob("**/*") - [
|
6
6
|
Dir.glob("carray-*.gem"),
|
@@ -12,7 +12,7 @@ Gem::Specification::new do |s|
|
|
12
12
|
|
13
13
|
s.platform = Gem::Platform::RUBY
|
14
14
|
s.name = "carray"
|
15
|
-
s.summary = "Multi-dimesional array class"
|
15
|
+
s.summary = "Multi-dimesional array class for Ruby"
|
16
16
|
s.description = <<-HERE
|
17
17
|
CArray is a uniform multi-dimensional rectangular array class.
|
18
18
|
It provides the various types of sub-arrays and references
|
@@ -22,18 +22,10 @@ Gem::Specification::new do |s|
|
|
22
22
|
s.version = version
|
23
23
|
s.author = "Hiroki Motoyoshi"
|
24
24
|
s.email = ""
|
25
|
+
s.licenses = ['MIT']
|
25
26
|
s.homepage = 'https://github.com/himotoyoshi/carray'
|
26
27
|
s.files = files
|
27
|
-
s.extensions = [ "extconf.rb" ]
|
28
|
-
|
29
|
-
s.rdoc_options = [
|
30
|
-
"-m rdoc_main.rb",
|
31
|
-
"rdoc_main.rb",
|
32
|
-
"rdoc_ext.rb",
|
33
|
-
"rdoc_math.rb",
|
34
|
-
"rdoc_stat.rb",
|
35
|
-
Dir.glob("lib/carray/**/*.rb"),
|
36
|
-
].flatten
|
37
|
-
s.required_ruby_version = ">= 1.8.1"
|
28
|
+
s.extensions = [ "ext/extconf.rb" ]
|
29
|
+
s.required_ruby_version = ">= 2.4.0"
|
38
30
|
end
|
39
31
|
|
@@ -23,7 +23,7 @@ VALUE rb_cCABlockIterator;
|
|
23
23
|
typedef struct {
|
24
24
|
int16_t obj_type;
|
25
25
|
int8_t data_type;
|
26
|
-
int8_t
|
26
|
+
int8_t ndim;
|
27
27
|
int32_t flags;
|
28
28
|
ca_size_t bytes;
|
29
29
|
ca_size_t elements;
|
@@ -42,11 +42,11 @@ typedef struct {
|
|
42
42
|
ca_size_t *step;
|
43
43
|
ca_size_t *count;
|
44
44
|
ca_size_t *size0;
|
45
|
-
} CABlock; // 68 + 20*(
|
45
|
+
} CABlock; // 68 + 20*(ndim) (bytes)
|
46
46
|
*/
|
47
47
|
|
48
48
|
typedef struct {
|
49
|
-
int8_t
|
49
|
+
int8_t ndim;
|
50
50
|
ca_size_t dim[CA_RANK_MAX];
|
51
51
|
CArray *reference;
|
52
52
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -73,14 +73,14 @@ ca_bi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
|
|
73
73
|
else {
|
74
74
|
CABlock *ck = (CABlock *)bit->kernel;
|
75
75
|
kernel = ca_block_new(ref,
|
76
|
-
ck->
|
76
|
+
ck->ndim, ck->size0,
|
77
77
|
ck->start, ck->step, ck->count,
|
78
78
|
ck->offset);
|
79
79
|
}
|
80
80
|
|
81
81
|
ca_update_mask(kernel);
|
82
82
|
|
83
|
-
for (i=0; i<kernel->
|
83
|
+
for (i=0; i<kernel->ndim; i++) {
|
84
84
|
j = idx[i];
|
85
85
|
CA_CHECK_INDEX(j, bit->dim[i]);
|
86
86
|
kernel->start[i] += j * kernel->dim[i];
|
@@ -99,7 +99,7 @@ ca_bi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
|
|
99
99
|
ca_size_t *dim = bit->dim;
|
100
100
|
ca_size_t idx[CA_RANK_MAX];
|
101
101
|
int8_t i;
|
102
|
-
for (i=bit->
|
102
|
+
for (i=bit->ndim-1; i>=0; i--) {
|
103
103
|
idx[i] = addr % dim[i];
|
104
104
|
addr /= dim[i];
|
105
105
|
}
|
@@ -117,7 +117,7 @@ ca_bi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
|
|
117
117
|
|
118
118
|
ca_update_mask(kernel);
|
119
119
|
|
120
|
-
for (i=0; i<kernel->
|
120
|
+
for (i=0; i<kernel->ndim; i++) {
|
121
121
|
j = idx[i];
|
122
122
|
CA_CHECK_INDEX(j, bit->dim[i]);
|
123
123
|
kernel->start[i] = j * kernel->dim[i];
|
@@ -136,7 +136,7 @@ ca_bi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
|
|
136
136
|
ca_size_t *dim = bit->dim;
|
137
137
|
ca_size_t idx[CA_RANK_MAX];
|
138
138
|
int8_t i;
|
139
|
-
for (i=bit->
|
139
|
+
for (i=bit->ndim-1; i>=0; i--) {
|
140
140
|
idx[i] = addr % dim[i];
|
141
141
|
addr /= dim[i];
|
142
142
|
}
|
@@ -158,11 +158,11 @@ ca_bi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
158
158
|
Data_Get_Struct(rref, CArray, ref);
|
159
159
|
Data_Get_Struct(rker, CABlock, ker);
|
160
160
|
|
161
|
-
if ( ref->
|
162
|
-
rb_raise(rb_eRuntimeError, "
|
161
|
+
if ( ref->ndim != ker->ndim ) {
|
162
|
+
rb_raise(rb_eRuntimeError, "ndim mismatch between reference and kernel");
|
163
163
|
}
|
164
164
|
|
165
|
-
for (i=0; i<ref->
|
165
|
+
for (i=0; i<ref->ndim; i++) {
|
166
166
|
if ( ker->step[i] != 1 ) {
|
167
167
|
rb_raise(rb_eRuntimeError, "block should be contiguous");
|
168
168
|
}
|
@@ -174,8 +174,8 @@ ca_bi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
174
174
|
*/
|
175
175
|
}
|
176
176
|
|
177
|
-
it->
|
178
|
-
memcpy(it->dim, dim, it->
|
177
|
+
it->ndim = ref->ndim;
|
178
|
+
memcpy(it->dim, dim, it->ndim * sizeof(ca_size_t));
|
179
179
|
it->reference = ref;
|
180
180
|
it->kernel = ker;
|
181
181
|
it->kernel_at_addr = ca_bi_kernel_at_addr;
|
@@ -21,7 +21,7 @@ VALUE rb_cCADimIterator;
|
|
21
21
|
*/
|
22
22
|
|
23
23
|
typedef struct {
|
24
|
-
int8_t
|
24
|
+
int8_t ndim;
|
25
25
|
ca_size_t dim[CA_RANK_MAX];
|
26
26
|
CArray *reference;
|
27
27
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -50,14 +50,14 @@ ca_di_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
|
|
50
50
|
else {
|
51
51
|
CABlock *ck = (CABlock *)dit->kernel;
|
52
52
|
kernel = ca_block_new(ref,
|
53
|
-
ck->
|
53
|
+
ck->ndim, ck->size0,
|
54
54
|
ck->start, ck->step, ck->count,
|
55
55
|
ck->offset);
|
56
56
|
}
|
57
57
|
|
58
58
|
ca_update_mask(kernel);
|
59
59
|
|
60
|
-
for (i=0; i<dit->
|
60
|
+
for (i=0; i<dit->ndim; i++) {
|
61
61
|
val = idx[i];
|
62
62
|
CA_CHECK_INDEX(val, dit->dim[i]);
|
63
63
|
kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
|
@@ -77,7 +77,7 @@ ca_di_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
|
|
77
77
|
ca_size_t *dim = dit->dim;
|
78
78
|
ca_size_t idx[CA_RANK_MAX];
|
79
79
|
int8_t i;
|
80
|
-
for (i=dit->
|
80
|
+
for (i=dit->ndim-1; i>=0; i--) {
|
81
81
|
idx[i] = addr % dim[i];
|
82
82
|
addr /= dim[i];
|
83
83
|
}
|
@@ -94,7 +94,7 @@ ca_di_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
|
|
94
94
|
|
95
95
|
ca_update_mask(kernel);
|
96
96
|
|
97
|
-
for (i=0; i<dit->
|
97
|
+
for (i=0; i<dit->ndim; i++) {
|
98
98
|
val = idx[i];
|
99
99
|
CA_CHECK_INDEX(val, dit->dim[i]);
|
100
100
|
kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
|
@@ -114,7 +114,7 @@ ca_di_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
|
|
114
114
|
ca_size_t *dim = dit->dim;
|
115
115
|
ca_size_t idx[CA_RANK_MAX];
|
116
116
|
int8_t i;
|
117
|
-
for (i=dit->
|
117
|
+
for (i=dit->ndim-1; i>=0; i--) {
|
118
118
|
idx[i] = addr % dim[i];
|
119
119
|
addr /= dim[i];
|
120
120
|
}
|
@@ -129,7 +129,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
129
129
|
volatile VALUE rindex, rker, rsymtbl;
|
130
130
|
CADimIterator *it;
|
131
131
|
CAIndexInfo blk_spec;
|
132
|
-
int8_t
|
132
|
+
int8_t ndim;
|
133
133
|
int i, j, k;
|
134
134
|
|
135
135
|
Data_Get_Struct(self, CADimIterator, it);
|
@@ -142,7 +142,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
142
142
|
|
143
143
|
blk_spec = *info;
|
144
144
|
blk_spec.type = CA_REG_BLOCK;
|
145
|
-
for (i=0; i<info->
|
145
|
+
for (i=0; i<info->ndim; i++) {
|
146
146
|
if ( info->index_type[i] == CA_IDX_SYMBOL ) {
|
147
147
|
blk_spec.index_type[i] = CA_IDX_ALL;
|
148
148
|
rb_hash_aset(rsymtbl, ID2SYM(blk_spec.index[i].symbol.id), INT2NUM(i));
|
@@ -151,13 +151,13 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
151
151
|
|
152
152
|
rref = rb_ca_ref_block(rref, &blk_spec);
|
153
153
|
|
154
|
-
rindex = rb_ary_new2(info->
|
155
|
-
|
154
|
+
rindex = rb_ary_new2(info->ndim);
|
155
|
+
ndim = 0;
|
156
156
|
|
157
157
|
j = 0;
|
158
158
|
k = 0;
|
159
159
|
|
160
|
-
for (i=0; i<info->
|
160
|
+
for (i=0; i<info->ndim; i++) {
|
161
161
|
if ( info->index_type[i] == CA_IDX_SCALAR ) {
|
162
162
|
rb_ary_store(rindex, i, SIZE2NUM(info->index[i].scalar));
|
163
163
|
continue; /* escape from j++ */
|
@@ -165,8 +165,8 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
165
165
|
else if ( info->index_type[i] == CA_IDX_SYMBOL ) {
|
166
166
|
rb_ary_store(rindex, i, rb_ary_new3(1, SIZE2NUM(0)));
|
167
167
|
it->symflag[j] = 1;
|
168
|
-
it->symindex[
|
169
|
-
|
168
|
+
it->symindex[ndim] = j;
|
169
|
+
ndim++;
|
170
170
|
}
|
171
171
|
else if ( info->index_type[i] == CA_IDX_ALL ) {
|
172
172
|
rb_ary_store(rindex, i, Qnil);
|
@@ -184,7 +184,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
184
184
|
|
185
185
|
rker = rb_apply(rref, rb_intern("[]"), rindex);
|
186
186
|
|
187
|
-
it->
|
187
|
+
it->ndim = ndim;
|
188
188
|
Data_Get_Struct(rref, CArray, it->reference);
|
189
189
|
Data_Get_Struct(rker, CArray, it->kernel);
|
190
190
|
it->kernel_at_addr = ca_di_kernel_at_addr;
|
@@ -192,7 +192,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
|
|
192
192
|
it->kernel_move_to_addr = ca_di_kernel_move_to_addr;
|
193
193
|
it->kernel_move_to_index = ca_di_kernel_move_to_index;
|
194
194
|
|
195
|
-
for (i=0; i<it->
|
195
|
+
for (i=0; i<it->ndim; i++) {
|
196
196
|
it->dim[i] = it->reference->dim[it->symindex[i]];
|
197
197
|
}
|
198
198
|
|
@@ -239,7 +239,7 @@ rb_ca_dim_iterator (int argc, VALUE *argv, VALUE self)
|
|
239
239
|
|
240
240
|
Data_Get_Struct(self, CArray, ca);
|
241
241
|
|
242
|
-
rb_ca_scan_index(ca->
|
242
|
+
rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
|
243
243
|
|
244
244
|
obj = rb_di_s_allocate(rb_cCADimIterator);
|
245
245
|
ca_di_setup(obj, self, &info);
|
@@ -13,7 +13,7 @@
|
|
13
13
|
#include "carray.h"
|
14
14
|
|
15
15
|
typedef struct {
|
16
|
-
int8_t
|
16
|
+
int8_t ndim;
|
17
17
|
ca_size_t dim[CA_RANK_MAX];
|
18
18
|
CArray *reference;
|
19
19
|
CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
|
@@ -59,7 +59,7 @@ ca_vi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
|
|
59
59
|
|
60
60
|
ca_update_mask(kernel);
|
61
61
|
|
62
|
-
for (i=0; i<kernel->
|
62
|
+
for (i=0; i<kernel->ndim; i++) {
|
63
63
|
j = idx[i];
|
64
64
|
CA_CHECK_INDEX(j, vit->dim[i]);
|
65
65
|
kernel->start[i] = j - vit->offset[i];
|
@@ -78,7 +78,7 @@ ca_vi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
|
|
78
78
|
ca_size_t *dim = vit->dim;
|
79
79
|
ca_size_t idx[CA_RANK_MAX];
|
80
80
|
int8_t i;
|
81
|
-
for (i=vit->
|
81
|
+
for (i=vit->ndim-1; i>=0; i--) {
|
82
82
|
idx[i] = addr % dim[i];
|
83
83
|
addr /= dim[i];
|
84
84
|
}
|
@@ -97,7 +97,7 @@ ca_vi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
|
|
97
97
|
|
98
98
|
ca_update_mask(kernel);
|
99
99
|
|
100
|
-
for (i=0; i<kernel->
|
100
|
+
for (i=0; i<kernel->ndim; i++) {
|
101
101
|
j = idx[i];
|
102
102
|
CA_CHECK_INDEX(j, dim[i]);
|
103
103
|
kernel->start[i] = j - offset[i];
|
@@ -116,7 +116,7 @@ ca_vi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
|
|
116
116
|
ca_size_t *dim = vit->dim;
|
117
117
|
ca_size_t idx[CA_RANK_MAX];
|
118
118
|
int8_t i;
|
119
|
-
for (i=vit->
|
119
|
+
for (i=vit->ndim-1; i>=0; i--) {
|
120
120
|
idx[i] = addr % dim[i];
|
121
121
|
addr /= dim[i];
|
122
122
|
}
|
@@ -136,12 +136,12 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
136
136
|
Data_Get_Struct(rref, CArray, ref);
|
137
137
|
Data_Get_Struct(rker, CArray, ker);
|
138
138
|
|
139
|
-
if ( ref->
|
140
|
-
rb_raise(rb_eRuntimeError, "
|
139
|
+
if ( ref->ndim != ker->ndim ) {
|
140
|
+
rb_raise(rb_eRuntimeError, "ndim mismatch between reference and kernel");
|
141
141
|
}
|
142
142
|
|
143
|
-
it->
|
144
|
-
memcpy(it->dim, ref->dim, it->
|
143
|
+
it->ndim = ref->ndim;
|
144
|
+
memcpy(it->dim, ref->dim, it->ndim * sizeof(ca_size_t));
|
145
145
|
it->reference = ref;
|
146
146
|
it->kernel = ker;
|
147
147
|
it->kernel_at_addr = ca_vi_kernel_at_addr;
|
@@ -149,7 +149,7 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
|
|
149
149
|
it->kernel_move_to_addr = ca_vi_kernel_move_to_addr;
|
150
150
|
it->kernel_move_to_index = ca_vi_kernel_move_to_index;
|
151
151
|
|
152
|
-
for (i=0; i<it->
|
152
|
+
for (i=0; i<it->ndim; i++) {
|
153
153
|
it->offset[i] = -(((CAWindow*)ker)->start[i]);
|
154
154
|
}
|
155
155
|
|
@@ -42,7 +42,7 @@ double ca_mem_count = 0.0;
|
|
42
42
|
|
43
43
|
/* Threshold for forced garbage collection and its default value */
|
44
44
|
double ca_gc_interval;
|
45
|
-
const double ca_default_gc_interval =
|
45
|
+
const double ca_default_gc_interval = 100.0; /* 100MB */
|
46
46
|
|
47
47
|
#define MB (1024*1024)
|
48
48
|
|
@@ -117,7 +117,7 @@ rb_ca_reset_gc_interval (VALUE self)
|
|
117
117
|
|
118
118
|
static int
|
119
119
|
carray_setup_i (CArray *ca,
|
120
|
-
int8_t data_type, int8_t
|
120
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
121
121
|
CArray *mask, int allocate, int use_calloc)
|
122
122
|
{
|
123
123
|
ca_size_t elements;
|
@@ -127,14 +127,14 @@ carray_setup_i (CArray *ca,
|
|
127
127
|
|
128
128
|
/* check arguments */
|
129
129
|
CA_CHECK_DATA_TYPE(data_type);
|
130
|
-
CA_CHECK_RANK(
|
131
|
-
CA_CHECK_DIM(
|
130
|
+
CA_CHECK_RANK(ndim);
|
131
|
+
CA_CHECK_DIM(ndim, dim);
|
132
132
|
CA_CHECK_BYTES(data_type, bytes);
|
133
133
|
|
134
134
|
/* calculate total number of elements */
|
135
135
|
elements = 1;
|
136
136
|
length = bytes;
|
137
|
-
for (i=0; i<
|
137
|
+
for (i=0; i<ndim; i++) {
|
138
138
|
elements *= dim[i];
|
139
139
|
length *= dim[i];
|
140
140
|
}
|
@@ -153,11 +153,11 @@ carray_setup_i (CArray *ca,
|
|
153
153
|
|
154
154
|
ca->data_type = data_type;
|
155
155
|
ca->flags = 0;
|
156
|
-
ca->
|
156
|
+
ca->ndim = ndim;
|
157
157
|
ca->bytes = bytes;
|
158
158
|
ca->elements = elements;
|
159
|
-
ca->dim = ALLOC_N(ca_size_t,
|
160
|
-
memcpy(ca->dim, dim,
|
159
|
+
ca->dim = ALLOC_N(ca_size_t, ndim);
|
160
|
+
memcpy(ca->dim, dim, ndim*sizeof(ca_size_t));
|
161
161
|
|
162
162
|
if ( allocate ) { /* allocate == true */
|
163
163
|
|
@@ -201,26 +201,26 @@ carray_setup_i (CArray *ca,
|
|
201
201
|
|
202
202
|
int
|
203
203
|
carray_setup (CArray *ca,
|
204
|
-
int8_t data_type, int8_t
|
204
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
|
205
205
|
{
|
206
|
-
return carray_setup_i(ca, data_type,
|
206
|
+
return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 0);
|
207
207
|
}
|
208
208
|
|
209
209
|
int
|
210
210
|
carray_safe_setup (CArray *ca,
|
211
|
-
int8_t data_type, int8_t
|
211
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
|
212
212
|
{
|
213
|
-
return carray_setup_i(ca, data_type,
|
213
|
+
return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 1);
|
214
214
|
}
|
215
215
|
|
216
216
|
int
|
217
217
|
ca_wrap_setup (CArray *ca,
|
218
|
-
int8_t data_type, int8_t
|
218
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
219
219
|
CArray *mask, char *ptr)
|
220
220
|
{
|
221
221
|
int ret;
|
222
222
|
|
223
|
-
ret = carray_setup_i(ca, data_type,
|
223
|
+
ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
|
224
224
|
if ( (!ptr) && (ca->elements != 0) ) {
|
225
225
|
rb_raise(rb_eRuntimeError, "wrapping NULL pointer with an non-empty array");
|
226
226
|
}
|
@@ -230,49 +230,49 @@ ca_wrap_setup (CArray *ca,
|
|
230
230
|
|
231
231
|
int
|
232
232
|
ca_wrap_setup_null (CArray *ca,
|
233
|
-
int8_t data_type, int8_t
|
233
|
+
int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
234
234
|
CArray *mask)
|
235
235
|
{
|
236
236
|
int ret;
|
237
237
|
|
238
|
-
ret = carray_setup_i(ca, data_type,
|
238
|
+
ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
|
239
239
|
ca->ptr = NULL;
|
240
240
|
return ret;
|
241
241
|
}
|
242
242
|
|
243
243
|
CArray *
|
244
|
-
carray_new (int8_t data_type, int8_t
|
244
|
+
carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
245
245
|
CArray *mask)
|
246
246
|
{
|
247
247
|
CArray *ca = ALLOC(CArray);
|
248
|
-
carray_setup(ca, data_type,
|
248
|
+
carray_setup(ca, data_type, ndim, dim, bytes, mask);
|
249
249
|
return ca;
|
250
250
|
}
|
251
251
|
|
252
252
|
CArray *
|
253
|
-
carray_new_safe (int8_t data_type, int8_t
|
253
|
+
carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
254
254
|
CArray *mask)
|
255
255
|
{
|
256
256
|
CArray *ca = ALLOC(CArray);
|
257
|
-
carray_safe_setup(ca, data_type,
|
257
|
+
carray_safe_setup(ca, data_type, ndim, dim, bytes, mask);
|
258
258
|
return ca;
|
259
259
|
}
|
260
260
|
|
261
261
|
CAWrap *
|
262
|
-
ca_wrap_new (int8_t data_type, int8_t
|
262
|
+
ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
263
263
|
CArray *mask, char *ptr)
|
264
264
|
{
|
265
265
|
CAWrap *ca = ALLOC(CAWrap);
|
266
|
-
ca_wrap_setup(ca, data_type,
|
266
|
+
ca_wrap_setup(ca, data_type, ndim, dim, bytes, mask, ptr);
|
267
267
|
return ca;
|
268
268
|
}
|
269
269
|
|
270
270
|
CAWrap *
|
271
|
-
ca_wrap_new_null (int8_t data_type, int8_t
|
271
|
+
ca_wrap_new_null (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
272
272
|
CArray *mask)
|
273
273
|
{
|
274
274
|
CAWrap *ca = ALLOC(CAWrap);
|
275
|
-
ca_wrap_setup_null(ca, data_type,
|
275
|
+
ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, mask);
|
276
276
|
return ca;
|
277
277
|
}
|
278
278
|
|
@@ -313,7 +313,7 @@ cscalar_setup (CScalar *ca,
|
|
313
313
|
ca->obj_type = CA_OBJ_SCALAR;
|
314
314
|
ca->data_type = data_type;
|
315
315
|
ca->flags = 0;
|
316
|
-
ca->
|
316
|
+
ca->ndim = 1;
|
317
317
|
ca->bytes = bytes;
|
318
318
|
ca->elements = 1;
|
319
319
|
ca->dim = &(ca->_dim);
|
@@ -388,7 +388,7 @@ ca_array_func_clone (void *ap)
|
|
388
388
|
{
|
389
389
|
CArray *ca = (CArray *) ap;
|
390
390
|
CArray *co;
|
391
|
-
co = carray_new(ca->data_type, ca->
|
391
|
+
co = carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->mask);
|
392
392
|
memcpy(co->ptr, ca->ptr, ca_length(ca));
|
393
393
|
return co;
|
394
394
|
}
|
@@ -407,9 +407,9 @@ ca_array_func_ptr_at_index (void *ap, ca_size_t *idx)
|
|
407
407
|
ca_size_t *dim = ca->dim;
|
408
408
|
int8_t i;
|
409
409
|
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[
|
410
|
+
n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
|
411
|
+
for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
|
412
|
+
n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
|
413
413
|
}
|
414
414
|
return ca->ptr + ca->bytes * n;
|
415
415
|
}
|
@@ -429,7 +429,7 @@ ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
|
429
429
|
int8_t i;
|
430
430
|
ca_size_t n;
|
431
431
|
n = idx[0];
|
432
|
-
for (i=1; i<ca->
|
432
|
+
for (i=1; i<ca->ndim; i++) {
|
433
433
|
n = dim[i]*n+idx[i];
|
434
434
|
}
|
435
435
|
memcpy(ptr, ca->ptr + ca->bytes * n, ca->bytes);
|
@@ -450,7 +450,7 @@ ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
|
450
450
|
int8_t i;
|
451
451
|
ca_size_t n;
|
452
452
|
n = idx[0];
|
453
|
-
for (i=1; i<ca->
|
453
|
+
for (i=1; i<ca->ndim; i++) {
|
454
454
|
n = dim[i]*n+idx[i];
|
455
455
|
}
|
456
456
|
memcpy(ca->ptr + ca->bytes * n, ptr, ca->bytes);
|
@@ -547,7 +547,7 @@ void
|
|
547
547
|
ca_array_func_create_mask (void *ap)
|
548
548
|
{
|
549
549
|
CArray *ca = (CArray *) ap;
|
550
|
-
ca->mask = carray_new_safe(CA_BOOLEAN, ca->
|
550
|
+
ca->mask = carray_new_safe(CA_BOOLEAN, ca->ndim, ca->dim, 0, NULL);
|
551
551
|
}
|
552
552
|
|
553
553
|
ca_operation_function_t ca_array_func = {
|
@@ -654,18 +654,18 @@ ca_operation_function_t ca_scalar_func = {
|
|
654
654
|
/* ------------------------------------------------------------------- */
|
655
655
|
|
656
656
|
VALUE
|
657
|
-
rb_carray_new (int8_t data_type, int8_t
|
657
|
+
rb_carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
658
658
|
CArray *mask)
|
659
659
|
{
|
660
|
-
CArray *ca = carray_new(data_type,
|
660
|
+
CArray *ca = carray_new(data_type, ndim, dim, bytes, mask);
|
661
661
|
return ca_wrap_struct(ca);
|
662
662
|
}
|
663
663
|
|
664
664
|
VALUE
|
665
|
-
rb_carray_new_safe (int8_t data_type, int8_t
|
665
|
+
rb_carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
|
666
666
|
CArray *mask)
|
667
667
|
{
|
668
|
-
CArray *ca = carray_new_safe(data_type,
|
668
|
+
CArray *ca = carray_new_safe(data_type, ndim, dim, bytes, mask);
|
669
669
|
return ca_wrap_struct(ca);
|
670
670
|
}
|
671
671
|
|
@@ -704,7 +704,7 @@ rb_ca_s_allocate (VALUE klass)
|
|
704
704
|
# CArray.new(data_type, dim, bytes=0) { ... }
|
705
705
|
#
|
706
706
|
# Constructs a new CArray object of <i>data_type</i>, which has the
|
707
|
-
#
|
707
|
+
# ndim and the dimensions specified by an <code>Array</code> of
|
708
708
|
# <code>Integer</code> or an argument list of <code>Integer</code>.
|
709
709
|
# The byte size of each element for the fixed length data type
|
710
710
|
# (<code>data_type == CA_FIXLEN</code>) is specified optional argument
|
@@ -720,7 +720,7 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
|
|
720
720
|
{
|
721
721
|
volatile VALUE rtype, rdim, ropt, rbytes = Qnil;
|
722
722
|
CArray *ca;
|
723
|
-
int8_t data_type,
|
723
|
+
int8_t data_type, ndim;
|
724
724
|
ca_size_t dim[CA_RANK_MAX];
|
725
725
|
ca_size_t bytes;
|
726
726
|
int8_t i;
|
@@ -732,13 +732,13 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
|
|
732
732
|
rb_ca_data_type_import(self, rtype);
|
733
733
|
|
734
734
|
Check_Type(rdim, T_ARRAY);
|
735
|
-
|
736
|
-
for (i=0; i<
|
735
|
+
ndim = RARRAY_LEN(rdim);
|
736
|
+
for (i=0; i<ndim; i++) {
|
737
737
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
738
738
|
}
|
739
739
|
|
740
740
|
Data_Get_Struct(self, CArray, ca);
|
741
|
-
carray_safe_setup(ca, data_type,
|
741
|
+
carray_safe_setup(ca, data_type, ndim, dim, bytes, NULL);
|
742
742
|
|
743
743
|
if ( rb_block_given_p() ) {
|
744
744
|
volatile VALUE rval = rb_yield(self);
|
@@ -759,13 +759,18 @@ rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
|
|
759
759
|
return rb_class_new_instance(3, args, klass);
|
760
760
|
}
|
761
761
|
|
762
|
-
#define rb_ca_s_type(type, code)
|
763
|
-
rb_ca_s_## type (int argc, VALUE *argv, VALUE klass)
|
764
|
-
{
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
762
|
+
#define rb_ca_s_type(type, code) \
|
763
|
+
rb_ca_s_## type (int argc, VALUE *argv, VALUE klass) \
|
764
|
+
{ \
|
765
|
+
if ( argc == 0 ) { \
|
766
|
+
return ca_data_type_class(code); \
|
767
|
+
} \
|
768
|
+
else { \
|
769
|
+
volatile VALUE ropt = rb_pop_options(&argc, &argv); \
|
770
|
+
volatile VALUE rdim = rb_ary_new4(argc, argv); \
|
771
|
+
VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
|
772
|
+
return rb_class_new_instance(3, args, klass); \
|
773
|
+
} \
|
769
774
|
}
|
770
775
|
|
771
776
|
/*
|
@@ -820,7 +825,7 @@ rb_ca_initialize_copy (VALUE self, VALUE other)
|
|
820
825
|
Data_Get_Struct(other, CArray, cs);
|
821
826
|
|
822
827
|
ca_update_mask(cs);
|
823
|
-
carray_setup(ca, cs->data_type, cs->
|
828
|
+
carray_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes, cs->mask);
|
824
829
|
|
825
830
|
memcpy(ca->ptr, cs->ptr, ca_length(cs));
|
826
831
|
|
@@ -837,7 +842,7 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
837
842
|
{
|
838
843
|
volatile VALUE obj, target, rtype, rdim, ropt, rbytes = Qnil;
|
839
844
|
CArray *ca;
|
840
|
-
int8_t data_type,
|
845
|
+
int8_t data_type, ndim;
|
841
846
|
ca_size_t dim[CA_RANK_MAX];
|
842
847
|
ca_size_t bytes;
|
843
848
|
int8_t i;
|
@@ -848,15 +853,15 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
848
853
|
rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
|
849
854
|
|
850
855
|
Check_Type(rdim, T_ARRAY);
|
851
|
-
|
852
|
-
for (i=0; i<
|
856
|
+
ndim = RARRAY_LEN(rdim);
|
857
|
+
for (i=0; i<ndim; i++) {
|
853
858
|
dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
|
854
859
|
}
|
855
860
|
|
856
861
|
target = rb_yield_values(0);
|
857
862
|
|
858
863
|
obj = Data_Make_Struct(rb_cCAWrap, CAWrap, ca_mark, ca_free, ca);
|
859
|
-
ca_wrap_setup_null(ca, data_type,
|
864
|
+
ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, NULL);
|
860
865
|
|
861
866
|
rb_funcall(target, rb_intern("wrap_as_carray"), 1, obj);
|
862
867
|
rb_ivar_set(obj, rb_intern("referred_object"), target);
|
@@ -865,13 +870,13 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
|
|
865
870
|
}
|
866
871
|
|
867
872
|
VALUE
|
868
|
-
rb_carray_wrap_ptr (int8_t data_type, int8_t
|
873
|
+
rb_carray_wrap_ptr (int8_t data_type, int8_t ndim, ca_size_t *dim,
|
869
874
|
ca_size_t bytes, CArray *mask, char *ptr, VALUE refer)
|
870
875
|
{
|
871
876
|
volatile VALUE obj;
|
872
877
|
CArray *ca;
|
873
878
|
|
874
|
-
ca = ca_wrap_new(data_type,
|
879
|
+
ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
|
875
880
|
obj = ca_wrap_struct(ca);
|
876
881
|
|
877
882
|
rb_ivar_set(obj, rb_intern("referred_object"), refer);
|