numo-narray 0.9.0.4 → 0.9.0.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 +11 -8
- data/Rakefile +9 -0
- data/ext/numo/narray/array.c +178 -47
- data/ext/numo/narray/data.c +105 -97
- data/ext/numo/narray/depend.erb +6 -7
- data/ext/numo/narray/gen/cogen.rb +30 -7
- data/ext/numo/narray/gen/def/bit.rb +17 -14
- data/ext/numo/narray/gen/def/dcomplex.rb +19 -15
- data/ext/numo/narray/gen/def/dfloat.rb +17 -13
- data/ext/numo/narray/gen/def/int16.rb +16 -12
- data/ext/numo/narray/gen/def/int32.rb +16 -12
- data/ext/numo/narray/gen/def/int64.rb +16 -12
- data/ext/numo/narray/gen/def/int8.rb +16 -12
- data/ext/numo/narray/gen/def/robject.rb +18 -14
- data/ext/numo/narray/gen/def/scomplex.rb +19 -15
- data/ext/numo/narray/gen/def/sfloat.rb +17 -13
- data/ext/numo/narray/gen/def/uint16.rb +16 -12
- data/ext/numo/narray/gen/def/uint32.rb +16 -12
- data/ext/numo/narray/gen/def/uint64.rb +16 -12
- data/ext/numo/narray/gen/def/uint8.rb +16 -12
- data/ext/numo/narray/gen/erbpp2.rb +324 -0
- data/ext/numo/narray/gen/narray_def.rb +252 -0
- data/ext/numo/narray/gen/spec.rb +141 -71
- data/ext/numo/narray/gen/tmpl/accum.c +22 -9
- data/ext/numo/narray/gen/tmpl/accum_binary.c +29 -13
- data/ext/numo/narray/gen/tmpl/accum_index.c +38 -16
- data/ext/numo/narray/gen/tmpl/alloc_func.c +107 -0
- data/ext/numo/narray/gen/tmpl/allocate.c +1 -1
- data/ext/numo/narray/gen/tmpl/aref.c +1 -1
- data/ext/numo/narray/gen/tmpl/aset.c +4 -2
- data/ext/numo/narray/gen/tmpl/binary.c +4 -4
- data/ext/numo/narray/gen/tmpl/binary2.c +5 -5
- data/ext/numo/narray/gen/tmpl/binary_s.c +5 -5
- data/ext/numo/narray/gen/tmpl/bincount.c +4 -4
- data/ext/numo/narray/gen/tmpl/cast.c +9 -6
- data/ext/numo/narray/gen/tmpl/cast_array.c +4 -9
- data/ext/numo/narray/gen/tmpl/class.c +9 -0
- data/ext/numo/narray/gen/tmpl/clip.c +118 -0
- data/ext/numo/narray/gen/tmpl/coerce_cast.c +4 -2
- data/ext/numo/narray/gen/tmpl/cond_binary.c +5 -5
- data/ext/numo/narray/gen/tmpl/cond_unary.c +6 -6
- data/ext/numo/narray/gen/tmpl/cum.c +18 -9
- data/ext/numo/narray/gen/tmpl/each.c +2 -2
- data/ext/numo/narray/gen/tmpl/each_with_index.c +2 -2
- data/ext/numo/narray/gen/tmpl/extract.c +2 -2
- data/ext/numo/narray/gen/tmpl/extract_data.c +48 -0
- data/ext/numo/narray/gen/tmpl/eye.c +3 -3
- data/ext/numo/narray/gen/tmpl/fill.c +2 -2
- data/ext/numo/narray/gen/tmpl/format.c +5 -5
- data/ext/numo/narray/gen/tmpl/format_to_a.c +4 -4
- data/ext/numo/narray/gen/tmpl/frexp.c +37 -0
- data/ext/numo/narray/gen/tmpl/init_class.c +20 -0
- data/ext/numo/narray/gen/tmpl/init_module.c +12 -0
- data/ext/numo/narray/gen/tmpl/inspect.c +2 -2
- data/ext/numo/narray/gen/tmpl/lib.c +45 -0
- data/ext/numo/narray/gen/tmpl/logseq.c +1 -1
- data/ext/numo/narray/gen/tmpl/map_with_index.c +2 -2
- data/ext/numo/narray/gen/tmpl/median.c +31 -8
- data/ext/numo/narray/gen/tmpl/minmax.c +24 -24
- data/ext/numo/narray/gen/tmpl/module.c +9 -0
- data/ext/numo/narray/gen/tmpl/new_dim0.c +12 -0
- data/ext/numo/narray/gen/tmpl/poly.c +3 -3
- data/ext/numo/narray/gen/tmpl/pow.c +1 -1
- data/ext/numo/narray/gen/tmpl/powint.c +1 -1
- data/ext/numo/narray/gen/tmpl/qsort.c +10 -3
- data/ext/numo/narray/gen/tmpl/rand.c +1 -1
- data/ext/numo/narray/gen/tmpl/rand_norm.c +1 -1
- data/ext/numo/narray/gen/tmpl/seq.c +1 -1
- data/ext/numo/narray/gen/tmpl/set2.c +5 -5
- data/ext/numo/narray/gen/tmpl/sort.c +29 -14
- data/ext/numo/narray/gen/tmpl/sort_index.c +41 -20
- data/ext/numo/narray/gen/tmpl/store.c +11 -5
- data/ext/numo/narray/gen/tmpl/store_array.c +1 -1
- data/ext/numo/narray/gen/tmpl/store_bit.c +1 -1
- data/ext/numo/narray/gen/tmpl/store_from.c +1 -1
- data/ext/numo/narray/gen/tmpl/store_numeric.c +3 -16
- data/ext/numo/narray/gen/tmpl/to_a.c +2 -2
- data/ext/numo/narray/gen/tmpl/unary.c +7 -7
- data/ext/numo/narray/gen/tmpl/unary2.c +8 -8
- data/ext/numo/narray/gen/tmpl/unary_ret2.c +33 -0
- data/ext/numo/narray/gen/tmpl/unary_s.c +8 -8
- data/ext/numo/narray/gen/tmpl_bit/allocate.c +1 -5
- data/ext/numo/narray/gen/tmpl_bit/aref.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/aset.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/binary.c +8 -8
- data/ext/numo/narray/gen/tmpl_bit/bit_count.c +8 -8
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +6 -6
- data/ext/numo/narray/gen/tmpl_bit/each.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/extract.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/fill.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/format.c +5 -5
- data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/inspect.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/mask.c +5 -5
- data/ext/numo/narray/gen/tmpl_bit/none_p.c +4 -4
- data/ext/numo/narray/gen/tmpl_bit/store_array.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/store_from.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/to_a.c +2 -2
- data/ext/numo/narray/gen/tmpl_bit/unary.c +9 -9
- data/ext/numo/narray/gen/tmpl_bit/where.c +6 -6
- data/ext/numo/narray/gen/tmpl_bit/where2.c +8 -8
- data/ext/numo/narray/index.c +46 -30
- data/ext/numo/narray/math.c +12 -6
- data/ext/numo/narray/narray.c +242 -218
- data/ext/numo/narray/ndloop.c +17 -24
- data/ext/numo/narray/numo/intern.h +63 -67
- data/ext/numo/narray/numo/narray.h +38 -13
- data/ext/numo/narray/numo/ndloop.h +1 -1
- data/ext/numo/narray/numo/template.h +1 -1
- data/ext/numo/narray/numo/types/complex.h +8 -4
- data/ext/numo/narray/numo/types/complex_macro.h +118 -1
- data/ext/numo/narray/numo/types/float_macro.h +283 -6
- data/ext/numo/narray/numo/types/robj_macro.h +261 -9
- data/ext/numo/narray/numo/types/xint_macro.h +35 -0
- data/ext/numo/narray/struct.c +34 -15
- data/lib/erbpp.rb +5 -1
- data/lib/erbpp/line_number.rb +10 -3
- data/lib/erbpp/narray_def.rb +55 -25
- data/lib/numo/narray/extra.rb +638 -219
- data/numo-narray.gemspec +1 -0
- data/spec/narray_spec.rb +2 -2
- metadata +17 -14
- data/ext/numo/narray/gen/dtype.erb.c +0 -82
- data/ext/numo/narray/gen/tmpl/cast_numeric.c +0 -22
- data/ext/numo/narray/gen/tmpl/robj_allocate.c +0 -32
- data/ext/numo/narray/gen/tmpl_bit/cast.c +0 -37
- data/ext/numo/narray/gen/tmpl_bit/cast_array.c +0 -18
- data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +0 -22
- data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +0 -8
- data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +0 -94
- data/ext/numo/narray/gen/tmpl_bit/store.c +0 -32
- data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +0 -22
@@ -0,0 +1,37 @@
|
|
1
|
+
static void
|
2
|
+
<%=c_iter%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1, *p2, *p3;
|
6
|
+
ssize_t s1, s2, s3;
|
7
|
+
dtype x;
|
8
|
+
int y;
|
9
|
+
INIT_COUNTER(lp, i);
|
10
|
+
INIT_PTR(lp, 0, p1, s1);
|
11
|
+
INIT_PTR(lp, 1, p2, s2);
|
12
|
+
INIT_PTR(lp, 2, p3, s3);
|
13
|
+
for (; i--;) {
|
14
|
+
GET_DATA_STRIDE(p1,s1,dtype,x);
|
15
|
+
x = m_<%=name%>(x,&y);
|
16
|
+
SET_DATA_STRIDE(p2,s2,dtype,x);
|
17
|
+
SET_DATA_STRIDE(p3,s3,int32_t,y);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
/*
|
22
|
+
split the number x into a normalized fraction and an exponent.
|
23
|
+
Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
24
|
+
|
25
|
+
@overload <%=name%>(x)
|
26
|
+
@param [Numo::NArray,Numeric] x
|
27
|
+
@return [Numo::<%=class_name%>,Numo::Int32] mantissa and exponent.
|
28
|
+
|
29
|
+
*/
|
30
|
+
static VALUE
|
31
|
+
<%=c_func(1)%>(VALUE mod, VALUE a1)
|
32
|
+
{
|
33
|
+
ndfunc_arg_in_t ain[1] = {{cT,0}};
|
34
|
+
ndfunc_arg_out_t aout[2] = {{cT,0},{numo_cInt32,0}};
|
35
|
+
ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP, 1,2, ain,aout };
|
36
|
+
return na_ndloop(&ndf, 1, a1);
|
37
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
Document-class: <%= full_class_name %>
|
3
|
+
<%= description %>
|
4
|
+
*/
|
5
|
+
cT = rb_define_class_under(<%=ns_var%>, "<%=class_name%>", cNArray);
|
6
|
+
|
7
|
+
<% for x in class_alias %>
|
8
|
+
// alias of <%=class_name%>
|
9
|
+
rb_define_const(<%=ns_var%>, "<%=x%>", <%=type_var%>);
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
hCast = rb_hash_new();
|
13
|
+
rb_define_const(cT, "UPCAST", hCast);
|
14
|
+
rb_hash_aset(hCast, rb_cArray, cT);
|
15
|
+
<% for x in upcast %>
|
16
|
+
<%= x %><% end %>
|
17
|
+
|
18
|
+
<% @children.each do |m| %>
|
19
|
+
<%= m.init_def %><% end %>
|
20
|
+
rb_define_singleton_method(cT, "[]", <%=find("cast").c_func%>, -2);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/*
|
2
|
+
Document-module: <%= full_module_name %>
|
3
|
+
<%= description %>
|
4
|
+
*/
|
5
|
+
<% if module_var != ns_var %>
|
6
|
+
<%=module_var%> = rb_define_module_under(<%=ns_var%>, "<%=module_name%>");
|
7
|
+
<% end %>
|
8
|
+
<% @children.each do |m| %>
|
9
|
+
<%= m.init_def %><% end %>
|
10
|
+
|
11
|
+
// how to do this?
|
12
|
+
//rb_extend_object(cT, mTM);
|
@@ -4,7 +4,7 @@ static VALUE
|
|
4
4
|
<% if is_object %>
|
5
5
|
return rb_inspect(*(VALUE*)(ptr+pos));
|
6
6
|
<% else %>
|
7
|
-
return format_<%=
|
7
|
+
return format_<%=type_name%>(fmt, (dtype*)(ptr+pos));
|
8
8
|
<% end %>
|
9
9
|
}
|
10
10
|
|
@@ -14,7 +14,7 @@ static VALUE
|
|
14
14
|
@return [String]
|
15
15
|
*/
|
16
16
|
VALUE
|
17
|
-
<%=c_func%>(VALUE ary)
|
17
|
+
<%=c_func(0)%>(VALUE ary)
|
18
18
|
{
|
19
19
|
return na_ndloop_inspect(ary, <%=c_iter%>, Qnil);
|
20
20
|
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/*
|
2
|
+
<%= file_name %>
|
3
|
+
Ruby/Numo::GSL - GSL wrapper for Ruby/Numo::NArray
|
4
|
+
|
5
|
+
created on: 2017-03-11
|
6
|
+
Copyright (C) 2017 Masahiro Tanaka
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <ruby.h>
|
10
|
+
#include <assert.h>
|
11
|
+
#include "numo/narray.h"
|
12
|
+
#include "numo/template.h"
|
13
|
+
#include "SFMT.h"
|
14
|
+
|
15
|
+
#define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
|
16
|
+
|
17
|
+
<% id_decl.each do |x| %>
|
18
|
+
<%= x %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% include_files.each do |f| %>
|
22
|
+
#include <<%=f%>>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
VALUE cT;
|
26
|
+
extern VALUE cRT;
|
27
|
+
|
28
|
+
<% children.each do |c|%>
|
29
|
+
<%= c.result+"\n\n" %>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
void
|
33
|
+
Init_<%=lib_name%>(void)
|
34
|
+
{
|
35
|
+
VALUE hCast, <%=ns_var%>;
|
36
|
+
|
37
|
+
<%=ns_var%> = rb_define_module("Numo");
|
38
|
+
|
39
|
+
<% id_assign.each do |x| %>
|
40
|
+
<%= x %><% end %>
|
41
|
+
|
42
|
+
<% children.each do |c| %>
|
43
|
+
<%= c.init_def %>
|
44
|
+
<% end %>
|
45
|
+
}
|
@@ -61,7 +61,7 @@ static void
|
|
61
61
|
[1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
62
62
|
*/
|
63
63
|
static VALUE
|
64
|
-
<%=c_func%>(int argc, VALUE *args, VALUE self)
|
64
|
+
<%=c_func(-1)%>(int argc, VALUE *args, VALUE self)
|
65
65
|
{
|
66
66
|
logseq_opt_t *g;
|
67
67
|
VALUE vbeg, vstep, vbase;
|
@@ -75,7 +75,7 @@ void
|
|
75
75
|
Creates a new NArray containing the values returned by the block.
|
76
76
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
77
77
|
|
78
|
-
@overload <%=
|
78
|
+
@overload <%=name%>
|
79
79
|
|
80
80
|
For a block {|x,i,j,...| ... }
|
81
81
|
@yield [x,i,j,...] x is an element, i,j,... are multidimensional indices.
|
@@ -84,7 +84,7 @@ void
|
|
84
84
|
|
85
85
|
*/
|
86
86
|
static VALUE
|
87
|
-
<%=c_func%>(VALUE self)
|
87
|
+
<%=c_func(0)%>(VALUE self)
|
88
88
|
{
|
89
89
|
ndfunc_arg_in_t ain[1] = {{Qnil,0}};
|
90
90
|
ndfunc_arg_out_t aout[1] = {{cT,0}};
|
@@ -1,5 +1,6 @@
|
|
1
|
+
<% (is_float ? ["_ignan","_prnan"] : [""]).each do |j| %>
|
1
2
|
static void
|
2
|
-
<%=c_iter%>(na_loop_t *const lp)
|
3
|
+
<%=c_iter%><%=j%>(na_loop_t *const lp)
|
3
4
|
{
|
4
5
|
size_t n;
|
5
6
|
char *p1, *p2;
|
@@ -10,7 +11,7 @@ static void
|
|
10
11
|
p2 = (lp->args[1]).ptr + (lp->args[1].iter[0]).pos;
|
11
12
|
buf = (dtype*)p1;
|
12
13
|
|
13
|
-
<%=
|
14
|
+
<%=type_name%>_qsort<%=j%>(buf, n, sizeof(dtype));
|
14
15
|
|
15
16
|
<% if is_float %>
|
16
17
|
for (; n; n--) {
|
@@ -28,17 +29,39 @@ static void
|
|
28
29
|
*(dtype*)p2 = buf[(n-1)/2];
|
29
30
|
}
|
30
31
|
}
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
/*
|
35
|
+
<%=name%> of self.
|
36
|
+
<% if is_float %>
|
37
|
+
@overload <%=name%>(axis:nil, nan:false)
|
38
|
+
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
39
|
+
<% else %>
|
40
|
+
@overload <%=name%>(axis:nil)
|
41
|
+
<% end %>
|
42
|
+
@param [Numeric,Array,Range] axis Affected dimensions.
|
43
|
+
@return [Numo::<%=class_name%>] returns <%=name%> of self.
|
44
|
+
*/
|
31
45
|
|
32
46
|
static VALUE
|
33
|
-
<%=c_func%>(int argc, VALUE *argv, VALUE self)
|
47
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
34
48
|
{
|
49
|
+
int nan = 0;
|
35
50
|
VALUE reduce;
|
36
|
-
ndfunc_arg_in_t ain[2] = {{
|
51
|
+
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{sym_reduce,0}};
|
37
52
|
ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}};
|
38
|
-
ndfunc_t ndf = {
|
39
|
-
|
40
|
-
self = na_copy(self);
|
41
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self); // v[0] = self
|
53
|
+
ndfunc_t ndf = {0, NDF_HAS_LOOP|NDF_FLAT_REDUCE, 2,1, ain,aout};
|
42
54
|
|
55
|
+
self = na_copy(self); // as temporary buffer
|
56
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &nan); // v[0] = self
|
57
|
+
<% if is_float %>
|
58
|
+
if (nan) {
|
59
|
+
ndf.func = <%=c_iter%>_prnan;
|
60
|
+
} else {
|
61
|
+
ndf.func = <%=c_iter%>_ignan;
|
62
|
+
}
|
63
|
+
<% else %>
|
64
|
+
ndf.func = <%=c_iter%>;
|
65
|
+
<% end %>
|
43
66
|
return na_ndloop(&ndf, 2, self, reduce);
|
44
67
|
}
|
@@ -1,47 +1,47 @@
|
|
1
|
+
<% (is_float ? ["","_nan"] : [""]).each do |j| %>
|
1
2
|
static void
|
2
|
-
<%=c_iter%>(na_loop_t *const lp)
|
3
|
+
<%=c_iter%><%=j%>(na_loop_t *const lp)
|
3
4
|
{
|
4
|
-
size_t
|
5
|
+
size_t n;
|
5
6
|
char *p1;
|
6
7
|
ssize_t s1;
|
7
|
-
dtype
|
8
|
+
dtype xmin,xmax;
|
8
9
|
|
9
|
-
INIT_COUNTER(lp,
|
10
|
+
INIT_COUNTER(lp, n);
|
10
11
|
INIT_PTR(lp, 0, p1, s1);
|
11
12
|
|
12
|
-
xmin
|
13
|
-
|
14
|
-
i--;
|
15
|
-
for (; i--;) {
|
16
|
-
x = *(dtype*)p1;
|
17
|
-
if (!m_isnan(x)) {
|
18
|
-
if (m_isnan(xmax) || m_gt(x,xmax)) {
|
19
|
-
xmax = x;
|
20
|
-
}
|
21
|
-
if (m_isnan(xmin) || m_lt(x,xmin)) {
|
22
|
-
xmin = x;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
p1 += s1;
|
26
|
-
}
|
13
|
+
f_<%=name%><%=j%>(n,p1,s1,&xmin,&xmax);
|
14
|
+
|
27
15
|
*(dtype*)(lp->args[1].ptr + lp->args[1].iter[0].pos) = xmin;
|
28
16
|
*(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
|
29
17
|
}
|
18
|
+
<% end %>
|
30
19
|
|
31
20
|
/*
|
32
|
-
<%=
|
33
|
-
|
34
|
-
@
|
21
|
+
<%=name%> of self.
|
22
|
+
<% if is_float %>
|
23
|
+
@overload <%=name%>(axis:nil, nan:false)
|
24
|
+
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
25
|
+
<% else %>
|
26
|
+
@overload <%=name%>(axis:nil)
|
27
|
+
<% end %>
|
28
|
+
@param [Numeric,Array,Range] axis Affected dimensions.
|
35
29
|
@return [Numo::<%=class_name%>,Numo::<%=class_name%>] min and max of self.
|
36
30
|
*/
|
37
31
|
static VALUE
|
38
|
-
<%=c_func%>(int argc, VALUE *argv, VALUE self)
|
32
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
39
33
|
{
|
34
|
+
int ignore_nan = 0;
|
40
35
|
VALUE reduce;
|
41
36
|
ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
|
42
37
|
ndfunc_arg_out_t aout[2] = {{cT,0},{cT,0}};
|
43
38
|
ndfunc_t ndf = {<%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,2, ain,aout};
|
44
39
|
|
45
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self);
|
40
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ignore_nan);
|
41
|
+
<% if is_float %>
|
42
|
+
if (ignore_nan) {
|
43
|
+
ndf.func = <%=c_iter%>_nan;
|
44
|
+
}
|
45
|
+
<% end %>
|
46
46
|
return na_ndloop(&ndf, 2, self, reduce);
|
47
47
|
}
|
@@ -18,13 +18,13 @@ static void
|
|
18
18
|
|
19
19
|
/*
|
20
20
|
Polynomial.: a0 + a1*x + a2*x**2 + a3*x**3 + ... + an*x**n
|
21
|
-
@overload <%=
|
21
|
+
@overload <%=name%> a0, a1, ...
|
22
22
|
@param [Numo::NArray,Numeric] a0
|
23
23
|
@param [Numo::NArray,Numeric] a1 , ...
|
24
24
|
@return [Numo::<%=class_name%>]
|
25
25
|
*/
|
26
26
|
static VALUE
|
27
|
-
<%=c_func%>(VALUE self, VALUE args)
|
27
|
+
<%=c_func(-2)%>(VALUE self, VALUE args)
|
28
28
|
{
|
29
29
|
int argc, i;
|
30
30
|
VALUE *argv;
|
@@ -45,5 +45,5 @@ static VALUE
|
|
45
45
|
}
|
46
46
|
a = rb_ary_new4(argc+1, argv);
|
47
47
|
v = na_ndloop2(&ndf, a);
|
48
|
-
return
|
48
|
+
return <%=type_name%>_extract(v);
|
49
49
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
qsort.c
|
3
3
|
Numerical Array Extension for Ruby
|
4
|
-
(C) Copyright 2007-
|
4
|
+
(C) Copyright 2007-2017 by Masahiro TANAKA
|
5
5
|
*/
|
6
6
|
|
7
7
|
/*
|
@@ -68,9 +68,16 @@
|
|
68
68
|
#define qsort_dtype <%=dtype%>
|
69
69
|
#undef qsort_cast
|
70
70
|
#define qsort_cast <%=dcast%>
|
71
|
+
<% if "#{suffix}" != "" %>
|
72
|
+
#undef cmp
|
73
|
+
#undef cmpgt
|
74
|
+
#define cmp(a,b) cmp<%=suffix%>(a,b)
|
75
|
+
#define cmpgt(a,b) cmpgt<%=suffix%>(a,b)
|
76
|
+
<% end %>
|
77
|
+
<% c_func(:nodef)%>
|
71
78
|
|
72
79
|
void
|
73
|
-
<%=
|
80
|
+
<%=type_name%>_qsort<%=suffix%>(void *a, size_t n, ssize_t es)
|
74
81
|
{
|
75
82
|
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
76
83
|
int d, r, presorted;
|
@@ -134,7 +141,7 @@ void
|
|
134
141
|
r = Min(pd - pc, pn - pd - es);
|
135
142
|
vecswap(qsort_dtype, pb, pn - r, r);
|
136
143
|
if ((r = pb - pa) > es)
|
137
|
-
<%=
|
144
|
+
<%=type_name%>_qsort<%=suffix%>(a, r / es, es);
|
138
145
|
if ((r = pd - pc) > es) {
|
139
146
|
a = pn - r;
|
140
147
|
n = r / es;
|
@@ -15,14 +15,14 @@ static void
|
|
15
15
|
for (; i--;) {
|
16
16
|
GET_DATA_INDEX(p1,idx1,dtype,x);
|
17
17
|
GET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
|
18
|
-
x = m_<%=
|
18
|
+
x = m_<%=name%>(x,y);
|
19
19
|
SET_DATA_INDEX(p1,idx1,dtype,x);
|
20
20
|
}
|
21
21
|
} else {
|
22
22
|
for (; i--;) {
|
23
23
|
GET_DATA_INDEX(p1,idx1,dtype,x);
|
24
24
|
GET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
|
25
|
-
x = m_<%=
|
25
|
+
x = m_<%=name%>(x,y);
|
26
26
|
SET_DATA_INDEX(p1,idx1,dtype,x);
|
27
27
|
}
|
28
28
|
}
|
@@ -31,14 +31,14 @@ static void
|
|
31
31
|
for (; i--;) {
|
32
32
|
GET_DATA(p1,dtype,x);
|
33
33
|
GET_DATA_INDEX(p2,idx2,<%=dtype%>,y);
|
34
|
-
x = m_<%=
|
34
|
+
x = m_<%=name%>(x,y);
|
35
35
|
SET_DATA_STRIDE(p1,s1,dtype,x);
|
36
36
|
}
|
37
37
|
} else {
|
38
38
|
for (; i--;) {
|
39
39
|
GET_DATA(p1,dtype,x);
|
40
40
|
GET_DATA_STRIDE(p2,s2,<%=dtype%>,y);
|
41
|
-
x = m_<%=
|
41
|
+
x = m_<%=name%>(x,y);
|
42
42
|
SET_DATA_STRIDE(p1,s1,dtype,x);
|
43
43
|
}
|
44
44
|
}
|
@@ -46,7 +46,7 @@ static void
|
|
46
46
|
}
|
47
47
|
|
48
48
|
static VALUE
|
49
|
-
<%=c_func%>(VALUE self, VALUE a1)
|
49
|
+
<%=c_func(1)%>(VALUE self, VALUE a1)
|
50
50
|
{
|
51
51
|
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{<%=tpclass%>,0}};
|
52
52
|
ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP, 2, 0, ain, 0 };
|