numo-narray 0.9.1.2 → 0.9.1.3

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -1
  3. data/ext/numo/narray/array.c +6 -6
  4. data/ext/numo/narray/data.c +8 -8
  5. data/ext/numo/narray/depend.erb +4 -4
  6. data/ext/numo/narray/extconf.rb +2 -2
  7. data/ext/numo/narray/gen/cogen.rb +13 -0
  8. data/ext/numo/narray/gen/def/dfloat.rb +1 -0
  9. data/ext/numo/narray/gen/def/sfloat.rb +1 -0
  10. data/ext/numo/narray/gen/narray_def.rb +14 -2
  11. data/ext/numo/narray/gen/spec.rb +26 -10
  12. data/ext/numo/narray/gen/tmpl/accum_binary.c +1 -1
  13. data/ext/numo/narray/gen/tmpl/accum_index.c +11 -1
  14. data/ext/numo/narray/gen/tmpl/alloc_func.c +3 -3
  15. data/ext/numo/narray/gen/tmpl/binary.c +149 -10
  16. data/ext/numo/narray/gen/tmpl/binary2.c +1 -1
  17. data/ext/numo/narray/gen/tmpl/bincount.c +1 -1
  18. data/ext/numo/narray/gen/tmpl/cast.c +1 -1
  19. data/ext/numo/narray/gen/tmpl/cond_binary.c +1 -1
  20. data/ext/numo/narray/gen/tmpl/each.c +1 -1
  21. data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
  22. data/ext/numo/narray/gen/tmpl/extract_data.c +3 -3
  23. data/ext/numo/narray/gen/tmpl/inspect.c +1 -1
  24. data/ext/numo/narray/gen/tmpl/lib.c +5 -0
  25. data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
  26. data/ext/numo/narray/gen/tmpl/median.c +3 -2
  27. data/ext/numo/narray/gen/tmpl/pow.c +1 -1
  28. data/ext/numo/narray/gen/tmpl/qsort.c +118 -56
  29. data/ext/numo/narray/gen/tmpl/store.c +4 -4
  30. data/ext/numo/narray/gen/tmpl/store_bit.c +4 -4
  31. data/ext/numo/narray/gen/tmpl/to_a.c +1 -1
  32. data/ext/numo/narray/gen/tmpl/unary_s.c +55 -9
  33. data/ext/numo/narray/gen/tmpl_bit/each.c +1 -1
  34. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +1 -1
  35. data/ext/numo/narray/gen/tmpl_bit/inspect.c +1 -1
  36. data/ext/numo/narray/gen/tmpl_bit/mask.c +1 -1
  37. data/ext/numo/narray/gen/tmpl_bit/to_a.c +1 -1
  38. data/ext/numo/narray/index.c +64 -37
  39. data/ext/numo/narray/math.c +4 -4
  40. data/ext/numo/narray/narray.c +54 -29
  41. data/ext/numo/narray/ndloop.c +7 -7
  42. data/ext/numo/narray/numo/narray.h +9 -2
  43. data/ext/numo/narray/numo/template.h +18 -0
  44. data/ext/numo/narray/numo/types/bit.h +5 -0
  45. data/ext/numo/narray/numo/types/complex_macro.h +5 -0
  46. data/ext/numo/narray/numo/types/float_macro.h +5 -0
  47. data/ext/numo/narray/numo/types/int_macro.h +24 -0
  48. data/ext/numo/narray/numo/types/robj_macro.h +5 -0
  49. data/ext/numo/narray/numo/types/uint_macro.h +24 -0
  50. data/ext/numo/narray/numo/types/xint_macro.h +5 -25
  51. data/ext/numo/narray/rand.c +2 -29
  52. data/ext/numo/narray/step.c +1 -28
  53. data/ext/numo/narray/struct.c +26 -22
  54. data/lib/numo/narray/extra.rb +50 -1
  55. metadata +2 -2
@@ -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=0)
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.2
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-03-25 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler