I think I found some bugs in Matrix#rank >ruby -rmatrix -e'p Matrix[[7,0], [1,0], [2,0]].rank' .../matrix.rb:761:in `/': nil can't be coerced into Fixnum (TypeError) >ruby -rmatrix -e'p Matrix[[7,0], [1,0], [2,1]].rank' .../matrix.rb:761:in `/': nil can't be coerced into Fixnum (TypeError) Fix (?): change exists = true begin if (i += 1) > a_column_size - 1 # line 731 exists = false break end end while a[i][k] == 0 to exists = true begin if (i += 1) > a_row_size - 1 exists = false break end end while a[i][k] == 0 and exists = true begin if (i += 1) > a_row_size - 1 # line 743 exists = false break end end while a[k][i] == 0 to exists = true begin if (i += 1) > a_column_size - 1 exists = false break end end while a[k][i] == 0 The error seems to be caused by using loop indices up to row/column size for column/row indices, which causes some swaps with nil values. version: >ruby -v ruby 1.8.5 (2006-08-25) [i386-mingw32]
on 2007-02-02 22:06
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.