numo-narray 0.9.0.5 → 0.9.0.6
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/Rakefile +10 -9
- data/ext/numo/narray/array.c +278 -287
- data/ext/numo/narray/gen/narray_def.rb +6 -6
- data/ext/numo/narray/gen/tmpl/accum.c +14 -15
- data/ext/numo/narray/gen/tmpl/accum_binary.c +11 -12
- data/ext/numo/narray/gen/tmpl/accum_index.c +11 -20
- data/ext/numo/narray/gen/tmpl/cum.c +6 -8
- data/ext/numo/narray/gen/tmpl/median.c +11 -14
- data/ext/numo/narray/gen/tmpl/minmax.c +10 -11
- data/ext/numo/narray/gen/tmpl/set2.c +1 -1
- data/ext/numo/narray/gen/tmpl/sort.c +6 -10
- data/ext/numo/narray/gen/tmpl/sort_index.c +16 -21
- data/ext/numo/narray/gen/tmpl/unary2.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/bit_count.c +4 -3
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +4 -3
- data/ext/numo/narray/narray.c +19 -8
- data/ext/numo/narray/numo/intern.h +2 -1
- data/ext/numo/narray/numo/narray.h +2 -2
- data/ext/numo/narray/numo/types/complex_macro.h +25 -11
- data/ext/numo/narray/numo/types/float_macro.h +7 -405
- data/ext/numo/narray/numo/types/real_accum.h +440 -0
- data/ext/numo/narray/numo/types/robj_macro.h +5 -405
- data/lib/numo/narray/extra.rb +50 -0
- metadata +4 -3
@@ -20,13 +20,13 @@ module NArrayMethod
|
|
20
20
|
def_method("pow", "pow", op:"**")
|
21
21
|
end
|
22
22
|
|
23
|
-
def unary2(meth, dtype,
|
24
|
-
h = {dtype:dtype,
|
23
|
+
def unary2(meth, dtype, result_class)
|
24
|
+
h = {dtype:dtype, result_class:result_class}
|
25
25
|
def_method(meth, "unary2", **h)
|
26
26
|
end
|
27
27
|
|
28
|
-
def set2(meth, dtype,
|
29
|
-
h = {dtype:dtype,
|
28
|
+
def set2(meth, dtype, result_class)
|
29
|
+
h = {dtype:dtype, result_class:result_class}
|
30
30
|
def_method(meth, "set2", h)
|
31
31
|
end
|
32
32
|
|
@@ -48,8 +48,8 @@ module NArrayMethod
|
|
48
48
|
def_method(meth, "bit_reduce", **h)
|
49
49
|
end
|
50
50
|
|
51
|
-
def accum(meth, dtype,
|
52
|
-
h = {dtype:dtype,
|
51
|
+
def accum(meth, dtype, result_class)
|
52
|
+
h = {dtype:dtype, result_class:result_class}
|
53
53
|
def_method(meth, "accum", **h)
|
54
54
|
end
|
55
55
|
|
@@ -17,33 +17,32 @@ static void
|
|
17
17
|
/*
|
18
18
|
<%=name%> of self.
|
19
19
|
<% if is_float %>
|
20
|
-
@overload <%=name%>(axis:nil, nan:false)
|
21
|
-
@param [TrueClass] nan If true,
|
20
|
+
@overload <%=name%>(axis:nil, keepdims:false, nan:false)
|
21
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
22
22
|
<% else %>
|
23
|
-
@overload <%=name%>(axis:nil)
|
23
|
+
@overload <%=name%>(axis:nil, keepdims:false)
|
24
24
|
<% end %>
|
25
|
-
@param [Numeric,Array,Range] axis
|
25
|
+
@param [Numeric,Array,Range] axis (keyword) Affected dimensions.
|
26
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
26
27
|
@return [Numo::<%=class_name%>] returns result of <%=name%>.
|
27
28
|
*/
|
28
29
|
static VALUE
|
29
30
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
30
31
|
{
|
31
|
-
int ignore_nan = 0;
|
32
32
|
VALUE v, reduce;
|
33
33
|
ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
|
34
|
-
ndfunc_arg_out_t aout[1] = {{<%=
|
34
|
+
ndfunc_arg_out_t aout[1] = {{<%=result_class%>,0}};
|
35
35
|
ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<% end %>
|
37
|
+
<% if is_float %>
|
38
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_nan);
|
39
|
+
<% else %>
|
40
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
41
|
+
<% end %>
|
43
42
|
v = na_ndloop(&ndf, 2, self, reduce);
|
44
|
-
<% if
|
43
|
+
<% if result_class == "cT" %>
|
45
44
|
return <%=type_name%>_extract(v);
|
46
|
-
<% else %>
|
45
|
+
<% else %>
|
47
46
|
return rb_funcall(v,rb_intern("extract"),0);
|
48
|
-
<% end %>
|
47
|
+
<% end %>
|
49
48
|
}
|
@@ -35,7 +35,6 @@ static void
|
|
35
35
|
static VALUE
|
36
36
|
<%=c_func%>_self(int argc, VALUE *argv, VALUE self)
|
37
37
|
{
|
38
|
-
int ignore_nan = 0;
|
39
38
|
VALUE v, reduce;
|
40
39
|
VALUE naryv[2];
|
41
40
|
ndfunc_arg_in_t ain[4] = {{cT,0},{cT,0},{sym_reduce,0},{sym_init,0}};
|
@@ -48,12 +47,12 @@ static VALUE
|
|
48
47
|
// should fix below: [self.ndim,other.ndim].max or?
|
49
48
|
naryv[0] = self;
|
50
49
|
naryv[1] = argv[0];
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
<% if is_float %>
|
51
|
+
reduce = na_reduce_dimension(argc-1, argv+1, 2, naryv, &ndf, <%=c_iter%>_nan);
|
52
|
+
<% else %>
|
53
|
+
reduce = na_reduce_dimension(argc-1, argv+1, 2, naryv, &ndf, 0);
|
54
|
+
<% end %>
|
55
|
+
|
57
56
|
v = na_ndloop(&ndf, 4, self, argv[0], reduce, m_<%=name%>_init);
|
58
57
|
return <%=type_name%>_extract(v);
|
59
58
|
}
|
@@ -62,15 +61,15 @@ static VALUE
|
|
62
61
|
Binary <%=name%>.
|
63
62
|
|
64
63
|
<% if is_float %>
|
65
|
-
@overload <%=op_map%>(other, axis:nil, nan:false)
|
66
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
64
|
+
@overload <%=op_map%>(other, axis:nil, keepdims:false, nan:false)
|
67
65
|
<% else %>
|
68
|
-
@overload <%=op_map%>(other, axis:nil)
|
66
|
+
@overload <%=op_map%>(other, axis:nil, keepdims:false)
|
69
67
|
<% end %>
|
70
68
|
@param [Numo::NArray,Numeric] other
|
71
|
-
@param [Numeric,Array,Range] axis
|
69
|
+
@param [Numeric,Array,Range] axis (keyword) Affected dimensions.
|
70
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
72
71
|
<% if is_float %>
|
73
|
-
@param [TrueClass] nan
|
72
|
+
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
74
73
|
<% end %>
|
75
74
|
@return [Numo::NArray] <%=name%> of self and other.
|
76
75
|
*/
|
@@ -24,7 +24,7 @@ static void
|
|
24
24
|
<%=name%>. Return an index of result.
|
25
25
|
<% if is_float %>
|
26
26
|
@overload <%=name%>(axis:nil, nan:false)
|
27
|
-
@param [TrueClass] nan If true,
|
27
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
28
28
|
<% else %>
|
29
29
|
@overload <%=name%>(axis:nil)
|
30
30
|
<% end %>
|
@@ -36,15 +36,12 @@ static void
|
|
36
36
|
static VALUE
|
37
37
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
38
38
|
{
|
39
|
-
int ignore_nan = 0;
|
40
39
|
narray_t *na;
|
41
40
|
VALUE idx, reduce;
|
42
41
|
ndfunc_arg_in_t ain[3] = {{Qnil,0},{Qnil,0},{sym_reduce,0}};
|
43
42
|
ndfunc_arg_out_t aout[1] = {{0,0,0}};
|
44
43
|
ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 3,1, ain,aout};
|
45
44
|
|
46
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ignore_nan);
|
47
|
-
|
48
45
|
GetNArray(self,na);
|
49
46
|
if (na->ndim==0) {
|
50
47
|
return INT2FIX(0);
|
@@ -52,27 +49,21 @@ static VALUE
|
|
52
49
|
if (na->size > (~(u_int32_t)0)) {
|
53
50
|
aout[0].type = numo_cInt64;
|
54
51
|
idx = nary_new(numo_cInt64, na->ndim, na->shape);
|
55
|
-
<% if is_float %>
|
56
|
-
if (ignore_nan) {
|
57
|
-
ndf.func = <%=c_iter%>_index64_nan;
|
58
|
-
} else {
|
59
|
-
ndf.func = <%=c_iter%>_index64;
|
60
|
-
}
|
61
|
-
<% else %>
|
62
52
|
ndf.func = <%=c_iter%>_index64;
|
63
|
-
<%
|
53
|
+
<% if is_float %>
|
54
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_index64_nan);
|
55
|
+
<% else %>
|
56
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
57
|
+
<% end %>
|
64
58
|
} else {
|
65
59
|
aout[0].type = numo_cInt32;
|
66
60
|
idx = nary_new(numo_cInt32, na->ndim, na->shape);
|
67
|
-
<% if is_float %>
|
68
|
-
if (ignore_nan) {
|
69
|
-
ndf.func = <%=c_iter%>_index32_nan;
|
70
|
-
} else {
|
71
|
-
ndf.func = <%=c_iter%>_index32;
|
72
|
-
}
|
73
|
-
<% else %>
|
74
61
|
ndf.func = <%=c_iter%>_index32;
|
75
|
-
<%
|
62
|
+
<% if is_float %>
|
63
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_index32_nan);
|
64
|
+
<% else %>
|
65
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
66
|
+
<% end %>
|
76
67
|
}
|
77
68
|
rb_funcall(idx, rb_intern("seq"), 0);
|
78
69
|
|
@@ -28,24 +28,22 @@ static void
|
|
28
28
|
<%=name%> of self.
|
29
29
|
@overload <%=name%>(axis:nil, nan:false)
|
30
30
|
@param [Numeric,Array,Range] axis Affected dimensions.
|
31
|
-
@param [TrueClass] nan If true,
|
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
|
*/
|
34
34
|
static VALUE
|
35
35
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
36
36
|
{
|
37
|
-
int ignore_nan = 0;
|
38
37
|
VALUE reduce;
|
39
38
|
ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
|
40
39
|
ndfunc_arg_out_t aout[1] = {{cT,0}};
|
41
40
|
ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP|NDF_FLAT_REDUCE|NDF_CUM,
|
42
41
|
2, 1, ain, aout };
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<% end %>
|
43
|
+
<% if is_float %>
|
44
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_nan);
|
45
|
+
<% else %>
|
46
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
47
|
+
<% end %>
|
50
48
|
return na_ndloop(&ndf, 2, self, reduce);
|
51
49
|
}
|
@@ -34,34 +34,31 @@ static void
|
|
34
34
|
/*
|
35
35
|
<%=name%> of self.
|
36
36
|
<% if is_float %>
|
37
|
-
@overload <%=name%>(axis:nil, nan:false)
|
38
|
-
@param [TrueClass] nan
|
37
|
+
@overload <%=name%>(axis:nil, keepdims:false, nan:false)
|
38
|
+
@param [TrueClass] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
39
39
|
<% else %>
|
40
|
-
@overload <%=name%>(axis:nil)
|
40
|
+
@overload <%=name%>(axis:nil, keepdims:false)
|
41
41
|
<% end %>
|
42
|
-
@param [Numeric,Array,Range] axis
|
42
|
+
@param [Numeric,Array,Range] axis (keyword) Affected dimensions.
|
43
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
43
44
|
@return [Numo::<%=class_name%>] returns <%=name%> of self.
|
44
45
|
*/
|
45
46
|
|
46
47
|
static VALUE
|
47
48
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
48
49
|
{
|
49
|
-
int nan = 0;
|
50
50
|
VALUE reduce;
|
51
51
|
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
|
52
52
|
ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}};
|
53
53
|
ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,1, ain,aout};
|
54
54
|
|
55
55
|
self = na_copy(self); // as temporary buffer
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
} else {
|
61
|
-
ndf.func = <%=c_iter%>_ignan;
|
62
|
-
}
|
63
|
-
<% else %>
|
56
|
+
<% if is_float %>
|
57
|
+
ndf.func = <%=c_iter%>_ignan;
|
58
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_prnan);
|
59
|
+
<% else %>
|
64
60
|
ndf.func = <%=c_iter%>;
|
65
|
-
|
61
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
62
|
+
<% end %>
|
66
63
|
return na_ndloop(&ndf, 2, self, reduce);
|
67
64
|
}
|
@@ -20,28 +20,27 @@ static void
|
|
20
20
|
/*
|
21
21
|
<%=name%> of self.
|
22
22
|
<% if is_float %>
|
23
|
-
@overload <%=name%>(axis:nil, nan:false)
|
24
|
-
@param [TrueClass] nan If true,
|
23
|
+
@overload <%=name%>(axis:nil, keepdims:false, nan:false)
|
24
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
25
25
|
<% else %>
|
26
|
-
@overload <%=name%>(axis:nil)
|
26
|
+
@overload <%=name%>(axis:nil, keepdims:false)
|
27
27
|
<% end %>
|
28
|
-
@param [Numeric,Array,Range] axis
|
28
|
+
@param [Numeric,Array,Range] axis (keyword) Affected dimensions.
|
29
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
29
30
|
@return [Numo::<%=class_name%>,Numo::<%=class_name%>] min and max of self.
|
30
31
|
*/
|
31
32
|
static VALUE
|
32
33
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
33
34
|
{
|
34
|
-
int ignore_nan = 0;
|
35
35
|
VALUE reduce;
|
36
36
|
ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
|
37
37
|
ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
|
38
38
|
ndfunc_t ndf = {<%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
<% end %>
|
40
|
+
<% if is_float %>
|
41
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_nan);
|
42
|
+
<% else %>
|
43
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
44
|
+
<% end %>
|
46
45
|
return na_ndloop(&ndf, 2, self, reduce);
|
47
46
|
}
|
@@ -48,7 +48,7 @@ static void
|
|
48
48
|
static VALUE
|
49
49
|
<%=c_func(1)%>(VALUE self, VALUE a1)
|
50
50
|
{
|
51
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{<%=
|
51
|
+
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{<%=result_class%>,0}};
|
52
52
|
ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 2, 0, ain, 0 };
|
53
53
|
|
54
54
|
na_ndloop(&ndf, 2, self, a1);
|
@@ -28,7 +28,6 @@ static void
|
|
28
28
|
static VALUE
|
29
29
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
30
30
|
{
|
31
|
-
int nan = 0;
|
32
31
|
VALUE reduce;
|
33
32
|
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
|
34
33
|
ndfunc_t ndf = {0, STRIDE_LOOP|NDF_FLAT_REDUCE, 2,0, ain,0};
|
@@ -36,16 +35,13 @@ static VALUE
|
|
36
35
|
if (!TEST_INPLACE(self)) {
|
37
36
|
self = na_copy(self);
|
38
37
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
} else {
|
44
|
-
ndf.func = <%=c_iter%>_ignan;
|
45
|
-
}
|
46
|
-
<% else %>
|
38
|
+
<% if is_float %>
|
39
|
+
ndf.func = <%=c_iter%>_ignan;
|
40
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_prnan);
|
41
|
+
<% else %>
|
47
42
|
ndf.func = <%=c_iter%>;
|
48
|
-
|
43
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
44
|
+
<% end %>
|
49
45
|
na_ndloop(&ndf, 2, self, reduce);
|
50
46
|
return self;
|
51
47
|
}
|
@@ -55,7 +55,6 @@ static void
|
|
55
55
|
static VALUE
|
56
56
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
57
57
|
{
|
58
|
-
int nan = 0;
|
59
58
|
size_t size;
|
60
59
|
narray_t *na;
|
61
60
|
VALUE idx, tmp, reduce, res;
|
@@ -64,8 +63,6 @@ static VALUE
|
|
64
63
|
ndfunc_arg_out_t aout[1] = {{0,0,0}};
|
65
64
|
ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_CUM, 3,1, ain,aout};
|
66
65
|
|
67
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &nan); // v[0] = self
|
68
|
-
|
69
66
|
GetNArray(self,na);
|
70
67
|
if (na->ndim==0) {
|
71
68
|
return INT2FIX(0);
|
@@ -74,28 +71,26 @@ static VALUE
|
|
74
71
|
ain[1].type =
|
75
72
|
aout[0].type = numo_cInt64;
|
76
73
|
idx = nary_new(numo_cInt64, na->ndim, na->shape);
|
77
|
-
<% if is_float %>
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<% end %>
|
74
|
+
<% if is_float %>
|
75
|
+
ndf.func = <%=type_name%>_index64_qsort_ignan;
|
76
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
|
77
|
+
<%=type_name%>_index64_qsort_prnan);
|
78
|
+
<% else %>
|
79
|
+
ndf.func = <%=type_name%>_index64_qsort;
|
80
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
81
|
+
<% end %>
|
86
82
|
} else {
|
87
83
|
ain[1].type =
|
88
84
|
aout[0].type = numo_cInt32;
|
89
85
|
idx = nary_new(numo_cInt32, na->ndim, na->shape);
|
90
|
-
<% if is_float %>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
<% end %>
|
86
|
+
<% if is_float %>
|
87
|
+
ndf.func = <%=type_name%>_index32_qsort_ignan;
|
88
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf,
|
89
|
+
<%=type_name%>_index32_qsort_prnan);
|
90
|
+
<% else %>
|
91
|
+
ndf.func = <%=type_name%>_index32_qsort;
|
92
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
93
|
+
<% end %>
|
99
94
|
}
|
100
95
|
rb_funcall(idx, rb_intern("seq"), 0);
|
101
96
|
|
@@ -51,7 +51,7 @@ static VALUE
|
|
51
51
|
<%=c_func(0)%>(VALUE self)
|
52
52
|
{
|
53
53
|
ndfunc_arg_in_t ain[1] = {{cT,0}};
|
54
|
-
ndfunc_arg_out_t aout[1] = {{<%=
|
54
|
+
ndfunc_arg_out_t aout[1] = {{<%=result_class%>,0}};
|
55
55
|
ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 1, 1, ain, aout };
|
56
56
|
|
57
57
|
return na_ndloop(&ndf, 1, self);
|
@@ -66,8 +66,9 @@ static void
|
|
66
66
|
/*
|
67
67
|
Returns the number of bits.
|
68
68
|
If argument is supplied, return Int-array counted along the axes.
|
69
|
-
@overload <%=op_map%>(axis:nil)
|
70
|
-
@param [Integer,Array,Range] axis
|
69
|
+
@overload <%=op_map%>(axis:nil, keepdims:false)
|
70
|
+
@param [Integer,Array,Range] axis (keyword) axes to be counted.
|
71
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
71
72
|
@return [Numo::Int64]
|
72
73
|
*/
|
73
74
|
static VALUE
|
@@ -78,7 +79,7 @@ static VALUE
|
|
78
79
|
ndfunc_arg_out_t aout[1] = {{numo_cInt64,0}};
|
79
80
|
ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP_NIP, 3, 1, ain, aout };
|
80
81
|
|
81
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, 0);
|
82
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
82
83
|
v = na_ndloop(&ndf, 3, self, reduce, INT2FIX(0));
|
83
84
|
return rb_funcall(v,rb_intern("extract"),0);
|
84
85
|
}
|
@@ -98,8 +98,9 @@ static void
|
|
98
98
|
Return true if all of bits are one (true).
|
99
99
|
<% end %>
|
100
100
|
If argument is supplied, return Bit-array reduced along the axes.
|
101
|
-
@overload <%=op_map%>(axis:nil)
|
102
|
-
@param [Integer,Array,Range] axis
|
101
|
+
@overload <%=op_map%>(axis:nil, keepdims:false)
|
102
|
+
@param [Integer,Array,Range] axis (keyword) axes to be reduced.
|
103
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
103
104
|
@return [Numo::Bit] .
|
104
105
|
*/
|
105
106
|
static VALUE
|
@@ -110,7 +111,7 @@ static VALUE
|
|
110
111
|
ndfunc_arg_out_t aout[1] = {{numo_cBit,0}};
|
111
112
|
ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP_NIP, 3,1, ain,aout};
|
112
113
|
|
113
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, 0);
|
114
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
114
115
|
v = na_ndloop(&ndf, 3, self, reduce, INT2FIX(<%=init_bit%>));
|
115
116
|
if (argc > 0) {
|
116
117
|
return v;
|