mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb (symmetric?): Trivial optimization
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f965d51384
commit
b906a46edd
1 changed files with 3 additions and 2 deletions
|
@ -718,9 +718,10 @@ class Matrix
|
|||
#
|
||||
def symmetric?
|
||||
Matrix.Raise ErrDimensionMismatch unless square?
|
||||
each_with_index(:strict_upper).all? do |e, row, col|
|
||||
e == rows[col][row]
|
||||
each_with_index(:strict_upper) do |e, row, col|
|
||||
return false if e != rows[col][row]
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue