mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
* lib/matrix.rb (eql?, ==, minor): Fix bugs when comparing/returning some
empty matrices. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
906f8026d0
commit
be77d0276d
2 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue