ruby-numo / numo-narray

Ruby/Numo::NArray - New NArray class library
http://ruby-numo.github.io/narray/
BSD 3-Clause "New" or "Revised" License
415 stars 41 forks source link

Sorting a 2D array. Strange behavior. #129

Closed kojix2 closed 4 years ago

kojix2 commented 5 years ago

I am trying to see how 2D array sorting works. And I find these strange behaviors.

require 'numo/narray'

a = Numo::DFloat.new(100).rand.sort_index
a = a.reshape 10, 10

p a.sort(1)
p a.sort(-2)

malloc(): memory corruption 中止 (コアダンプ)

require 'numo/narray'

a = Numo::DFloat[0,3,2,1]
a = a.reshape(2,2)

p a.sort(-2)

Numo::DFloat#shape=[2,2] [[0, 1], [2.37152e-322, 3]]

require 'numo/narray'

a = Numo::DFloat[0,3,2,1]
a = a.reshape(2,2)

p a.sort(0)

Numo::DFloat#shape=[2,2] [[0, 1], [4.65207e-310, 3]]

I'm sorry if this is a known issue and is currently under development. Thank you very much.

masa16 commented 4 years ago

fixed with https://github.com/ruby-numo/numo-narray/commit/8ac06ab98b6b74048b083d83d06c749228151bfe