numo-narray 0.9.1.2 → 0.9.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -1
- data/ext/numo/narray/array.c +6 -6
- data/ext/numo/narray/data.c +8 -8
- data/ext/numo/narray/depend.erb +4 -4
- data/ext/numo/narray/extconf.rb +2 -2
- data/ext/numo/narray/gen/cogen.rb +13 -0
- data/ext/numo/narray/gen/def/dfloat.rb +1 -0
- data/ext/numo/narray/gen/def/sfloat.rb +1 -0
- data/ext/numo/narray/gen/narray_def.rb +14 -2
- data/ext/numo/narray/gen/spec.rb +26 -10
- data/ext/numo/narray/gen/tmpl/accum_binary.c +1 -1
- data/ext/numo/narray/gen/tmpl/accum_index.c +11 -1
- data/ext/numo/narray/gen/tmpl/alloc_func.c +3 -3
- data/ext/numo/narray/gen/tmpl/binary.c +149 -10
- data/ext/numo/narray/gen/tmpl/binary2.c +1 -1
- data/ext/numo/narray/gen/tmpl/bincount.c +1 -1
- data/ext/numo/narray/gen/tmpl/cast.c +1 -1
- data/ext/numo/narray/gen/tmpl/cond_binary.c +1 -1
- data/ext/numo/narray/gen/tmpl/each.c +1 -1
- data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/extract_data.c +3 -3
- data/ext/numo/narray/gen/tmpl/inspect.c +1 -1
- data/ext/numo/narray/gen/tmpl/lib.c +5 -0
- data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/median.c +3 -2
- data/ext/numo/narray/gen/tmpl/pow.c +1 -1
- data/ext/numo/narray/gen/tmpl/qsort.c +118 -56
- data/ext/numo/narray/gen/tmpl/store.c +4 -4
- data/ext/numo/narray/gen/tmpl/store_bit.c +4 -4
- data/ext/numo/narray/gen/tmpl/to_a.c +1 -1
- data/ext/numo/narray/gen/tmpl/unary_s.c +55 -9
- data/ext/numo/narray/gen/tmpl_bit/each.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/inspect.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/mask.c +1 -1
- data/ext/numo/narray/gen/tmpl_bit/to_a.c +1 -1
- data/ext/numo/narray/index.c +64 -37
- data/ext/numo/narray/math.c +4 -4
- data/ext/numo/narray/narray.c +54 -29
- data/ext/numo/narray/ndloop.c +7 -7
- data/ext/numo/narray/numo/narray.h +9 -2
- data/ext/numo/narray/numo/template.h +18 -0
- data/ext/numo/narray/numo/types/bit.h +5 -0
- data/ext/numo/narray/numo/types/complex_macro.h +5 -0
- data/ext/numo/narray/numo/types/float_macro.h +5 -0
- data/ext/numo/narray/numo/types/int_macro.h +24 -0
- data/ext/numo/narray/numo/types/robj_macro.h +5 -0
- data/ext/numo/narray/numo/types/uint_macro.h +24 -0
- data/ext/numo/narray/numo/types/xint_macro.h +5 -25
- data/ext/numo/narray/rand.c +2 -29
- data/ext/numo/narray/step.c +1 -28
- data/ext/numo/narray/struct.c +26 -22
- data/lib/numo/narray/extra.rb +50 -1
- metadata +2 -2
data/lib/numo/narray/extra.rb
CHANGED
@@ -208,6 +208,55 @@ module Numo
|
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
+
|
212
|
+
# Iterate over an axis
|
213
|
+
# @ example
|
214
|
+
# > a = Numo::DFloat.new(2,2,2).seq
|
215
|
+
# > p a
|
216
|
+
# Numo::DFloat#shape=[2,2,2]
|
217
|
+
# [[[0, 1],
|
218
|
+
# [2, 3]],
|
219
|
+
# [[4, 5],
|
220
|
+
# [6, 7]]]
|
221
|
+
#
|
222
|
+
# > a.each_over_axis{|i| p i}
|
223
|
+
# Numo::DFloat(view)#shape=[2,2]
|
224
|
+
# [[0, 1],
|
225
|
+
# [2, 3]]
|
226
|
+
# Numo::DFloat(view)#shape=[2,2]
|
227
|
+
# [[4, 5],
|
228
|
+
# [6, 7]]
|
229
|
+
#
|
230
|
+
# > a.each_over_axis(1){|i| p i}
|
231
|
+
# Numo::DFloat(view)#shape=[2,2]
|
232
|
+
# [[0, 1],
|
233
|
+
# [4, 5]]
|
234
|
+
# Numo::DFloat(view)#shape=[2,2]
|
235
|
+
# [[2, 3],
|
236
|
+
# [6, 7]]
|
237
|
+
|
238
|
+
def each_over_axis(axis=0)
|
239
|
+
unless block_given?
|
240
|
+
return to_enum(:each_over_axis,axis)
|
241
|
+
end
|
242
|
+
if ndim == 0
|
243
|
+
if axis != 0
|
244
|
+
raise ArgumentError,"axis=#{axis} is invalid"
|
245
|
+
end
|
246
|
+
niter = 1
|
247
|
+
else
|
248
|
+
axis = check_axis(axis)
|
249
|
+
niter = shape[axis]
|
250
|
+
end
|
251
|
+
idx = [true]*ndim
|
252
|
+
niter.times do |i|
|
253
|
+
idx[axis] = i
|
254
|
+
yield(self[*idx])
|
255
|
+
end
|
256
|
+
self
|
257
|
+
end
|
258
|
+
|
259
|
+
|
211
260
|
# Append values to the end of an narray.
|
212
261
|
# @example
|
213
262
|
# a = Numo::DFloat[1, 2, 3]
|
@@ -987,7 +1036,7 @@ module Numo
|
|
987
1036
|
raise NArray::ShapeError, "must be >= 2-dimensional array"
|
988
1037
|
end
|
989
1038
|
m,n = shape[-2..-1]
|
990
|
-
NArray.triu_indices(m,n,k
|
1039
|
+
NArray.triu_indices(m,n,k)
|
991
1040
|
end
|
992
1041
|
|
993
1042
|
# Return the indices for the uppler-triangle on and above the k-th diagonal.
|
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.1.
|
4
|
+
version: 0.9.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|