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
@@ -1,7 +1,8 @@
|
|
1
|
-
<% [
|
1
|
+
<% (is_float ? ["","_nan"] : [""]).each do |j|
|
2
|
+
[64,32].each do |i| %>
|
2
3
|
#define idx_t int<%=i%>_t
|
3
4
|
static void
|
4
|
-
<%=c_iter%>_index<%=i%>(na_loop_t *const lp)
|
5
|
+
<%=c_iter%>_index<%=i%><%=j%>(na_loop_t *const lp)
|
5
6
|
{
|
6
7
|
size_t n, idx;
|
7
8
|
char *d_ptr, *i_ptr, *o_ptr;
|
@@ -10,49 +11,70 @@ static void
|
|
10
11
|
INIT_COUNTER(lp, n);
|
11
12
|
INIT_PTR(lp, 0, d_ptr, d_step);
|
12
13
|
|
13
|
-
idx = f_<%=
|
14
|
+
idx = f_<%=name%><%=j%>(n,d_ptr,d_step);
|
14
15
|
|
15
16
|
INIT_PTR(lp, 1, i_ptr, i_step);
|
16
17
|
o_ptr = NDL_PTR(lp,2);
|
17
18
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
18
19
|
}
|
19
20
|
#undef idx_t
|
20
|
-
<% end %>
|
21
|
+
<% end;end %>
|
21
22
|
|
22
23
|
/*
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
<%=name%>. Return an index of result.
|
25
|
+
<% if is_float %>
|
26
|
+
@overload <%=name%>(axis:nil, nan:false)
|
27
|
+
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
28
|
+
<% else %>
|
29
|
+
@overload <%=name%>(axis:nil)
|
30
|
+
<% end %>
|
31
|
+
@param [Numeric,Array,Range] axis Affected dimensions.
|
32
|
+
@return [Integer,Numo::Int] returns result index of <%=name%>.
|
33
|
+
@example
|
34
|
+
Numo::NArray[3,4,1,2].min_index => 3
|
30
35
|
*/
|
31
36
|
static VALUE
|
32
|
-
<%=c_func%>(int argc, VALUE *argv, VALUE self)
|
37
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
33
38
|
{
|
39
|
+
int ignore_nan = 0;
|
34
40
|
narray_t *na;
|
35
41
|
VALUE idx, reduce;
|
36
42
|
ndfunc_arg_in_t ain[3] = {{Qnil,0},{Qnil,0},{sym_reduce,0}};
|
37
43
|
ndfunc_arg_out_t aout[1] = {{0,0,0}};
|
38
44
|
ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 3,1, ain,aout};
|
39
45
|
|
46
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ignore_nan);
|
47
|
+
|
40
48
|
GetNArray(self,na);
|
41
49
|
if (na->ndim==0) {
|
42
50
|
return INT2FIX(0);
|
43
51
|
}
|
44
52
|
if (na->size > (~(u_int32_t)0)) {
|
45
53
|
aout[0].type = numo_cInt64;
|
46
|
-
idx =
|
54
|
+
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 %>
|
47
62
|
ndf.func = <%=c_iter%>_index64;
|
63
|
+
<% end %>
|
48
64
|
} else {
|
49
65
|
aout[0].type = numo_cInt32;
|
50
|
-
idx =
|
66
|
+
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 %>
|
51
74
|
ndf.func = <%=c_iter%>_index32;
|
75
|
+
<% end %>
|
52
76
|
}
|
53
77
|
rb_funcall(idx, rb_intern("seq"), 0);
|
54
78
|
|
55
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self);
|
56
|
-
|
57
79
|
return na_ndloop(&ndf, 3, self, idx, reduce);
|
58
80
|
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
static size_t
|
2
|
+
<%=type_name%>_memsize(const void* ptr)
|
3
|
+
{
|
4
|
+
size_t size = sizeof(narray_data_t);
|
5
|
+
const narray_data_t *na = (const narray_data_t*)ptr;
|
6
|
+
|
7
|
+
assert(na->base.type == NARRAY_DATA_T);
|
8
|
+
|
9
|
+
if (na->ptr != NULL) {
|
10
|
+
<% if is_bit %>
|
11
|
+
size += ((na->base.size-1)/8/sizeof(BIT_DIGIT)+1)*sizeof(BIT_DIGIT);
|
12
|
+
<% else %>
|
13
|
+
size += na->base.size * sizeof(dtype);
|
14
|
+
<% end %>
|
15
|
+
}
|
16
|
+
if (na->base.size > 0) {
|
17
|
+
if (na->base.shape != NULL && na->base.shape != &(na->base.size)) {
|
18
|
+
size += sizeof(size_t) * na->base.ndim;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return size;
|
22
|
+
}
|
23
|
+
|
24
|
+
static void
|
25
|
+
<%=type_name%>_free(void* ptr)
|
26
|
+
{
|
27
|
+
narray_data_t *na = (narray_data_t*)ptr;
|
28
|
+
|
29
|
+
assert(na->base.type == NARRAY_DATA_T);
|
30
|
+
|
31
|
+
if (na->ptr != NULL) {
|
32
|
+
xfree(na->ptr);
|
33
|
+
na->ptr = NULL;
|
34
|
+
}
|
35
|
+
if (na->base.size > 0) {
|
36
|
+
if (na->base.shape != NULL && na->base.shape != &(na->base.size)) {
|
37
|
+
xfree(na->base.shape);
|
38
|
+
na->base.shape = NULL;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
xfree(na);
|
42
|
+
}
|
43
|
+
|
44
|
+
static narray_type_info_t <%=type_name%>_info = {
|
45
|
+
<% if is_bit %>
|
46
|
+
1, // element_bits
|
47
|
+
0, // element_bytes
|
48
|
+
1, // element_stride (in bits)
|
49
|
+
<% else %>
|
50
|
+
0, // element_bits
|
51
|
+
sizeof(dtype), // element_bytes
|
52
|
+
sizeof(dtype), // element_stride (in bytes)
|
53
|
+
<% end %>
|
54
|
+
};
|
55
|
+
|
56
|
+
<% if is_object %>
|
57
|
+
static void
|
58
|
+
<%=type_name%>_gc_mark(void *ptr)
|
59
|
+
{
|
60
|
+
size_t n, i;
|
61
|
+
VALUE *a;
|
62
|
+
narray_data_t *na = ptr;
|
63
|
+
|
64
|
+
if (na->ptr) {
|
65
|
+
a = (VALUE*)(na->ptr);
|
66
|
+
n = na->base.size;
|
67
|
+
for (i=0; i<n; i++) {
|
68
|
+
rb_gc_mark(a[i]);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
const rb_data_type_t <%=type_name%>_data_type = {
|
74
|
+
"<%=full_class_name%>",
|
75
|
+
{<%=type_name%>_gc_mark, <%=type_name%>_free, <%=type_name%>_memsize,},
|
76
|
+
&na_data_type,
|
77
|
+
&<%=type_name%>_info,
|
78
|
+
0, // flags
|
79
|
+
};
|
80
|
+
|
81
|
+
<% else %>
|
82
|
+
|
83
|
+
const rb_data_type_t <%=type_name%>_data_type = {
|
84
|
+
"<%=full_class_name%>",
|
85
|
+
{0, <%=type_name%>_free, <%=type_name%>_memsize,},
|
86
|
+
&na_data_type,
|
87
|
+
&<%=type_name%>_info,
|
88
|
+
0, // flags
|
89
|
+
};
|
90
|
+
|
91
|
+
<% end %>
|
92
|
+
|
93
|
+
VALUE
|
94
|
+
<%=c_func(0)%>(VALUE klass)
|
95
|
+
{
|
96
|
+
narray_data_t *na = ALLOC(narray_data_t);
|
97
|
+
|
98
|
+
na->base.ndim = 0;
|
99
|
+
na->base.type = NARRAY_DATA_T;
|
100
|
+
na->base.flag[0] = NA_FL0_INIT;
|
101
|
+
na->base.flag[1] = NA_FL1_INIT;
|
102
|
+
na->base.size = 0;
|
103
|
+
na->base.shape = NULL;
|
104
|
+
na->base.reduce = INT2FIX(0);
|
105
|
+
na->ptr = NULL;
|
106
|
+
return TypedData_Wrap_Struct(klass, &<%=type_name%>_data_type, (void*)na);
|
107
|
+
}
|
@@ -38,12 +38,13 @@
|
|
38
38
|
|
39
39
|
*/
|
40
40
|
static VALUE
|
41
|
-
<%=c_func%>(int argc, VALUE *argv, VALUE self)
|
41
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
42
42
|
{
|
43
43
|
int nd;
|
44
44
|
size_t pos;
|
45
45
|
char *ptr;
|
46
46
|
VALUE a;
|
47
|
+
dtype x;
|
47
48
|
|
48
49
|
argc--;
|
49
50
|
if (argc==0) {
|
@@ -54,8 +55,9 @@ static VALUE
|
|
54
55
|
a = na_aref_main(argc, argv, self, 0, nd);
|
55
56
|
<%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
|
56
57
|
} else {
|
58
|
+
x = <%=type_name%>_extract_data(argv[argc]);
|
57
59
|
ptr = na_get_pointer_for_read_write(self) + pos;
|
58
|
-
*(dtype*)ptr =
|
60
|
+
*(dtype*)ptr = x;
|
59
61
|
}
|
60
62
|
|
61
63
|
}
|
@@ -12,13 +12,13 @@ static void
|
|
12
12
|
for (i=n; i--;) {
|
13
13
|
GET_DATA_STRIDE(p1,s1,dtype,x);
|
14
14
|
GET_DATA_STRIDE(p2,s2,dtype,y);
|
15
|
-
<% if is_int and %w[div mod divmod].include?
|
15
|
+
<% if is_int and %w[div mod divmod].include? name %>
|
16
16
|
if (y==0) {
|
17
17
|
lp->err_type = rb_eZeroDivError;
|
18
18
|
return;
|
19
19
|
}
|
20
20
|
<% end %>
|
21
|
-
x = m_<%=
|
21
|
+
x = m_<%=name%>(x,y);
|
22
22
|
SET_DATA_STRIDE(p3,s3,dtype,x);
|
23
23
|
}
|
24
24
|
}
|
@@ -34,13 +34,13 @@ static VALUE
|
|
34
34
|
}
|
35
35
|
|
36
36
|
/*
|
37
|
-
Binary <%=
|
37
|
+
Binary <%=name%>.
|
38
38
|
@overload <%=op_map%> other
|
39
39
|
@param [Numo::NArray,Numeric] other
|
40
40
|
@return [Numo::NArray] self <%=op_map%> other
|
41
41
|
*/
|
42
42
|
static VALUE
|
43
|
-
<%=c_func%>(VALUE self, VALUE other)
|
43
|
+
<%=c_func(1)%>(VALUE self, VALUE other)
|
44
44
|
{
|
45
45
|
<% if is_object %>
|
46
46
|
return <%=c_func%>_self(self, other);
|
@@ -13,13 +13,13 @@ static void
|
|
13
13
|
for (i=n; i--;) {
|
14
14
|
GET_DATA_STRIDE(p1,s1,dtype,x);
|
15
15
|
GET_DATA_STRIDE(p2,s2,dtype,y);
|
16
|
-
<% if is_int and %w[divmod].include?
|
16
|
+
<% if is_int and %w[divmod].include? name %>
|
17
17
|
if (y==0) {
|
18
18
|
lp->err_type = rb_eZeroDivError;
|
19
19
|
return;
|
20
20
|
}
|
21
21
|
<% end %>
|
22
|
-
m_<%=
|
22
|
+
m_<%=name%>(x,y,a,b);
|
23
23
|
SET_DATA_STRIDE(p3,s3,dtype,a);
|
24
24
|
SET_DATA_STRIDE(p4,s4,dtype,b);
|
25
25
|
}
|
@@ -36,13 +36,13 @@ static VALUE
|
|
36
36
|
}
|
37
37
|
|
38
38
|
/*
|
39
|
-
Binary <%=
|
39
|
+
Binary <%=name%>.
|
40
40
|
@overload <%=op_map%> other
|
41
41
|
@param [Numo::NArray,Numeric] other
|
42
|
-
@return [Numo::NArray] <%=
|
42
|
+
@return [Numo::NArray] <%=name%> of self and other.
|
43
43
|
*/
|
44
44
|
static VALUE
|
45
|
-
<%=c_func%>(VALUE self, VALUE other)
|
45
|
+
<%=c_func(1)%>(VALUE self, VALUE other)
|
46
46
|
{
|
47
47
|
<% if is_object %>
|
48
48
|
return <%=c_func%>_self(self, other);
|
@@ -12,20 +12,20 @@ static void
|
|
12
12
|
for (; i--;) {
|
13
13
|
GET_DATA_STRIDE(p1,s1,dtype,x);
|
14
14
|
GET_DATA_STRIDE(p2,s2,dtype,y);
|
15
|
-
x = m_<%=
|
15
|
+
x = m_<%=name%>(x,y);
|
16
16
|
SET_DATA_STRIDE(p3,s3,dtype,x);
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
20
20
|
/*
|
21
|
-
Calculate <%=
|
22
|
-
@overload <%=
|
21
|
+
Calculate <%=name%>(a1,a2).
|
22
|
+
@overload <%=name%>(a1,a2)
|
23
23
|
@param [Numo::NArray,Numeric] a1 first value
|
24
24
|
@param [Numo::NArray,Numeric] a2 second value
|
25
|
-
@return [Numo::<%=class_name%>] <%=
|
25
|
+
@return [Numo::<%=class_name%>] <%=name%>(a1,a2).
|
26
26
|
*/
|
27
27
|
static VALUE
|
28
|
-
<%=c_func%>(VALUE mod, VALUE a1, VALUE a2)
|
28
|
+
<%=c_func(2)%>(VALUE mod, VALUE a1, VALUE a2)
|
29
29
|
{
|
30
30
|
ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
|
31
31
|
ndfunc_arg_out_t aout[1] = {{cT,0}};
|
@@ -105,7 +105,7 @@ static VALUE
|
|
105
105
|
Count the number of occurrences of each non-negative integer value.
|
106
106
|
Only Integer-types has this method.
|
107
107
|
|
108
|
-
@overload <%=
|
108
|
+
@overload <%=name%>([weight], minlength:nil)
|
109
109
|
@param [SFloat or DFloat or Array] weight (optional) Array of
|
110
110
|
float values. Its size along last axis should be same as that of self.
|
111
111
|
@param [Integer] minlength (keyword, optional) Minimum size along
|
@@ -134,7 +134,7 @@ static VALUE
|
|
134
134
|
|
135
135
|
*/
|
136
136
|
static VALUE
|
137
|
-
<%=c_func%>(int argc, VALUE *argv, VALUE self)
|
137
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
138
138
|
{
|
139
139
|
VALUE weight=Qnil, kw=Qnil;
|
140
140
|
VALUE opts[1] = {Qundef};
|
@@ -146,9 +146,9 @@ static VALUE
|
|
146
146
|
rb_get_kwargs(kw, table, 0, 1, opts);
|
147
147
|
|
148
148
|
<% if is_unsigned %>
|
149
|
-
v =
|
149
|
+
v = <%=type_name%>_max(0,0,self);
|
150
150
|
<% else %>
|
151
|
-
v =
|
151
|
+
v = <%=type_name%>_minmax(0,0,self);
|
152
152
|
if (m_num_to_data(RARRAY_AREF(v,0)) < 0) {
|
153
153
|
rb_raise(rb_eArgError,"array items must be non-netagive");
|
154
154
|
}
|
@@ -1,13 +1,17 @@
|
|
1
|
+
<% children.each do |c|%>
|
2
|
+
<%= c.result %>
|
3
|
+
|
4
|
+
<% end %>
|
1
5
|
/*
|
2
6
|
Cast object to Numo::<%=class_name%>.
|
3
7
|
@overload [](elements)
|
4
|
-
@overload <%=
|
8
|
+
@overload <%=name%>(array)
|
5
9
|
@param [Numeric,Array] elements
|
6
10
|
@param [Array] array
|
7
11
|
@return [Numo::<%=class_name%>]
|
8
12
|
*/
|
9
13
|
static VALUE
|
10
|
-
<%=c_func%>(VALUE type, VALUE obj)
|
14
|
+
<%=c_func(1)%>(VALUE type, VALUE obj)
|
11
15
|
{
|
12
16
|
VALUE v;
|
13
17
|
narray_t *na;
|
@@ -18,22 +22,21 @@ static VALUE
|
|
18
22
|
}
|
19
23
|
if (RTEST(rb_obj_is_kind_of(obj,rb_cNumeric))) {
|
20
24
|
x = m_num_to_data(obj);
|
21
|
-
return
|
25
|
+
return <%=type_name%>_new_dim0(x);
|
22
26
|
}
|
23
27
|
if (RTEST(rb_obj_is_kind_of(obj,rb_cArray))) {
|
24
28
|
return <%=find_tmpl("cast_array").c_func%>(obj);
|
25
29
|
}
|
26
30
|
if (IsNArray(obj)) {
|
27
31
|
GetNArray(obj,na);
|
28
|
-
v =
|
32
|
+
v = nary_new(cT, NA_NDIM(na), NA_SHAPE(na));
|
29
33
|
if (NA_SIZE(na) > 0) {
|
30
|
-
<%=find_tmpl("allocate").c_func%>(v);
|
31
34
|
<%=find_tmpl("store").c_func%>(v,obj);
|
32
35
|
}
|
33
36
|
return v;
|
34
37
|
}
|
35
38
|
<% if is_object %>
|
36
|
-
return
|
39
|
+
return robject_new_dim0(obj);
|
37
40
|
<% else %>
|
38
41
|
rb_raise(nary_eCastError,"cannot cast to %s",rb_class2name(type));
|
39
42
|
return Qnil;
|
@@ -1,18 +1,13 @@
|
|
1
1
|
static VALUE
|
2
|
-
<%=c_func%>(VALUE rary)
|
2
|
+
<%=c_func(:nodef)%>(VALUE rary)
|
3
3
|
{
|
4
|
-
VALUE
|
4
|
+
VALUE nary;
|
5
5
|
narray_t *na;
|
6
|
-
na_compose_t *nc;
|
7
6
|
|
8
|
-
|
9
|
-
Data_Get_Struct(vnc, na_compose_t, nc);
|
10
|
-
nary = rb_narray_new(cT, nc->ndim, nc->shape);
|
11
|
-
RB_GC_GUARD(vnc);
|
7
|
+
nary = na_s_new_like(cT, rary);
|
12
8
|
GetNArray(nary,na);
|
13
9
|
if (na->size > 0) {
|
14
|
-
<%=find_tmpl("
|
15
|
-
<%=find_tmpl("store_array").c_func%>(nary,rary);
|
10
|
+
<%=find_tmpl("store").find("array").c_func%>(nary,rary);
|
16
11
|
}
|
17
12
|
return nary;
|
18
13
|
}
|