numo-narray 0.9.1.4 → 0.9.1.5
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/README.md +10 -4
- data/ext/numo/narray/array.c +17 -7
- data/ext/numo/narray/data.c +39 -36
- data/ext/numo/narray/extconf.rb +1 -0
- data/ext/numo/narray/gen/narray_def.rb +4 -0
- data/ext/numo/narray/gen/spec.rb +5 -1
- data/ext/numo/narray/gen/tmpl/accum.c +2 -2
- data/ext/numo/narray/gen/tmpl/accum_arg.c +88 -0
- data/ext/numo/narray/gen/tmpl/accum_binary.c +1 -1
- data/ext/numo/narray/gen/tmpl/accum_index.c +25 -14
- data/ext/numo/narray/gen/tmpl/aref.c +5 -35
- data/ext/numo/narray/gen/tmpl/aset.c +7 -37
- data/ext/numo/narray/gen/tmpl/bincount.c +7 -7
- data/ext/numo/narray/gen/tmpl/clip.c +11 -15
- data/ext/numo/narray/gen/tmpl/cum.c +1 -1
- data/ext/numo/narray/gen/tmpl/each.c +4 -2
- data/ext/numo/narray/gen/tmpl/each_with_index.c +5 -2
- data/ext/numo/narray/gen/tmpl/lib.c +2 -2
- data/ext/numo/narray/gen/tmpl/logseq.c +6 -5
- data/ext/numo/narray/gen/tmpl/map_with_index.c +5 -6
- data/ext/numo/narray/gen/tmpl/median.c +2 -2
- data/ext/numo/narray/gen/tmpl/minmax.c +1 -1
- data/ext/numo/narray/gen/tmpl/poly.c +4 -4
- data/ext/numo/narray/gen/tmpl/qsort.c +1 -1
- data/ext/numo/narray/gen/tmpl/rand.c +8 -6
- data/ext/numo/narray/gen/tmpl/rand_norm.c +18 -16
- data/ext/numo/narray/gen/tmpl/seq.c +5 -4
- data/ext/numo/narray/gen/tmpl/sort.c +3 -3
- data/ext/numo/narray/gen/tmpl/sort_index.c +2 -2
- data/ext/numo/narray/gen/tmpl/store_array.c +14 -2
- data/ext/numo/narray/gen/tmpl/unary_s.c +55 -31
- data/ext/numo/narray/gen/tmpl_bit/aref.c +22 -30
- data/ext/numo/narray/gen/tmpl_bit/aset.c +20 -34
- data/ext/numo/narray/gen/tmpl_bit/binary.c +42 -14
- data/ext/numo/narray/gen/tmpl_bit/bit_count.c +5 -0
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +5 -0
- data/ext/numo/narray/gen/tmpl_bit/store_array.c +14 -2
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +21 -7
- data/ext/numo/narray/gen/tmpl_bit/unary.c +21 -7
- data/ext/numo/narray/index.c +369 -59
- data/ext/numo/narray/math.c +2 -2
- data/ext/numo/narray/narray.c +45 -27
- data/ext/numo/narray/ndloop.c +2 -2
- data/ext/numo/narray/numo/intern.h +3 -2
- data/ext/numo/narray/numo/narray.h +24 -5
- data/ext/numo/narray/numo/ndloop.h +2 -2
- data/ext/numo/narray/numo/template.h +4 -6
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/step.c +58 -252
- data/ext/numo/narray/struct.c +2 -2
- data/lib/numo/narray/extra.rb +172 -212
- data/numo-narray.gemspec +9 -5
- metadata +18 -17
@@ -1,40 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
|
2
|
+
Multi-dimensional element reference.
|
3
3
|
@overload [](dim0,...,dimL)
|
4
|
-
@param [Numeric,Range,
|
5
|
-
@return [Numeric,
|
6
|
-
|
7
|
-
|
8
|
-
for each dimension, or returns a NArray View as a sliced subarray if
|
9
|
-
+dim0+, +dim1+, ... includes other than Numeric index, e.g., Range
|
10
|
-
or Array or true.
|
11
|
-
|
12
|
-
@example
|
13
|
-
a = Numo::DFloat.new(4,5).seq
|
14
|
-
=> Numo::DFloat#shape=[4,5]
|
15
|
-
[[0, 1, 2, 3, 4],
|
16
|
-
[5, 6, 7, 8, 9],
|
17
|
-
[10, 11, 12, 13, 14],
|
18
|
-
[15, 16, 17, 18, 19]]
|
19
|
-
|
20
|
-
a[1,1]
|
21
|
-
=> 6.0
|
22
|
-
|
23
|
-
a[1..3,1]
|
24
|
-
=> Numo::DFloat#shape=[3]
|
25
|
-
[6, 11, 16]
|
26
|
-
|
27
|
-
a[1,[1,3,4]]
|
28
|
-
=> Numo::DFloat#shape=[3]
|
29
|
-
[6, 8, 9]
|
30
|
-
|
31
|
-
a[true,2].fill(99)
|
32
|
-
a
|
33
|
-
=> Numo::DFloat#shape=[4,5]
|
34
|
-
[[0, 1, 99, 3, 4],
|
35
|
-
[5, 6, 99, 8, 9],
|
36
|
-
[10, 11, 99, 13, 14],
|
37
|
-
[15, 16, 99, 18, 19]]
|
4
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional indices.
|
5
|
+
@return [Numeric,Numo::<%=class_name%>] an element or NArray view.
|
6
|
+
@see Numo::NArray#[]
|
7
|
+
@see #[]=
|
38
8
|
*/
|
39
9
|
static VALUE
|
40
10
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
@@ -1,41 +1,11 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
@overload []=(dim0
|
4
|
-
@param [Numeric,Range,
|
5
|
-
@param [Numeric,Numo::NArray,
|
6
|
-
@return [Numeric] returns val (last argument).
|
7
|
-
|
8
|
-
|
9
|
-
for each dimention). Broadcasting mechanism is applied.
|
10
|
-
|
11
|
-
@example
|
12
|
-
a = Numo::DFloat.new(3,4).seq
|
13
|
-
=> Numo::DFloat#shape=[3,4]
|
14
|
-
[[0, 1, 2, 3],
|
15
|
-
[4, 5, 6, 7],
|
16
|
-
[8, 9, 10, 11]]
|
17
|
-
|
18
|
-
a[1,2]=99
|
19
|
-
a
|
20
|
-
=> Numo::DFloat#shape=[3,4]
|
21
|
-
[[0, 1, 2, 3],
|
22
|
-
[4, 5, 99, 7],
|
23
|
-
[8, 9, 10, 11]]
|
24
|
-
|
25
|
-
a[1,[0,2]] = [101,102]
|
26
|
-
a
|
27
|
-
=> Numo::DFloat#shape=[3,4]
|
28
|
-
[[0, 1, 2, 3],
|
29
|
-
[101, 5, 102, 7],
|
30
|
-
[8, 9, 10, 11]]
|
31
|
-
|
32
|
-
a[1,true]=99
|
33
|
-
a
|
34
|
-
=> Numo::DFloat#shape=[3,4]
|
35
|
-
[[0, 1, 2, 3],
|
36
|
-
[99, 99, 99, 99],
|
37
|
-
[8, 9, 10, 11]]
|
38
|
-
|
2
|
+
Multi-dimensional element assignment.
|
3
|
+
@overload []=(dim0,...,dimL,val)
|
4
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional indices.
|
5
|
+
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
6
|
+
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
7
|
+
@see Numo::NArray#[]=
|
8
|
+
@see #[]
|
39
9
|
*/
|
40
10
|
static VALUE
|
41
11
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
@@ -115,22 +115,22 @@ static VALUE
|
|
115
115
|
otherwise returns UInt32 or UInt64 depending on the size along last axis.
|
116
116
|
@example
|
117
117
|
Numo::Int32[0..4].bincount
|
118
|
-
=> Numo::UInt32#shape=[5]
|
119
|
-
|
118
|
+
# => Numo::UInt32#shape=[5]
|
119
|
+
# [1, 1, 1, 1, 1]
|
120
120
|
|
121
121
|
Numo::Int32[0, 1, 1, 3, 2, 1, 7].bincount
|
122
|
-
=> Numo::UInt32#shape=[8]
|
123
|
-
|
122
|
+
# => Numo::UInt32#shape=[8]
|
123
|
+
# [1, 3, 1, 1, 0, 0, 0, 1]
|
124
124
|
|
125
125
|
x = Numo::Int32[0, 1, 1, 3, 2, 1, 7, 23]
|
126
126
|
x.bincount.size == x.max+1
|
127
|
-
=> true
|
127
|
+
# => true
|
128
128
|
|
129
129
|
w = Numo::DFloat[0.3, 0.5, 0.2, 0.7, 1.0, -0.6]
|
130
130
|
x = Numo::Int32[0, 1, 1, 2, 2, 2]
|
131
131
|
x.bincount(w)
|
132
|
-
=> Numo::DFloat#shape=[3]
|
133
|
-
|
132
|
+
# => Numo::DFloat#shape=[3]
|
133
|
+
# [0.3, 0.7, 1.1]
|
134
134
|
|
135
135
|
*/
|
136
136
|
static VALUE
|
@@ -69,28 +69,24 @@ static void
|
|
69
69
|
|
70
70
|
@example
|
71
71
|
a = Numo::Int32.new(10).seq
|
72
|
-
|
73
|
-
# Numo::Int32#shape=[10]
|
74
|
-
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
75
|
-
|
76
|
-
p a
|
77
|
-
# Numo::Int32#shape=[10]
|
72
|
+
# => Numo::Int32#shape=[10]
|
78
73
|
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
79
74
|
|
80
|
-
|
81
|
-
# Numo::Int32
|
82
|
-
# [
|
75
|
+
a.clip(1,8)
|
76
|
+
# => Numo::Int32#shape=[10]
|
77
|
+
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
83
78
|
|
84
|
-
|
85
|
-
|
79
|
+
a.inplace.clip(3,6)
|
80
|
+
a
|
81
|
+
# => Numo::Int32#shape=[10]
|
86
82
|
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
87
83
|
|
88
|
-
|
89
|
-
# Numo::Int32#shape=[10]
|
84
|
+
b = Numo::Int32.new(10).seq
|
85
|
+
# => Numo::Int32#shape=[10]
|
90
86
|
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
91
87
|
|
92
|
-
|
93
|
-
# Numo::Int32#shape=[10]
|
88
|
+
b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
89
|
+
# => Numo::Int32#shape=[10]
|
94
90
|
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
95
91
|
*/
|
96
92
|
static VALUE
|
@@ -27,7 +27,7 @@ static void
|
|
27
27
|
/*
|
28
28
|
<%=name%> of self.
|
29
29
|
@overload <%=name%>(axis:nil, nan:false)
|
30
|
-
@param [Numeric,Array,Range] axis
|
30
|
+
@param [Numeric,Array,Range] axis Performs <%=name%> along the axis.
|
31
31
|
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
32
32
|
@return [Numo::<%=class_name%>] <%=name%> of self.
|
33
33
|
*/
|
@@ -29,8 +29,10 @@ static void
|
|
29
29
|
passing that element as a parameter.
|
30
30
|
@overload <%=name%>
|
31
31
|
@return [Numo::NArray] self
|
32
|
-
For a block {|x| ... }
|
33
|
-
@
|
32
|
+
For a block `{|x| ... }`,
|
33
|
+
@yieldparam [Numeric] x an element of NArray.
|
34
|
+
@see #each_with_index
|
35
|
+
@see #map
|
34
36
|
*/
|
35
37
|
static VALUE
|
36
38
|
<%=c_func(0)%>(VALUE self)
|
@@ -50,9 +50,12 @@ static void
|
|
50
50
|
Invokes the given block once for each element of self,
|
51
51
|
passing that element and indices along each axis as parameters.
|
52
52
|
@overload <%=name%>
|
53
|
+
For a block `{|x,i,j,...| ... }`,
|
54
|
+
@yieldparam [Numeric] x an element
|
55
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
53
56
|
@return [Numo::NArray] self
|
54
|
-
|
55
|
-
@
|
57
|
+
@see #each
|
58
|
+
@see #map_with_index
|
56
59
|
*/
|
57
60
|
static VALUE
|
58
61
|
<%=c_func(0)%>(VALUE self)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/*
|
2
2
|
<%= file_name %>
|
3
|
-
Ruby/Numo::
|
3
|
+
Ruby/Numo::NArray - Numerical Array class for Ruby
|
4
4
|
|
5
5
|
created on: 2017-03-11
|
6
|
-
Copyright (C) 2017 Masahiro Tanaka
|
6
|
+
Copyright (C) 2017-2019 Masahiro Tanaka
|
7
7
|
*/
|
8
8
|
|
9
9
|
#include <ruby.h>
|
@@ -42,7 +42,7 @@ static void
|
|
42
42
|
|
43
43
|
/*
|
44
44
|
Set logarithmic sequence of numbers to self. The sequence is obtained from
|
45
|
-
base**(beg+i*step)
|
45
|
+
`base**(beg+i*step)`
|
46
46
|
where i is 1-dimensional index.
|
47
47
|
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
48
48
|
|
@@ -54,11 +54,12 @@ static void
|
|
54
54
|
|
55
55
|
@example
|
56
56
|
Numo::DFloat.new(5).logseq(4,-1,2)
|
57
|
-
=> Numo::DFloat#shape=[5]
|
58
|
-
|
57
|
+
# => Numo::DFloat#shape=[5]
|
58
|
+
# [16, 8, 4, 2, 1]
|
59
|
+
|
59
60
|
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
60
|
-
=> Numo::DComplex#shape=[5]
|
61
|
-
|
61
|
+
# => Numo::DComplex#shape=[5]
|
62
|
+
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
62
63
|
*/
|
63
64
|
static VALUE
|
64
65
|
<%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
|
@@ -75,14 +75,13 @@ static void
|
|
75
75
|
passing that element and indices along each axis as parameters.
|
76
76
|
Creates a new NArray containing the values returned by the block.
|
77
77
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
78
|
-
|
79
78
|
@overload <%=name%>
|
80
|
-
|
81
|
-
|
82
|
-
@
|
83
|
-
|
79
|
+
For a block `{|x,i,j,...| ... }`,
|
80
|
+
@yieldparam [Numeric] x an element
|
81
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
84
82
|
@return [Numo::NArray] mapped array
|
85
|
-
|
83
|
+
@see #map
|
84
|
+
@see #each_with_index
|
86
85
|
*/
|
87
86
|
static VALUE
|
88
87
|
<%=c_func(0)%>(VALUE self)
|
@@ -39,8 +39,8 @@ static void
|
|
39
39
|
<% else %>
|
40
40
|
@overload <%=name%>(axis:nil, keepdims:false)
|
41
41
|
<% end %>
|
42
|
-
@param [Numeric,Array,Range] axis
|
43
|
-
@param [TrueClass] keepdims
|
42
|
+
@param [Numeric,Array,Range] axis Finds <%=name%> along the axis.
|
43
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
44
44
|
@return [Numo::<%=class_name%>] returns <%=name%> of self.
|
45
45
|
*/
|
46
46
|
|
@@ -25,7 +25,7 @@ static void
|
|
25
25
|
<% else %>
|
26
26
|
@overload <%=name%>(axis:nil, keepdims:false)
|
27
27
|
<% end %>
|
28
|
-
@param [Numeric,Array,Range] axis
|
28
|
+
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
29
29
|
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
30
30
|
@return [Numo::<%=class_name%>,Numo::<%=class_name%>] min and max of self.
|
31
31
|
*/
|
@@ -17,10 +17,10 @@ static void
|
|
17
17
|
}
|
18
18
|
|
19
19
|
/*
|
20
|
-
|
21
|
-
|
22
|
-
@
|
23
|
-
@param [Numo::NArray,Numeric] a1
|
20
|
+
Calculate polynomial.
|
21
|
+
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
22
|
+
@overload <%=name%> a0, a1, ..., an
|
23
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
24
24
|
@return [Numo::<%=class_name%>]
|
25
25
|
*/
|
26
26
|
static VALUE
|
@@ -113,14 +113,16 @@ static void
|
|
113
113
|
@return [Numo::<%=class_name%>] self.
|
114
114
|
@example
|
115
115
|
Numo::DFloat.new(6).rand
|
116
|
-
=> Numo::DFloat#shape=[6]
|
117
|
-
|
116
|
+
# => Numo::DFloat#shape=[6]
|
117
|
+
# [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
118
|
+
|
118
119
|
Numo::DComplex.new(6).rand(5+5i)
|
119
|
-
=> Numo::DComplex#shape=[6]
|
120
|
-
|
120
|
+
# => Numo::DComplex#shape=[6]
|
121
|
+
# [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
122
|
+
|
121
123
|
Numo::Int32.new(6).rand(2,5)
|
122
|
-
=> Numo::Int32#shape=[6]
|
123
|
-
|
124
|
+
# => Numo::Int32#shape=[6]
|
125
|
+
# [4, 3, 3, 2, 4, 2]
|
124
126
|
*/
|
125
127
|
static VALUE
|
126
128
|
<%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
|
@@ -75,24 +75,26 @@ static void
|
|
75
75
|
@return [Numo::<%=class_name%>] self.
|
76
76
|
@example
|
77
77
|
Numo::DFloat.new(5,5).rand_norm
|
78
|
-
=> Numo::DFloat#shape=[5,5]
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
# => Numo::DFloat#shape=[5,5]
|
79
|
+
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
80
|
+
# [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
81
|
+
# [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
82
|
+
# [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
83
|
+
# [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
84
|
+
|
84
85
|
Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
85
|
-
=> Numo::DFloat#shape=[5,5]
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
# => Numo::DFloat#shape=[5,5]
|
87
|
+
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
88
|
+
# [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
89
|
+
# [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
90
|
+
# [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
91
|
+
# [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
92
|
+
|
91
93
|
Numo::DComplex.new(3,3).rand_norm(5+5i)
|
92
|
-
=> Numo::DComplex#shape=[3,3]
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
# => Numo::DComplex#shape=[3,3]
|
95
|
+
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
96
|
+
# [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
97
|
+
# [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
96
98
|
*/
|
97
99
|
static VALUE
|
98
100
|
<%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
|
@@ -60,11 +60,12 @@ static void
|
|
60
60
|
@return [Numo::<%=class_name%>] self.
|
61
61
|
@example
|
62
62
|
Numo::DFloat.new(6).seq(1,-0.2)
|
63
|
-
=> Numo::DFloat#shape=[6]
|
64
|
-
|
63
|
+
# => Numo::DFloat#shape=[6]
|
64
|
+
# [1, 0.8, 0.6, 0.4, 0.2, 0]
|
65
|
+
|
65
66
|
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
66
|
-
=> Numo::DComplex#shape=[6]
|
67
|
-
|
67
|
+
# => Numo::DComplex#shape=[6]
|
68
|
+
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
68
69
|
*/
|
69
70
|
static VALUE
|
70
71
|
<%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
|
@@ -20,17 +20,17 @@ static void
|
|
20
20
|
<% else %>
|
21
21
|
@overload <%=name%>(axis:nil)
|
22
22
|
<% end %>
|
23
|
-
@param [Numeric,Array,Range] axis
|
23
|
+
@param [Numeric,Array,Range] axis Performs <%=name%> along the axis.
|
24
24
|
@return [Numo::<%=class_name%>] returns result of <%=name%>.
|
25
25
|
@example
|
26
|
-
Numo::DFloat[3,4,1,2].sort
|
26
|
+
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
27
27
|
*/
|
28
28
|
static VALUE
|
29
29
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
30
30
|
{
|
31
31
|
VALUE reduce;
|
32
32
|
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
|
33
|
-
ndfunc_t ndf = {0,
|
33
|
+
ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,0, ain,0};
|
34
34
|
|
35
35
|
if (!TEST_INPLACE(self)) {
|
36
36
|
self = na_copy(self);
|
@@ -52,10 +52,10 @@ static void
|
|
52
52
|
<% else %>
|
53
53
|
@overload <%=name%>(axis:nil)
|
54
54
|
<% end %>
|
55
|
-
@param [Numeric,Array,Range] axis
|
55
|
+
@param [Numeric,Array,Range] axis Performs <%=name%> along the axis.
|
56
56
|
@return [Integer,Numo::Int] returns result index of <%=name%>.
|
57
57
|
@example
|
58
|
-
Numo::NArray[3,4,1,2].sort_index
|
58
|
+
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
59
59
|
*/
|
60
60
|
static VALUE
|
61
61
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
@@ -47,7 +47,13 @@ static void
|
|
47
47
|
if (idx1) {
|
48
48
|
for (i=i1=0; i1<n1 && i<n; i++,i1++) {
|
49
49
|
x = ptr[i1];
|
50
|
-
if (rb_obj_is_kind_of(x, rb_cRange)
|
50
|
+
if (rb_obj_is_kind_of(x, rb_cRange)
|
51
|
+
#ifdef HAVE_RB_ARITHMETIC_SEQUENCE_EXTRACT
|
52
|
+
|| rb_obj_is_kind_of(x, rb_cArithSeq)
|
53
|
+
#else
|
54
|
+
|| rb_obj_is_kind_of(x, rb_cEnumerator)
|
55
|
+
#endif
|
56
|
+
) {
|
51
57
|
nary_step_sequence(x,&len,&beg,&step);
|
52
58
|
for (c=0; c<len && i<n; c++,i++) {
|
53
59
|
y = beg + step * c;
|
@@ -63,7 +69,13 @@ static void
|
|
63
69
|
} else {
|
64
70
|
for (i=i1=0; i1<n1 && i<n; i++,i1++) {
|
65
71
|
x = ptr[i1];
|
66
|
-
if (rb_obj_is_kind_of(x, rb_cRange)
|
72
|
+
if (rb_obj_is_kind_of(x, rb_cRange)
|
73
|
+
#ifdef HAVE_RB_ARITHMETIC_SEQUENCE_EXTRACT
|
74
|
+
|| rb_obj_is_kind_of(x, rb_cArithSeq)
|
75
|
+
#else
|
76
|
+
|| rb_obj_is_kind_of(x, rb_cEnumerator)
|
77
|
+
#endif
|
78
|
+
) {
|
67
79
|
nary_step_sequence(x,&len,&beg,&step);
|
68
80
|
for (c=0; c<len && i<n; c++,i++) {
|
69
81
|
y = beg + step * c;
|