summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-16 21:04:07 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-16 21:04:07 +0000
commit6f715850bb25e1bab53c11881229d2fce0ce7435 (patch)
tree48e97c049ccbdc22b808ced6fd14796e262cfaf4
parent9357c458bea82880f7f896d7fef926d3908f0215 (diff)
downloadruby-6f715850bb25e1bab53c11881229d2fce0ce7435.tar.gz
ruby-6f715850bb25e1bab53c11881229d2fce0ce7435.tar.xz
ruby-6f715850bb25e1bab53c11881229d2fce0ce7435.zip
* lib/matrix.rb (Matrix#rank): Two bug fixes. One made Matrix[[0,0],[0,0],[1,0]].rank raise a NoMethodError while the other one had Matrix[[0,1],[0,0],[1,0]].rank raise a TypeError.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/matrix.rb4
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 853d9a5d7..ac9977478 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Sep 17 06:03:40 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+
+ * lib/matrix.rb (Matrix#rank): Two bug fixes. One made
+ Matrix[[0,0],[0,0],[1,0]].rank raise a NoMethodError while the other
+ one had Matrix[[0,1],[0,0],[1,0]].rank raise a TypeError.
+
Thu Sep 17 06:02:04 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix.rb: Optimizations
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 1ed4e16c4..c646fe174 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -751,14 +751,14 @@ class Matrix
rank = 0
a_column_size.times do |k|
if (akk = a[k][k]) == 0
- i = (k+1 ... a_column_size).find {|i|
+ i = (k+1 ... a_row_size).find {|i|
a[i][k] != 0
}
if i
a[i], a[k] = a[k], a[i]
akk = a[k][k]
else
- i = (k+1 ... a_row_size).find {|i|
+ i = (k+1 ... a_column_size).find {|i|
a[k][i] != 0
}
next if i.nil?