diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/matrix.rb | 8 |
2 files changed, 10 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Sat Jun 5 13:10:47 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca> + + * lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning + some empty matrices. + Sat Jun 5 11:00:48 2010 Tanaka Akira <akr@fsij.org> * error.c (rb_name_err_mesg_new): guard mesg, recv and method. diff --git a/lib/matrix.rb b/lib/matrix.rb index 79c4c7b1b3..8e6b08c3c6 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -442,7 +442,7 @@ class Matrix rows = @rows[from_row, size_row].collect{|row| row[from_col, size_col] } - new_matrix rows, column_size - from_col + new_matrix rows, [column_size - from_col, size_col].min end #-- @@ -493,12 +493,14 @@ class Matrix # Returns +true+ if and only if the two matrices contain equal elements. # def ==(other) - return false unless Matrix === other + return false unless Matrix === other && + column_size == other.column_size # necessary for empty matrices rows == other.rows end def eql?(other) - return false unless Matrix === other + return false unless Matrix === other && + column_size == other.column_size # necessary for empty matrices rows.eql? other.rows end |