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
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,41 +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
|
-
* Optionally required gems
|
14
|
-
+ narray
|
15
|
-
+ narray_miss
|
16
|
-
+ axlsx
|
17
|
-
+ spreadsheet
|
18
|
-
+ sqlite3
|
19
|
-
* Optional command
|
20
|
-
+ Gnuplot
|
21
|
-
+ ImageMagick (stream, convert, display, identify)
|
22
27
|
|
23
28
|
Directories
|
24
29
|
-----------
|
25
30
|
|
26
31
|
. - Ruby/CArray extension source codes
|
27
32
|
lib - Ruby/CArray standard library in Ruby
|
28
|
-
ext - optional extension libraries for Ruby/CArray
|
29
|
-
examples - some examples
|
30
33
|
test - some unit tests (incomplete)
|
31
34
|
spec - some rspec (incomplete)
|
32
35
|
utils - support tools for development.
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Hiroki Motoyoshi
|
38
|
-
|
39
|
-
Copying
|
40
|
-
-------
|
37
|
+
Licenses
|
38
|
+
--------
|
41
39
|
|
42
|
-
|
43
|
-
the Ruby Licence. See the file 'COPYING' in this directory.
|
40
|
+
MIT (after version 1.5.0)
|
data/Rakefile
CHANGED
@@ -2,12 +2,43 @@
|
|
2
2
|
#
|
3
3
|
#
|
4
4
|
|
5
|
+
GEMSPEC = "carray.gemspec"
|
6
|
+
|
7
|
+
task :install do
|
8
|
+
spec = eval File.read(GEMSPEC)
|
9
|
+
version_h = `ruby ext/version.rb`.chomp
|
10
|
+
if spec.version.to_s != version_h
|
11
|
+
STDERR.puts "Mismatch in version between carray.gemspec and version.h"
|
12
|
+
STDERR.puts " carray.gemspec - #{spec.version.to_s }"
|
13
|
+
STDERR.puts " version.h - #{version_h}"
|
14
|
+
STDERR.puts "Please check!"
|
15
|
+
exit(1)
|
16
|
+
end
|
17
|
+
system %{
|
18
|
+
gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rspec/core/rake_task'
|
23
|
+
RSpec::Core::RakeTask.new
|
24
|
+
|
25
|
+
|
26
|
+
__END__
|
5
27
|
require 'rake'
|
6
28
|
require 'rake/testtask'
|
7
29
|
require 'rspec/core/rake_task'
|
8
30
|
|
9
31
|
task :default => :test
|
10
32
|
|
33
|
+
GEMSPEC = "carray.gemspec"
|
34
|
+
|
35
|
+
task :install do
|
36
|
+
spec = eval File.read(GEMSPEC)
|
37
|
+
system %{
|
38
|
+
gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
11
42
|
desc "Run the tests"
|
12
43
|
Rake::TestTask::new(:test) do |t|
|
13
44
|
t.test_files = FileList['test/test_ALL.rb']
|
data/carray.gemspec
CHANGED
@@ -1,21 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
Gem::Specification::new do |s|
|
4
|
-
|
5
|
-
|
6
|
-
version, date = carray_version()
|
2
|
+
|
3
|
+
version = "1.5.1"
|
7
4
|
|
8
5
|
files = Dir.glob("**/*") - [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
Dir.glob("carray-*.gem"),
|
7
|
+
Dir.glob("ext/**/{Makefile,mkmf.log}"),
|
8
|
+
Dir.glob("**/*.{o,so,bundle}"),
|
9
|
+
Dir.glob("**/*~"),
|
10
|
+
Dir.glob("doc/**/*"),
|
11
|
+
].flatten
|
15
12
|
|
16
13
|
s.platform = Gem::Platform::RUBY
|
17
14
|
s.name = "carray"
|
18
|
-
s.summary = "Multi-dimesional array class"
|
15
|
+
s.summary = "Multi-dimesional array class for Ruby"
|
19
16
|
s.description = <<-HERE
|
20
17
|
CArray is a uniform multi-dimensional rectangular array class.
|
21
18
|
It provides the various types of sub-arrays and references
|
@@ -25,20 +22,10 @@ Gem::Specification::new do |s|
|
|
25
22
|
s.version = version
|
26
23
|
s.author = "Hiroki Motoyoshi"
|
27
24
|
s.email = ""
|
25
|
+
s.licenses = ['MIT']
|
28
26
|
s.homepage = 'https://github.com/himotoyoshi/carray'
|
29
27
|
s.files = files
|
30
|
-
s.extensions = [ "extconf.rb" ]
|
31
|
-
|
32
|
-
s.rdoc_options = [
|
33
|
-
"-m rdoc_main.rb",
|
34
|
-
"rdoc_main.rb",
|
35
|
-
"rdoc_ext.rb",
|
36
|
-
"rdoc_math.rb",
|
37
|
-
"rdoc_stat.rb",
|
38
|
-
Dir.glob("lib/carray/**/*.rb"),
|
39
|
-
].flatten
|
40
|
-
s.required_ruby_version = ">= 1.8.1"
|
41
|
-
s.add_runtime_dependency 'narray', '~> 0.6.1.1'
|
42
|
-
s.add_runtime_dependency 'narray_miss', '~> 1.3'
|
43
|
-
s.add_runtime_dependency 'sqlite3', '~> 1.3'
|
28
|
+
s.extensions = [ "ext/extconf.rb" ]
|
29
|
+
s.required_ruby_version = ">= 2.4.0"
|
44
30
|
end
|
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
|
|