summaryrefslogtreecommitdiff
path: root/lib/matrix.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-30 06:04:04 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-30 06:04:04 +0000
commitb906a46edd76e873cec0714eb1e96d68caec363c (patch)
tree3a9656b7466ec0f9af3474878679a293f5ebe50a /lib/matrix.rb
parentf965d513846cdd9775d022f1463d5097e10a9620 (diff)
* lib/matrix.rb (symmetric?): Trivial optimization
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/matrix.rb')
-rw-r--r--lib/matrix.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 7a20fae..7569d68 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -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
#