carray 1.5.2 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +32 -0
- data/NEWS.md +56 -3
- data/README.md +34 -18
- data/Rakefile +1 -1
- data/TODO.md +5 -4
- data/carray.gemspec +10 -11
- data/ext/ca_obj_bitarray.c +4 -7
- data/ext/ca_obj_bitfield.c +3 -5
- data/ext/ca_obj_block.c +1 -6
- data/ext/ca_obj_refer.c +6 -8
- data/ext/ca_obj_unbound_repeat.c +21 -52
- data/ext/carray.h +4 -0
- data/ext/carray_access.c +77 -45
- data/ext/carray_attribute.c +16 -1
- data/ext/carray_cast.c +1 -1
- data/ext/carray_conversion.c +8 -1
- data/ext/carray_core.c +22 -16
- data/ext/carray_generate.c +3 -3
- data/ext/carray_mask.c +12 -2
- data/ext/carray_math.rb +20 -2
- data/ext/carray_numeric.c +32 -51
- data/ext/carray_order.c +159 -0
- data/ext/carray_test.c +13 -0
- data/ext/carray_undef.c +0 -8
- data/ext/carray_utils.c +126 -47
- data/ext/extconf.rb +13 -1
- data/ext/mkmath.rb +1 -1
- data/ext/ruby_carray.c +8 -1
- data/ext/ruby_ccomplex.c +1 -1
- data/ext/version.h +4 -4
- data/lib/carray.rb +7 -9
- data/lib/carray/autoload.rb +0 -2
- data/lib/carray/basic.rb +3 -5
- data/lib/carray/broadcast.rb +78 -22
- data/lib/carray/compose.rb +34 -10
- data/lib/carray/construct.rb +36 -14
- data/lib/carray/info.rb +1 -3
- data/lib/carray/inspect.rb +3 -5
- data/lib/carray/io/imagemagick.rb +1 -3
- data/lib/carray/iterator.rb +2 -3
- data/lib/carray/mask.rb +18 -7
- data/lib/carray/math.rb +4 -6
- data/lib/carray/math/histogram.rb +1 -3
- data/lib/carray/math/recurrence.rb +1 -3
- data/lib/carray/mkmf.rb +1 -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 +1 -3
- data/lib/carray/obsolete.rb +1 -17
- data/lib/carray/ordering.rb +1 -3
- data/lib/carray/serialize.rb +34 -25
- data/lib/carray/string.rb +1 -3
- data/lib/carray/struct.rb +3 -5
- data/lib/carray/testing.rb +5 -10
- data/lib/carray/time.rb +1 -3
- data/lib/carray/transform.rb +12 -3
- data/misc/NOTE +16 -38
- data/spec/Classes/CAUnboudRepeat_spec.rb +24 -0
- data/spec/Features/feature_attributes_spec.rb +6 -6
- data/spec/Features/feature_boolean_spec.rb +15 -14
- data/spec/Features/feature_broadcast.rb +16 -0
- data/spec/Features/feature_cast_spec.rb +1 -1
- data/spec/Features/feature_mask_spec.rb +6 -0
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53f410eef744cd7d2c38db76556f150cbb1820054bc938fd39d6f45c09dce148
|
4
|
+
data.tar.gz: a3a8994279e0d7b56adbf5a5427390867c6f8fcc4bef5adacdd792a7865efc6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a07507ad136d73bc1cbc136853577546187fb5852450471d5ca149d8b8e5edebbd28a688391c0f27666327f90b69421885cea17cbdab6e78cb92ed6ca8844b
|
7
|
+
data.tar.gz: f62fedda0c4d535ed8686cc5a21c96db5e670eb5710eece004d75fc22fcbb89a8dc74b51d412eef65f55454b6885b699ff46b0d8d5c78cdf1413374613218b83
|
data/.yardopts
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
--markup markdown
|
2
|
+
--markup-provider redcarpet
|
3
|
+
--no-private
|
4
|
+
--exclude lib/carray/obsolete.rb
|
5
|
+
--exclude lib/carray/autoload.rb
|
6
|
+
--exclude 'lib/carray/autoload/'
|
7
|
+
--readme README.md
|
8
|
+
--files NEWS.md,TODO.md
|
9
|
+
lib/carray.rb
|
10
|
+
ext/ruby_carray.c
|
11
|
+
ext/ca_obj_array.c
|
12
|
+
ext/ca_obj_bitarray.c
|
13
|
+
ext/ca_obj_bitfield.c
|
14
|
+
ext/ca_obj_block.c
|
15
|
+
ext/carray_attribute.c
|
16
|
+
ext/carray_call_cfunc.c
|
17
|
+
ext/carray_cast.c
|
18
|
+
ext/carray_class.c
|
19
|
+
ext/carray_conversion.c
|
20
|
+
ext/carray_copy.c
|
21
|
+
ext/carray_core.c
|
22
|
+
ext/carray_data_type.c
|
23
|
+
ext/carray_element.c
|
24
|
+
ext/carray_generate.c
|
25
|
+
ext/carray_loop.c
|
26
|
+
ext/carray_mask.c
|
27
|
+
ext/carray_operator.c
|
28
|
+
ext/carray_order.c
|
29
|
+
ext/carray_sort_addr.c
|
30
|
+
ext/carray_test.c
|
31
|
+
ext/carray_utils.c
|
32
|
+
|
data/NEWS.md
CHANGED
@@ -1,6 +1,59 @@
|
|
1
1
|
ChangeLog of Ruby/CArray
|
2
2
|
========================
|
3
3
|
|
4
|
+
1.5.6 -> 1.5.7
|
5
|
+
|
6
|
+
* [Mod] Modify the methods 'CArray#first' and 'CArray#last' to return nil when the number of elements is zero
|
7
|
+
* [Fix] Added check of having ArithmeticSeuqence in ruby_carray.c
|
8
|
+
|
9
|
+
1.5.5 -> 1.5.6
|
10
|
+
|
11
|
+
* [Mod] Modify CArray access methods to accept Enumerator::ArithmeticSequence for index, address
|
12
|
+
* [Mod] Remove some gem autoloading (io_csv, io_sqlite3, rmagick, cairo, opencv, ffi)
|
13
|
+
* [Mod] Modify 'CArray#valid_index?' and 'CArray#valid_addr?' to accept negative integers
|
14
|
+
* [Mod] Modify the methods 'CArray#double' etc not to raise error for invalid string in conversion into float
|
15
|
+
|
16
|
+
1.5.4 -> 1.5.5
|
17
|
+
|
18
|
+
* [Fix] Fix recognition of "atan2", ... in "math.h"
|
19
|
+
* [Fix] Fix serialize.rb of keyword parameters for Ruby2.7
|
20
|
+
|
21
|
+
1.5.3 -> 1.5.4
|
22
|
+
--------------
|
23
|
+
|
24
|
+
* [New] Import method 'CArray#section' from gem 'carray-calculus'
|
25
|
+
* [New] Add new method 'CArray#pull', 'CArray#pulled'
|
26
|
+
* [New] Add new option 'expand_scalar' to 'CArray.broadcast'
|
27
|
+
* [Mod] Modify the method 'CArray.broadcast' to accept block.
|
28
|
+
* [Mod] Modify the method 'CArray.meshgrid' to accept block.
|
29
|
+
* [Mod] Modify 'CScalar#broadcast_to' to return CArray
|
30
|
+
* [Mod] Modify 'CScalar#is_masked' and 'CScalar#is_masked' to return CScalar
|
31
|
+
* [Fix] Fix order of repetitive dimensions in 'CArray#meshgrid'
|
32
|
+
* [Fix] Fix errors in installing on MinGW+msys2
|
33
|
+
|
34
|
+
1.5.2 -> 1.5.3
|
35
|
+
--------------
|
36
|
+
|
37
|
+
* [New] Add new method 'CArray#exp2'
|
38
|
+
* [New] Add new method 'CArray#log2'
|
39
|
+
* [New] Add new method 'CArray#logb'
|
40
|
+
* [New] Add new method 'CArray#remainder'
|
41
|
+
* [New] Add new method 'CArray.guard_undef'
|
42
|
+
* [New] Add new method 'CArray#data_class='
|
43
|
+
* [New] Add new method 'CArray.data_class?'
|
44
|
+
* [Mod] Modify 'CArray#pmax' to use 'fmax' for float type
|
45
|
+
* [Mod] Modify 'CArray#pmin' to use 'fmin' for float type
|
46
|
+
* [Mod] Remove method 'Object#undef?'
|
47
|
+
* [Mod] Remove method '::nan', '::inf'
|
48
|
+
* [Mod] Remove method 'TrueClass#*', 'FalseClass#*' (unknown origin)
|
49
|
+
* [Fix] Fix invalid access for CAUnboundRepeat using index
|
50
|
+
* [Fix] Fix treatment of extra :* in operation between CAUnboundRepeat objects
|
51
|
+
* [Fix] Fix to accept Symbol for the name of data_class member
|
52
|
+
* [Fix] Fix 'CArray#uniq' to accept the array with the dimension more than 2.
|
53
|
+
* [Fix] Fix for CArray serialization to include data_class
|
54
|
+
* [Fix] Fix data_class inheritance in some methods in which new CArray is created.
|
55
|
+
* [Fix] Fix 'CArray#broadcast_to' to accept the case of dimension extension.
|
56
|
+
|
4
57
|
1.5.1 -> 1.5.2
|
5
58
|
--------------
|
6
59
|
|
@@ -13,8 +66,8 @@ ChangeLog of Ruby/CArray
|
|
13
66
|
* [New] Add new API function `rb_ca_wrap_new`
|
14
67
|
* [Mod] Modify 'CArray#linspace' to return float64 array for integer arguments
|
15
68
|
* [Mod] Modify CAUnboundRepeat to have `ndim` same as the bounded array (before `ndim` same as parent array)
|
16
|
-
* [Mod]
|
17
|
-
* [Mod]
|
69
|
+
* [Mod] Remove the obsolete mothod 'CArray#dump'.
|
70
|
+
* [Mod] Remove the obsolete mothod 'CArray#load'.
|
18
71
|
* [Mod] Modify CArray.wrap_readonly to wrap string as array.
|
19
72
|
* [Fix] Add support for Integer (same as for Fixnum, Bignum)
|
20
73
|
|
@@ -23,12 +76,12 @@ ChangeLog of Ruby/CArray
|
|
23
76
|
|
24
77
|
* [New] Add data type classes like 'Float64' ... to provide the methods like 'CArray::Float64.linspace'
|
25
78
|
* [Mod] Modify 'CArray.float64' ... without aruguments to return the corresponding data type class
|
79
|
+
* [Mod] Set obsolete flag to 'CAIterator#sort_with'
|
26
80
|
* [Fix] Move C extension files into 'ext/'
|
27
81
|
* [Fix] Rename member 'rank' to 'ndim' in struct CArray in C extension
|
28
82
|
* [Fix] Remove 'CArray#shuffle' (gone to 'carray-random' gem)
|
29
83
|
* [Fix] Remove dependencies on 'rb_secure()' and 'rb_safe_level()'
|
30
84
|
* [Fix] Modify 'CArray#span' to handle fractional step for integer array
|
31
|
-
* [Obsolete] Set obsolete flag to 'CAIterator#sort_with'
|
32
85
|
|
33
86
|
1.4.0 -> 1.5.0
|
34
87
|
--------------
|
data/README.md
CHANGED
@@ -6,16 +6,16 @@ Ruby/CArray is an extension library for the multi-dimensional array class.
|
|
6
6
|
Features
|
7
7
|
--------
|
8
8
|
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* Indirect data manipulation
|
9
|
+
* Collection class for multidimensional array storing the value with uniform data type
|
10
|
+
* Element-wise mathematical operations and functions
|
11
|
+
* Statistical operation for the elements
|
12
|
+
* Various methods for referencing data elements
|
13
|
+
* Internally included element-wise mask to handle missing values
|
14
|
+
* Indirect data manipulation to referent by virtual array
|
15
15
|
* Special iterators (dimension, block, window, categorical)
|
16
|
-
* User-defined array
|
17
|
-
*
|
18
|
-
*
|
16
|
+
* User-defined array class with same multi-dimensional interfaces as CArray
|
17
|
+
* Accessing the partial data in fixed length data via data_class interface
|
18
|
+
* Wrapping the memory block owned by the other object (such as NArray).
|
19
19
|
|
20
20
|
Requirements
|
21
21
|
------------
|
@@ -25,16 +25,32 @@ Requirements
|
|
25
25
|
+ IEEE754 floating point number
|
26
26
|
+ C99 complex number
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
What is Ruby/CArray
|
29
|
+
------------------
|
30
30
|
|
31
|
-
|
32
|
-
ext - C extension source codes
|
33
|
-
utils - support tools for development
|
34
|
-
spec - rspec files
|
35
|
-
misc - misc files
|
31
|
+
Ruby/CArray is an extension library for the multi-dimensional numerical array class. The name "CArray" comes from a wrapper's meaning to a numerical array handled by the C language. CArray stores integers or floating-point numbers in memory block and treats them collectively to ensure efficient performance. Therefore, Ruby/CArray is suitable for numerical computation and data analysis.
|
36
32
|
|
37
|
-
|
38
|
-
|
33
|
+
#### Multi-dimensional uniform array ####
|
34
|
+
|
35
|
+
CArray is a collection class that can store the array of values with a uniform data type of one of fixed-width integer (8,16,32,64bits), floating-point number (32,64bits), complex number (64,128bits), fixed-length string, ruby object. These values are stored in memory block as binary data. CArray has multi-dimensional interfaces for the array to access their values. The multi-dimensional array has the attributes of the dimension size (1,2,3,...) and the shape of dimension ([dim0], [dim0,dim1], [dim0,dim1,dim2],...) which define the size of array.
|
36
|
+
|
37
|
+
#### Collective mathematical operations ####
|
38
|
+
|
39
|
+
CArray supports the collective calculation for the element-wise arithmetic operations and elementary mathematical functions. Additionally, some basic statistical summarization along specific dimensions are also provided.
|
40
|
+
|
41
|
+
#### Referencing data and virtual arrays ####
|
42
|
+
|
43
|
+
CArray provides various methods for referencing data, such as addressing, slicing, selection by condition, address mapping, grid reference, transposing, shifting, rolling, data type conversion, reshaping, and so on. These data referencing are realized by the creation of virtual arrays, so-called 'view'. The virtual array doesn't have its data and retrieves the data from the referent only on-demand, including dereferencing, copying, or calculation. Since virtual array classes are sub-class of CArray, it has the same interfaces to access data as CArray. The changes in a virtual array by storing data are also reflected in the referent (if not a read_only array). Multiple heterogeneous chains of reference are also allowed, although the trade-offs with performance must be carefully considered.
|
44
|
+
|
45
|
+
#### Built-in element-wise mask handling ####
|
46
|
+
|
47
|
+
CArray possesses masked states about each element (so-called "element-wise mask"). By referring the element-wise mask, CArray can perform mathematical and statistical calculations on the data with missing values by appropriate handling of masked elements. , which include the propagation of mask state to result in element-wise arithmetics and ignoring the masked elements in a statistical calculation, and so on.
|
48
|
+
|
49
|
+
#### User-defined array ####
|
50
|
+
|
51
|
+
Users can define a new virtual array class in Ruby level or C-extension level with TemplateMethod pattern. They are defined as a subclass of CAObject in Ruby level and as a subclass of CAVirtual in C-extension level. In particular, at the Ruby level, you can easily define a CArray-like class by implementing just a few template methods.
|
52
|
+
|
53
|
+
License
|
54
|
+
-------
|
39
55
|
|
40
56
|
MIT (after version 1.5.0)
|
data/Rakefile
CHANGED
data/TODO.md
CHANGED
@@ -3,13 +3,14 @@ ToDo List
|
|
3
3
|
|
4
4
|
ToDo
|
5
5
|
-------
|
6
|
-
|
6
|
+
* Implement CArray.broadcast in C
|
7
|
+
* Implement Integer#{|,&,^,<<,>>} with Refinement (remove monkey patch)
|
8
|
+
* Remove RSTRUCT hack in carray_access.c for handling of Range object.
|
9
|
+
* Solve abs probrems
|
7
10
|
* Create spec
|
8
11
|
- str_format (cyclic format)
|
9
12
|
- CA_SIZE
|
10
|
-
|
11
|
-
* Implement CArray.broadcast in C
|
12
|
-
* Solve abs probrems
|
13
|
+
- serialization of carray which has data_class
|
13
14
|
|
14
15
|
Done
|
15
16
|
-------
|
data/carray.gemspec
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
Gem::Specification::new do |s|
|
2
2
|
|
3
|
-
version = "1.5.
|
3
|
+
version = "1.5.7"
|
4
4
|
|
5
|
-
files = Dir.glob("**/*")
|
5
|
+
files = Dir.glob("**/*") + [".yardopts"] -
|
6
|
+
[
|
6
7
|
Dir.glob("carray-*.gem"),
|
7
8
|
Dir.glob("ext/**/{Makefile,mkmf.log}"),
|
8
9
|
Dir.glob("**/*.{o,so,bundle}"),
|
9
10
|
Dir.glob("**/*~"),
|
10
11
|
Dir.glob("doc/**/*"),
|
12
|
+
Dir.glob("test/**/*"),
|
11
13
|
].flatten
|
12
14
|
|
13
15
|
s.platform = Gem::Platform::RUBY
|
14
16
|
s.name = "carray"
|
15
17
|
s.summary = "Multi-dimesional array class for Ruby"
|
16
18
|
s.description = <<-HERE
|
17
|
-
Ruby/CArray is an extension library for the multi-dimensional array
|
18
|
-
CArray
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
creation of reference arrays that can reflect changes to the referent,
|
23
|
-
the ability to access memory pointers of other objects, user-defined arrays,
|
24
|
-
and so on.
|
19
|
+
Ruby/CArray is an extension library for the multi-dimensional numerical array
|
20
|
+
class. The name "CArray" comes from the meaning of a wrapper to a numerical array
|
21
|
+
handled by the C language. CArray stores integers or floating-point numbers in
|
22
|
+
memory block and treats them collectively to ensure efficient performance.
|
23
|
+
Therefore, Ruby/CArray is suitable for numerical computation and data analysis.
|
25
24
|
HERE
|
26
25
|
s.version = version
|
27
26
|
s.author = "Hiroki Motoyoshi"
|
28
27
|
s.email = ""
|
29
|
-
s.
|
28
|
+
s.license = 'MIT'
|
30
29
|
s.homepage = 'https://github.com/himotoyoshi/carray'
|
31
30
|
s.files = files
|
32
31
|
s.extensions = [ "ext/extconf.rb" ]
|
data/ext/ca_obj_bitarray.c
CHANGED
@@ -462,12 +462,9 @@ rb_ca_bitarray_new (VALUE cary)
|
|
462
462
|
return obj;
|
463
463
|
}
|
464
464
|
|
465
|
-
/*
|
466
|
-
|
467
|
-
|
468
|
-
end
|
469
|
-
alias bitarray bits
|
470
|
-
end
|
465
|
+
/* @overload bitarray
|
466
|
+
|
467
|
+
[TBD]
|
471
468
|
*/
|
472
469
|
|
473
470
|
VALUE
|
@@ -511,8 +508,8 @@ Init_ca_obj_bitarray ()
|
|
511
508
|
CA_OBJ_BITARRAY = ca_install_obj_type(rb_cCABitarray, ca_bitarray_func);
|
512
509
|
rb_define_const(rb_cObject, "CA_OBJ_BITARRAY", INT2NUM(CA_OBJ_BITARRAY));
|
513
510
|
|
514
|
-
rb_define_method(rb_cCArray, "bits", rb_ca_bitarray, 0);
|
515
511
|
rb_define_method(rb_cCArray, "bitarray", rb_ca_bitarray, 0);
|
512
|
+
rb_define_alias(rb_cCArray, "bits", "bitarray");
|
516
513
|
|
517
514
|
rb_define_alloc_func(rb_cCABitarray, rb_ca_bitarray_s_allocate);
|
518
515
|
rb_define_method(rb_cCABitarray, "initialize_copy",
|
data/ext/ca_obj_bitfield.c
CHANGED
@@ -557,11 +557,9 @@ rb_ca_bitfield_new (VALUE cary, ca_size_t offset, ca_size_t bitlen)
|
|
557
557
|
return obj;
|
558
558
|
}
|
559
559
|
|
560
|
-
/*
|
561
|
-
|
562
|
-
|
563
|
-
end
|
564
|
-
end
|
560
|
+
/* @overload bitfield (range, type)
|
561
|
+
|
562
|
+
[TBD]
|
565
563
|
*/
|
566
564
|
|
567
565
|
VALUE
|
data/ext/ca_obj_block.c
CHANGED
@@ -12,11 +12,6 @@
|
|
12
12
|
|
13
13
|
VALUE rb_cCABlock;
|
14
14
|
|
15
|
-
/* yard:
|
16
|
-
class CABlock < CAVirtual # :nodoc:
|
17
|
-
end
|
18
|
-
*/
|
19
|
-
|
20
15
|
static int
|
21
16
|
ca_block_setup (CABlock *ca, CArray *parent, int8_t ndim, ca_size_t *dim,
|
22
17
|
ca_size_t *start, ca_size_t *step, ca_size_t *count, ca_size_t offset)
|
@@ -733,7 +728,7 @@ rb_cb_initialize_copy (VALUE self, VALUE other)
|
|
733
728
|
return ary; \
|
734
729
|
}
|
735
730
|
|
736
|
-
/*
|
731
|
+
/* @overload size0:
|
737
732
|
class CABlock
|
738
733
|
def size0
|
739
734
|
end
|
data/ext/ca_obj_refer.c
CHANGED
@@ -32,11 +32,11 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
32
32
|
CA_CHECK_BYTES(data_type, bytes);
|
33
33
|
|
34
34
|
if ( ca_is_object_type(parent) && data_type != CA_OBJECT ) {
|
35
|
-
rb_raise(rb_eRuntimeError, "object
|
35
|
+
rb_raise(rb_eRuntimeError, "object array can't be referred by other data type");
|
36
36
|
}
|
37
37
|
|
38
38
|
if ( parent->elements && bytes > parent->bytes * parent->elements ) {
|
39
|
-
rb_raise(rb_eRuntimeError, "
|
39
|
+
rb_raise(rb_eRuntimeError, "bytes exceeds the data size of referent");
|
40
40
|
}
|
41
41
|
|
42
42
|
/* calc datanum and check deformation */
|
@@ -51,27 +51,25 @@ ca_refer_setup (CARefer *ca, CArray *parent,
|
|
51
51
|
}
|
52
52
|
if ( bytes < parent->bytes ) {
|
53
53
|
if ( parent->bytes % bytes != 0 ) {
|
54
|
-
rb_raise(
|
54
|
+
rb_raise(rb_eRuntimeError, "bytes of reference array must be a multiple of that of referent");
|
55
55
|
}
|
56
56
|
is_deformed = -2;
|
57
57
|
ratio = parent->bytes / bytes;
|
58
58
|
}
|
59
59
|
else if ( bytes > parent->bytes ) {
|
60
60
|
if ( bytes % parent->bytes != 0 ) {
|
61
|
-
rb_raise(
|
61
|
+
rb_raise(rb_eRuntimeError, "bytes of reference array must be a multiple of that of referent");
|
62
62
|
}
|
63
63
|
is_deformed = 2;
|
64
64
|
ratio = bytes / parent->bytes;
|
65
65
|
}
|
66
|
-
|
67
66
|
if ( offset < 0 ) {
|
68
|
-
rb_raise(rb_eRuntimeError,
|
69
|
-
"negative offset for CARefer");
|
67
|
+
rb_raise(rb_eRuntimeError, "negative offset is not permitted for CARefer");
|
70
68
|
}
|
71
69
|
|
72
70
|
if ( ( bytes * elements + parent->bytes * offset ) >
|
73
71
|
( parent->bytes * parent->elements ) ) {
|
74
|
-
rb_raise(rb_eRuntimeError, "data size
|
72
|
+
rb_raise(rb_eRuntimeError, "data size of reference array must not exceed that of referent");
|
75
73
|
}
|
76
74
|
|
77
75
|
ca->obj_type = CA_OBJ_REFER;
|
data/ext/ca_obj_unbound_repeat.c
CHANGED
@@ -50,15 +50,9 @@ ca_ubrep_setup (CAUnboundRepeat *ca, CArray *parent,
|
|
50
50
|
ca->rep_ndim = rep_ndim;
|
51
51
|
ca->rep_dim = ALLOC_N(ca_size_t, rep_ndim);
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
if ( ca->rep_dim[i] ) {
|
57
|
-
ca->dim[i] = ca->rep_dim[i];
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
ca->dim[i] = 1;
|
61
|
-
}
|
53
|
+
for (i=0; i<rep_ndim; i++) {
|
54
|
+
ca->rep_dim[i] = rep_dim[i];
|
55
|
+
ca->dim[i] = ( rep_dim[i] ) ? rep_dim[i] : 1;
|
62
56
|
}
|
63
57
|
|
64
58
|
if ( ca_has_mask(parent) ) {
|
@@ -104,13 +98,6 @@ ca_ubrep_func_ptr_at_addr (void *ap, ca_size_t addr)
|
|
104
98
|
return ca_ptr_at_addr(ca->parent, addr);
|
105
99
|
}
|
106
100
|
|
107
|
-
static char *
|
108
|
-
ca_ubrep_func_ptr_at_index (void *ap, ca_size_t *idx)
|
109
|
-
{
|
110
|
-
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
111
|
-
return ca_ptr_at_index(ca->parent, idx);
|
112
|
-
}
|
113
|
-
|
114
101
|
static void
|
115
102
|
ca_ubrep_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
116
103
|
{
|
@@ -118,13 +105,6 @@ ca_ubrep_func_fetch_addr (void *ap, ca_size_t addr, void *ptr)
|
|
118
105
|
ca_fetch_addr(ca->parent, addr, ptr);
|
119
106
|
}
|
120
107
|
|
121
|
-
static void
|
122
|
-
ca_ubrep_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
|
123
|
-
{
|
124
|
-
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
125
|
-
ca_fetch_index(ca->parent, idx, ptr);
|
126
|
-
}
|
127
|
-
|
128
108
|
static void
|
129
109
|
ca_ubrep_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
130
110
|
{
|
@@ -132,13 +112,6 @@ ca_ubrep_func_store_addr (void *ap, ca_size_t addr, void *ptr)
|
|
132
112
|
ca_store_addr(ca->parent, addr, ptr);
|
133
113
|
}
|
134
114
|
|
135
|
-
static void
|
136
|
-
ca_ubrep_func_store_index (void *ap, ca_size_t *idx, void *ptr)
|
137
|
-
{
|
138
|
-
CAUnboundRepeat *ca = (CAUnboundRepeat *) ap;
|
139
|
-
ca_store_index(ca->parent, idx, ptr);
|
140
|
-
}
|
141
|
-
|
142
115
|
static void
|
143
116
|
ca_ubrep_func_allocate (void *ap)
|
144
117
|
{
|
@@ -227,11 +200,11 @@ ca_operation_function_t ca_ubrep_func = {
|
|
227
200
|
free_ca_ubrep,
|
228
201
|
ca_ubrep_func_clone,
|
229
202
|
ca_ubrep_func_ptr_at_addr,
|
230
|
-
|
203
|
+
NULL,
|
231
204
|
ca_ubrep_func_fetch_addr,
|
232
|
-
|
205
|
+
NULL,
|
233
206
|
ca_ubrep_func_store_addr,
|
234
|
-
|
207
|
+
NULL,
|
235
208
|
ca_ubrep_func_allocate,
|
236
209
|
ca_ubrep_func_attach,
|
237
210
|
ca_ubrep_func_sync,
|
@@ -304,11 +277,10 @@ rb_ca_unbound_repeat (int argc, VALUE *argv, VALUE self)
|
|
304
277
|
rep_ndim = argc;
|
305
278
|
|
306
279
|
count = 0;
|
307
|
-
ndim
|
308
|
-
|
280
|
+
ndim = 0;
|
309
281
|
elements = 1;
|
310
282
|
for (i=0; i<rep_ndim; i++) {
|
311
|
-
if (
|
283
|
+
if ( TYPE(argv[i]) == T_SYMBOL ) {
|
312
284
|
if ( argv[i] == ID2SYM(rb_intern("*")) ) {
|
313
285
|
rep_dim[i] = 0;
|
314
286
|
}
|
@@ -321,8 +293,8 @@ rb_ca_unbound_repeat (int argc, VALUE *argv, VALUE self)
|
|
321
293
|
rb_raise(rb_eArgError, "invalid argument");
|
322
294
|
}
|
323
295
|
rep_dim[i] = ca->dim[count];
|
324
|
-
dim[ndim]
|
325
|
-
elements
|
296
|
+
dim[ndim] = ca->dim[count];
|
297
|
+
elements *= ca->dim[count];
|
326
298
|
count++; ndim++;
|
327
299
|
}
|
328
300
|
}
|
@@ -334,9 +306,8 @@ rb_ca_unbound_repeat (int argc, VALUE *argv, VALUE self)
|
|
334
306
|
if ( ndim != ca->ndim ) {
|
335
307
|
rb_raise(rb_eArgError, "invalid number of nil's (%i for %i)", ndim, ca->ndim);
|
336
308
|
}
|
337
|
-
|
338
|
-
|
339
|
-
}
|
309
|
+
|
310
|
+
return rb_ca_ubrep_new(self, rep_ndim, rep_dim);
|
340
311
|
}
|
341
312
|
|
342
313
|
static VALUE
|
@@ -388,6 +359,7 @@ ca_ubrep_bind2 (VALUE self, int32_t new_ndim, ca_size_t *new_dim)
|
|
388
359
|
ca_size_t upr_spec[CA_RANK_MAX];
|
389
360
|
ca_size_t srp_spec[CA_RANK_MAX];
|
390
361
|
int uprep = 0, srp_ndim;
|
362
|
+
int ndim_real;
|
391
363
|
int i;
|
392
364
|
|
393
365
|
Data_Get_Struct(self, CAUnboundRepeat, ca);
|
@@ -398,6 +370,7 @@ ca_ubrep_bind2 (VALUE self, int32_t new_ndim, ca_size_t *new_dim)
|
|
398
370
|
}
|
399
371
|
|
400
372
|
srp_ndim = 0;
|
373
|
+
ndim_real = 0;
|
401
374
|
for (i=0; i<new_ndim; i++) {
|
402
375
|
if ( ca->rep_dim[i] == 0 ) {
|
403
376
|
if ( new_dim[i] == 0 ) {
|
@@ -410,14 +383,16 @@ ca_ubrep_bind2 (VALUE self, int32_t new_ndim, ca_size_t *new_dim)
|
|
410
383
|
upr_spec[i] = new_dim[i];
|
411
384
|
}
|
412
385
|
else {
|
386
|
+
ndim_real++;
|
413
387
|
rep_spec[i] = 0;
|
414
388
|
srp_spec[srp_ndim++] = 0;
|
415
389
|
upr_spec[i] = ca->rep_dim[i];
|
416
390
|
}
|
417
391
|
}
|
392
|
+
|
418
393
|
if ( uprep ) {
|
419
394
|
volatile VALUE rep;
|
420
|
-
if ( srp_ndim >=
|
395
|
+
if ( srp_ndim >= ndim_real ) {
|
421
396
|
rep = rb_ca_repeat_new(rb_ca_parent(self), srp_ndim, srp_spec);
|
422
397
|
}
|
423
398
|
else {
|
@@ -430,11 +405,8 @@ ca_ubrep_bind2 (VALUE self, int32_t new_ndim, ca_size_t *new_dim)
|
|
430
405
|
}
|
431
406
|
}
|
432
407
|
|
433
|
-
/*
|
434
|
-
|
435
|
-
def bind_with(other)
|
436
|
-
end
|
437
|
-
end
|
408
|
+
/* @overload bind_with (other)
|
409
|
+
|
438
410
|
*/
|
439
411
|
|
440
412
|
VALUE
|
@@ -460,11 +432,8 @@ ca_ubrep_bind_with (VALUE self, VALUE other)
|
|
460
432
|
}
|
461
433
|
}
|
462
434
|
|
463
|
-
/*
|
464
|
-
|
465
|
-
def bind(*index)
|
466
|
-
end
|
467
|
-
end
|
435
|
+
/* @overload bind (*index)
|
436
|
+
|
468
437
|
*/
|
469
438
|
|
470
439
|
static VALUE
|