numo-narray 0.9.0.5 → 0.9.0.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/numo/narray/extra.rb
CHANGED
@@ -43,6 +43,56 @@ module Numo
|
|
43
43
|
reverse(0)
|
44
44
|
end
|
45
45
|
|
46
|
+
# Multi-dimensional array indexing.
|
47
|
+
# Same as [] for one-dimensional NArray.
|
48
|
+
# Similar to numpy's tuple indexing, i.e., a[[1,2,..],[3,4,..]]
|
49
|
+
# (This method will be rewritten in C)
|
50
|
+
# @return [Numo::NArray] one-dimensional view of self.
|
51
|
+
# @example
|
52
|
+
# p x = Numo::DFloat.new(3,3,3).seq
|
53
|
+
# # Numo::DFloat#shape=[3,3,3]
|
54
|
+
# # [[[0, 1, 2],
|
55
|
+
# # [3, 4, 5],
|
56
|
+
# # [6, 7, 8]],
|
57
|
+
# # [[9, 10, 11],
|
58
|
+
# # [12, 13, 14],
|
59
|
+
# # [15, 16, 17]],
|
60
|
+
# # [[18, 19, 20],
|
61
|
+
# # [21, 22, 23],
|
62
|
+
# # [24, 25, 26]]]
|
63
|
+
#
|
64
|
+
# p x.at([0,1,2],[0,1,2],[-1,-2,-3])
|
65
|
+
# # Numo::DFloat(view)#shape=[3]
|
66
|
+
# # [2, 13, 24]
|
67
|
+
def at(*indices)
|
68
|
+
if indices.size != ndim
|
69
|
+
raise DimensionError, "argument length does not match dimension size"
|
70
|
+
end
|
71
|
+
idx = nil
|
72
|
+
stride = 1
|
73
|
+
(indices.size-1).downto(0) do |i|
|
74
|
+
ix = Int64.cast(indices[i])
|
75
|
+
if ix.ndim != 1
|
76
|
+
raise DimensionError, "index array is not one-dimensional"
|
77
|
+
end
|
78
|
+
ix[ix < 0] += shape[i]
|
79
|
+
if ((ix < 0) & (ix >= shape[i])).any?
|
80
|
+
raise IndexError, "index array is out of range"
|
81
|
+
end
|
82
|
+
if idx
|
83
|
+
if idx.size != ix.size
|
84
|
+
raise ShapeError, "index array sizes mismatch"
|
85
|
+
end
|
86
|
+
idx += ix * stride
|
87
|
+
stride *= shape[i]
|
88
|
+
else
|
89
|
+
idx = ix
|
90
|
+
stride = shape[i]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
self[idx]
|
94
|
+
end
|
95
|
+
|
46
96
|
# Rotate in the plane specified by axes.
|
47
97
|
# @example
|
48
98
|
# p a = Numo::Int32.new(2,2).seq
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numo-narray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0.
|
4
|
+
version: 0.9.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- ext/numo/narray/numo/types/int64.h
|
226
226
|
- ext/numo/narray/numo/types/int8.h
|
227
227
|
- ext/numo/narray/numo/types/int_macro.h
|
228
|
+
- ext/numo/narray/numo/types/real_accum.h
|
228
229
|
- ext/numo/narray/numo/types/robj_macro.h
|
229
230
|
- ext/numo/narray/numo/types/robject.h
|
230
231
|
- ext/numo/narray/numo/types/scomplex.h
|
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
267
|
version: '0'
|
267
268
|
requirements: []
|
268
269
|
rubyforge_project:
|
269
|
-
rubygems_version: 2.6.
|
270
|
+
rubygems_version: 2.6.11
|
270
271
|
signing_key:
|
271
272
|
specification_version: 4
|
272
273
|
summary: alpha release of Numo::NArray - New NArray class library in Ruby/Numo (NUmerical
|