numo-narray 0.9.1.4 → 0.9.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -6
- data/Rakefile +4 -63
- data/ext/numo/narray/array.c +35 -32
- data/ext/numo/narray/data.c +40 -43
- data/ext/numo/narray/depend.erb +6 -10
- data/ext/numo/narray/extconf.rb +24 -21
- data/ext/numo/narray/gen/cogen.rb +2 -2
- data/ext/numo/narray/gen/narray_def.rb +5 -1
- data/ext/numo/narray/gen/spec.rb +17 -7
- 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/alloc_func.c +4 -1
- data/ext/numo/narray/gen/tmpl/allocate.c +1 -0
- 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/cast.c +7 -0
- 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/allocate.c +1 -0
- 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 +48 -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 +27 -9
- data/ext/numo/narray/gen/tmpl_bit/unary.c +25 -7
- data/ext/numo/narray/index.c +363 -59
- data/ext/numo/narray/math.c +2 -2
- data/ext/numo/narray/narray.c +151 -36
- data/ext/numo/narray/ndloop.c +4 -4
- data/ext/numo/narray/numo/intern.h +3 -2
- data/ext/numo/narray/numo/narray.h +37 -14
- data/ext/numo/narray/numo/ndloop.h +2 -2
- data/ext/numo/narray/numo/template.h +11 -15
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/numo/types/int16.h +5 -2
- data/ext/numo/narray/numo/types/int32.h +0 -1
- data/ext/numo/narray/numo/types/int64.h +0 -1
- data/ext/numo/narray/numo/types/int8.h +1 -2
- data/ext/numo/narray/numo/types/uint16.h +5 -2
- data/ext/numo/narray/numo/types/uint32.h +0 -1
- data/ext/numo/narray/numo/types/uint64.h +0 -1
- data/ext/numo/narray/numo/types/uint8.h +1 -2
- data/ext/numo/narray/numo/types/xint_macro.h +2 -0
- data/ext/numo/narray/step.c +58 -252
- data/ext/numo/narray/struct.c +3 -3
- data/lib/numo/narray.rb +1 -7
- data/lib/numo/narray/extra.rb +214 -213
- data/numo-narray.gemspec +7 -8
- metadata +17 -36
data/ext/numo/narray/depend.erb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
TAGSRC = \
|
2
|
-
|
3
|
-
|
4
|
-
*.h \
|
5
|
-
types/*.h \
|
6
|
-
*.c \
|
7
|
-
types/*.c
|
2
|
+
numo/types/*.h \
|
3
|
+
*.c
|
8
4
|
|
9
5
|
tags : TAGS
|
10
6
|
TAGS : $(TAGSRC)
|
11
7
|
etags $(TAGSRC)
|
12
8
|
|
13
9
|
doc :
|
14
|
-
yard doc *.c
|
10
|
+
yard doc *.c
|
15
11
|
|
16
12
|
C_TMPL = <%=Dir.glob("#{__dir__}/gen/tmpl*/*.c").join(" ")%>
|
17
13
|
|
@@ -22,13 +18,13 @@ DEPENDS = $(C_TMPL) <%= __dir__ %>/gen/*.rb
|
|
22
18
|
type_c = []
|
23
19
|
type_rb = Dir.glob("#{__dir__}/gen/def/*.rb")
|
24
20
|
type_rb.each do |s|
|
25
|
-
type_c << c = "
|
21
|
+
type_c << c = "t_"+File.basename(s,".rb")+".c"
|
26
22
|
%>
|
27
23
|
<%=c%>: <%=s%> $(DEPENDS)
|
28
|
-
$(MAKEDIRS) $(@D) types
|
29
24
|
ruby $(COGEN) -l -o $@ <%=s%>
|
30
25
|
<% end %>
|
31
26
|
|
32
27
|
src : <%= type_c.join(" ") %>
|
33
28
|
|
34
|
-
CLEANOBJS = *.o
|
29
|
+
CLEANOBJS = *.o t_*.c *.bak
|
30
|
+
DISTCLEANFILES = depend TAGS
|
data/ext/numo/narray/extconf.rb
CHANGED
@@ -7,7 +7,11 @@ if RUBY_VERSION < "2.1.0"
|
|
7
7
|
exit(1)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
def d(file)
|
11
|
+
File.join(__dir__,file)
|
12
|
+
end
|
13
|
+
|
14
|
+
rm_f d('numo/extconf.h')
|
11
15
|
|
12
16
|
#$CFLAGS="-g3 -O0 -Wall"
|
13
17
|
#$CFLAGS=" $(cflags) -O3 -m64 -msse2 -funroll-loops"
|
@@ -28,20 +32,20 @@ step
|
|
28
32
|
index
|
29
33
|
ndloop
|
30
34
|
data
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
t_bit
|
36
|
+
t_int8
|
37
|
+
t_int16
|
38
|
+
t_int32
|
39
|
+
t_int64
|
40
|
+
t_uint8
|
41
|
+
t_uint16
|
42
|
+
t_uint32
|
43
|
+
t_uint64
|
44
|
+
t_sfloat
|
45
|
+
t_dfloat
|
46
|
+
t_scomplex
|
47
|
+
t_dcomplex
|
48
|
+
t_robject
|
45
49
|
math
|
46
50
|
SFMT
|
47
51
|
struct
|
@@ -83,19 +87,18 @@ unless have_type("u_int64_t", stdint)
|
|
83
87
|
have_type("uint64_t", stdint)
|
84
88
|
end
|
85
89
|
have_func("exp10")
|
90
|
+
have_func("rb_arithmetic_sequence_extract")
|
86
91
|
|
87
92
|
have_var("rb_cComplex")
|
88
93
|
|
89
94
|
$objs = srcs.collect{|i| i+".o"}
|
90
95
|
|
91
|
-
create_header('numo/extconf.h')
|
96
|
+
create_header d('numo/extconf.h')
|
92
97
|
|
93
|
-
|
94
|
-
File.open(
|
95
|
-
depend_erb_path = File.join(__dir__, "depend.erb")
|
96
|
-
File.open(depend_erb_path, "r") do |depend_erb|
|
98
|
+
File.open(d('depend'), "w") do |depend|
|
99
|
+
File.open(d('depend.erb'), "r") do |depend_erb|
|
97
100
|
erb = ERB.new(depend_erb.read)
|
98
|
-
erb.filename =
|
101
|
+
erb.filename = d('depend.erb')
|
99
102
|
depend.print(erb.result)
|
100
103
|
end
|
101
104
|
end
|
@@ -50,7 +50,7 @@ code = DefLib.new do
|
|
50
50
|
set file_name: $output||""
|
51
51
|
set include_files: ["numo/types/#{type_name}.h"]
|
52
52
|
set lib_name: "numo_"+type_name
|
53
|
-
|
53
|
+
|
54
54
|
if (::RbConfig::CONFIG['target_cpu'] == 'x86_64') or (::RbConfig::CONFIG['target_cpu'] == 'x64')
|
55
55
|
set is_simd: true
|
56
56
|
else
|
@@ -66,7 +66,7 @@ code = DefLib.new do
|
|
66
66
|
end.result
|
67
67
|
|
68
68
|
if $output
|
69
|
-
|
69
|
+
File.write($output, code)
|
70
70
|
else
|
71
71
|
$stdout.write(code)
|
72
72
|
end
|
@@ -27,7 +27,7 @@ module NArrayMethod
|
|
27
27
|
|
28
28
|
def set2(meth, dtype, result_class)
|
29
29
|
h = {dtype:dtype, result_class:result_class}
|
30
|
-
def_method(meth, "set2", h)
|
30
|
+
def_method(meth, "set2", **h)
|
31
31
|
end
|
32
32
|
|
33
33
|
def cond_binary(meth,op=nil)
|
@@ -57,6 +57,10 @@ module NArrayMethod
|
|
57
57
|
def_method(meth, "accum_index")
|
58
58
|
end
|
59
59
|
|
60
|
+
def accum_arg(meth)
|
61
|
+
def_method(meth, "accum_arg")
|
62
|
+
end
|
63
|
+
|
60
64
|
def cum(meth, cmacro)
|
61
65
|
def_method(meth, "cum", cmacro:cmacro)
|
62
66
|
end
|
data/ext/numo/narray/gen/spec.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
def_id "cast"
|
2
|
-
def_id "eq"
|
3
|
-
def_id "ne"
|
4
|
-
def_id "pow"
|
5
2
|
def_id "mulsum"
|
3
|
+
def_id "to_a"
|
6
4
|
if is_complex
|
7
5
|
def_id "real"
|
8
6
|
def_id "imag"
|
@@ -32,7 +30,6 @@ if is_object
|
|
32
30
|
def_id "bit_xor"
|
33
31
|
def_id "bit_not"
|
34
32
|
def_id "abs"
|
35
|
-
def_id "minus"
|
36
33
|
def_id "reciprocal"
|
37
34
|
def_id "square"
|
38
35
|
def_id "floor"
|
@@ -42,6 +39,7 @@ if is_object
|
|
42
39
|
def_id "nan?"
|
43
40
|
def_id "infinite?"
|
44
41
|
def_id "finite?"
|
42
|
+
def_id "-@","minus"
|
45
43
|
def_id "==","eq"
|
46
44
|
def_id "!=","ne"
|
47
45
|
def_id ">" ,"gt"
|
@@ -49,6 +47,9 @@ if is_object
|
|
49
47
|
def_id "<" ,"lt"
|
50
48
|
def_id "<=","le"
|
51
49
|
def_id "<=>","ufo"
|
50
|
+
else
|
51
|
+
def_id "eq"
|
52
|
+
def_id "ne"
|
52
53
|
end
|
53
54
|
|
54
55
|
if is_int && !is_object
|
@@ -179,7 +180,12 @@ if !is_complex
|
|
179
180
|
binary2 "divmod"
|
180
181
|
end
|
181
182
|
|
182
|
-
|
183
|
+
|
184
|
+
if !is_bit
|
185
|
+
pow
|
186
|
+
def_id "**","pow"
|
187
|
+
def_alias "pow","**"
|
188
|
+
end
|
183
189
|
|
184
190
|
unary "minus", "-@"
|
185
191
|
unary "reciprocal"
|
@@ -273,7 +279,7 @@ if is_float
|
|
273
279
|
cond_unary "isfinite"
|
274
280
|
end
|
275
281
|
|
276
|
-
if is_int
|
282
|
+
if is_int && !is_object
|
277
283
|
if is_unsigned
|
278
284
|
accum "sum","u_int64_t","numo_cUInt64"
|
279
285
|
accum "prod","u_int64_t","numo_cUInt64"
|
@@ -303,6 +309,8 @@ if is_comparable
|
|
303
309
|
accum "ptp","dtype","cT"
|
304
310
|
accum_index "max_index"
|
305
311
|
accum_index "min_index"
|
312
|
+
accum_arg "argmax"
|
313
|
+
accum_arg "argmin"
|
306
314
|
def_method "minmax"
|
307
315
|
def_module_function "maximum", "ewcomp", n_arg:2
|
308
316
|
def_module_function "minimum", "ewcomp", n_arg:2
|
@@ -366,6 +374,7 @@ cn = get(:class_name)
|
|
366
374
|
nm = get(:name)
|
367
375
|
st = get(:simd_type)
|
368
376
|
dp = get(:is_double_precision)
|
377
|
+
algn = get(:need_align)
|
369
378
|
is_c = is_complex
|
370
379
|
|
371
380
|
def_module do
|
@@ -377,8 +386,9 @@ def_module do
|
|
377
386
|
set module_name: "Math"
|
378
387
|
set module_var: "mTM"
|
379
388
|
set simd_type: st
|
380
|
-
set is_double_precision: dp
|
389
|
+
set is_double_precision: dp
|
381
390
|
set is_complex: is_c
|
391
|
+
set need_align: algn
|
382
392
|
|
383
393
|
math "sqrt"
|
384
394
|
math "cbrt"
|
@@ -22,8 +22,8 @@ static void
|
|
22
22
|
<% else %>
|
23
23
|
@overload <%=name%>(axis:nil, keepdims:false)
|
24
24
|
<% end %>
|
25
|
-
@param [Numeric,Array,Range] axis
|
26
|
-
@param [TrueClass] keepdims
|
25
|
+
@param [Numeric,Array,Range] axis Performs <%=name%> along the axis.
|
26
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
27
27
|
@return [Numo::<%=class_name%>] returns result of <%=name%>.
|
28
28
|
*/
|
29
29
|
static VALUE
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<% (is_float ? ["","_nan"] : [""]).each do |j|
|
2
|
+
[64,32].each do |i| %>
|
3
|
+
#define idx_t int<%=i%>_t
|
4
|
+
static void
|
5
|
+
<%=c_iter%>_arg<%=i%><%=j%>(na_loop_t *const lp)
|
6
|
+
{
|
7
|
+
size_t n, idx;
|
8
|
+
char *d_ptr, *o_ptr;
|
9
|
+
ssize_t d_step;
|
10
|
+
|
11
|
+
INIT_COUNTER(lp, n);
|
12
|
+
INIT_PTR(lp, 0, d_ptr, d_step);
|
13
|
+
|
14
|
+
idx = f_<%=name[3..5]%>_index<%=j%>(n,d_ptr,d_step);
|
15
|
+
|
16
|
+
o_ptr = NDL_PTR(lp,1);
|
17
|
+
*(idx_t*)o_ptr = (idx_t)idx;
|
18
|
+
}
|
19
|
+
#undef idx_t
|
20
|
+
<% end;end %>
|
21
|
+
|
22
|
+
/*
|
23
|
+
Index of the <%=name[3..5]%>imum value.
|
24
|
+
<% if is_float %>
|
25
|
+
@overload <%=name%>(axis:nil, nan:false)
|
26
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
27
|
+
<% else %>
|
28
|
+
@overload <%=name%>(axis:nil)
|
29
|
+
<% end %>
|
30
|
+
@param [Numeric,Array,Range] axis Finds <%=name[3..5]%>imum values along the axis and returns **indices along the axis**.
|
31
|
+
@return [Integer,Numo::Int] returns the result indices.
|
32
|
+
@see #<%=name[3..5]%>_index
|
33
|
+
@see #<%=name[3..5]%>
|
34
|
+
|
35
|
+
@example
|
36
|
+
<% case name; when /min/ %>
|
37
|
+
a = Numo::NArray[3,4,1,2]
|
38
|
+
a.argmin #=> 2
|
39
|
+
|
40
|
+
b = Numo::NArray[[3,4,1],[2,0,5]]
|
41
|
+
b.argmin #=> 4
|
42
|
+
b.argmin(axis:1) #=> [2, 1]
|
43
|
+
b.argmin(axis:0) #=> [1, 1, 0]
|
44
|
+
b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
45
|
+
<% when /max/ %>
|
46
|
+
a = Numo::NArray[3,4,1,2]
|
47
|
+
a.argmax #=> 1
|
48
|
+
|
49
|
+
b = Numo::NArray[[3,4,1],[2,0,5]]
|
50
|
+
b.argmax #=> 5
|
51
|
+
b.argmax(axis:1) #=> [1, 2]
|
52
|
+
b.argmax(axis:0) #=> [0, 0, 1]
|
53
|
+
b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
54
|
+
<% end %>
|
55
|
+
*/
|
56
|
+
static VALUE
|
57
|
+
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
58
|
+
{
|
59
|
+
narray_t *na;
|
60
|
+
VALUE reduce;
|
61
|
+
ndfunc_arg_in_t ain[2] = {{Qnil,0},{sym_reduce,0}};
|
62
|
+
ndfunc_arg_out_t aout[1] = {{0,0,0}};
|
63
|
+
ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 2,1, ain,aout};
|
64
|
+
|
65
|
+
GetNArray(self,na);
|
66
|
+
if (na->ndim==0) {
|
67
|
+
return INT2FIX(0);
|
68
|
+
}
|
69
|
+
if (na->size > (~(u_int32_t)0)) {
|
70
|
+
aout[0].type = numo_cInt64;
|
71
|
+
ndf.func = <%=c_iter%>_arg64;
|
72
|
+
<% if is_float %>
|
73
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_arg64_nan);
|
74
|
+
<% else %>
|
75
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
76
|
+
<% end %>
|
77
|
+
} else {
|
78
|
+
aout[0].type = numo_cInt32;
|
79
|
+
ndf.func = <%=c_iter%>_arg32;
|
80
|
+
<% if is_float %>
|
81
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, <%=c_iter%>_arg32_nan);
|
82
|
+
<% else %>
|
83
|
+
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
84
|
+
<% end %>
|
85
|
+
}
|
86
|
+
|
87
|
+
return na_ndloop(&ndf, 2, self, reduce);
|
88
|
+
}
|
@@ -70,7 +70,7 @@ static VALUE
|
|
70
70
|
@overload <%=op_map%>(other, axis:nil, keepdims:false)
|
71
71
|
<% end %>
|
72
72
|
@param [Numo::NArray,Numeric] other
|
73
|
-
@param [Numeric,Array,Range] axis
|
73
|
+
@param [Numeric,Array,Range] axis Performs <%=name%> along the axis.
|
74
74
|
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
75
75
|
<% if is_float %>
|
76
76
|
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
@@ -21,27 +21,38 @@ static void
|
|
21
21
|
<% end;end %>
|
22
22
|
|
23
23
|
/*
|
24
|
-
|
24
|
+
Index of the <%=name[0..2]%>imum value.
|
25
25
|
<% if is_float %>
|
26
26
|
@overload <%=name%>(axis:nil, nan:false)
|
27
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 %>
|
31
|
-
@param [Numeric,Array,Range] axis
|
32
|
-
@return [Integer,Numo::Int] returns result
|
31
|
+
@param [Numeric,Array,Range] axis Finds <%=name[0..2]%>imum values along the axis and returns **flat 1-d indices**.
|
32
|
+
@return [Integer,Numo::Int] returns result indices.
|
33
|
+
@see #arg<%=name[0..2]%>
|
34
|
+
@see #<%=name[0..2]%>
|
35
|
+
|
33
36
|
@example
|
34
|
-
|
35
|
-
Numo::NArray[3,4,1,2]
|
36
|
-
|
37
|
-
|
38
|
-
Numo::NArray[[3,4,1],[2,0,5]]
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
<% case name; when /min/ %>
|
38
|
+
a = Numo::NArray[3,4,1,2]
|
39
|
+
a.min_index #=> 2
|
40
|
+
|
41
|
+
b = Numo::NArray[[3,4,1],[2,0,5]]
|
42
|
+
b.min_index #=> 4
|
43
|
+
b.min_index(axis:1) #=> [2, 4]
|
44
|
+
b.min_index(axis:0) #=> [3, 4, 2]
|
45
|
+
b[b.min_index(axis:0)] #=> [2, 0, 1]
|
46
|
+
<% when /max/ %>
|
47
|
+
a = Numo::NArray[3,4,1,2]
|
48
|
+
a.max_index #=> 1
|
49
|
+
|
50
|
+
b = Numo::NArray[[3,4,1],[2,0,5]]
|
51
|
+
b.max_index #=> 5
|
52
|
+
b.max_index(axis:1) #=> [1, 5]
|
53
|
+
b.max_index(axis:0) #=> [0, 1, 5]
|
54
|
+
b[b.max_index(axis:0)] #=> [3, 4, 5]
|
55
|
+
<% end %>
|
45
56
|
*/
|
46
57
|
static VALUE
|
47
58
|
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
|
@@ -29,7 +29,9 @@ static void
|
|
29
29
|
assert(na->base.type == NARRAY_DATA_T);
|
30
30
|
|
31
31
|
if (na->ptr != NULL) {
|
32
|
-
|
32
|
+
if (na->owned) {
|
33
|
+
xfree(na->ptr);
|
34
|
+
}
|
33
35
|
na->ptr = NULL;
|
34
36
|
}
|
35
37
|
if (na->base.size > 0) {
|
@@ -103,5 +105,6 @@ static VALUE
|
|
103
105
|
na->base.shape = NULL;
|
104
106
|
na->base.reduce = INT2FIX(0);
|
105
107
|
na->ptr = NULL;
|
108
|
+
na->owned = FALSE;
|
106
109
|
return TypedData_Wrap_Struct(klass, &<%=type_name%>_data_type, (void*)na);
|
107
110
|
}
|
@@ -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)
|