diff options
| author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-16 21:25:53 +0000 |
|---|---|---|
| committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-16 21:25:53 +0000 |
| commit | 5a52a755c5ebffe8e6b4b7461a5d2d27c57c8dea (patch) | |
| tree | 046ee2624b60128ba6bb372f1be79aa81d25ea00 | |
| parent | 433cd0e0828b2aba1871ea7a67f99faedb82b6b1 (diff) | |
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | lib/matrix.rb | 4 |
2 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Thu Sep 17 06:25:32 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:19:27 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca> * lib/matrix.rb: Optimizations diff --git a/lib/matrix.rb b/lib/matrix.rb index a86440dbba..93ae3a9909 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -701,14 +701,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? |
