diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-10 17:18:31 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-10 17:18:31 +0000 |
commit | c33d5a80c7ee0a4e42acb0dd54ac89d68c229a67 (patch) | |
tree | a6472ad7c77b9e5d03cb4ab0dc384f3dd24c60d7 /test/matrix | |
parent | 561fbde4351ed7fb4dc0193c2a9fe361053555f2 (diff) | |
download | bundler-c33d5a80c7ee0a4e42acb0dd54ac89d68c229a67.tar.gz |
* test/matrix/test_matrix.rb (TestMatrix#test_rank):
added a test method for r24969.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/matrix')
-rw-r--r-- | test/matrix/test_matrix.rb | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 0850117b86..8e0848de01 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -46,4 +46,102 @@ class TestMatrix < Test::Unit::TestCase assert_equal @m1.hash, @m2.hash assert_equal @m1.hash, @m3.hash end + + def test_rank + [ + [[0]], + [[0], [0]], + [[0, 0], [0, 0]], + [[0, 0], [0, 0], [0, 0]], + [[0, 0, 0]], + [[0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + ].each do |rows| + assert_equal 0, Matrix[*rows].rank + end + + [ + [[1], [0]], + [[1, 0], [0, 0]], + [[1, 0], [1, 0]], + [[0, 0], [1, 0]], + [[1, 0], [0, 0], [0, 0]], + [[0, 0], [1, 0], [0, 0]], + [[0, 0], [0, 0], [1, 0]], + [[1, 0], [1, 0], [0, 0]], + [[0, 0], [1, 0], [1, 0]], + [[1, 0], [1, 0], [1, 0]], + [[1, 0, 0]], + [[1, 0, 0], [0, 0, 0]], + [[0, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0]], + [[1, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [1, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0], [0, 0, 0]], + [[0, 0, 0], [1, 0, 0], [1, 0, 0]], + [[1, 0, 0], [0, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0], [1, 0, 0]], + [[1, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[1, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[1, 0, 0], [1, 0, 0], [0, 0, 0], [0, 0, 0]], + [[1, 0, 0], [0, 0, 0], [1, 0, 0], [0, 0, 0]], + [[1, 0, 0], [0, 0, 0], [0, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0], [1, 0, 0], [0, 0, 0]], + [[1, 0, 0], [0, 0, 0], [1, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0], [0, 0, 0], [1, 0, 0]], + [[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]], + + [[1]], + [[1], [1]], + [[1, 1]], + [[1, 1], [1, 1]], + [[1, 1], [1, 1], [1, 1]], + [[1, 1, 1]], + [[1, 1, 1], [1, 1, 1]], + [[1, 1, 1], [1, 1, 1], [1, 1, 1]], + [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]], + ].each do |rows| + matrix = Matrix[*rows] + assert_equal 1, matrix.rank + assert_equal 1, matrix.transpose.rank + end + + [ + [[1, 0], [0, 1]], + [[1, 0], [0, 1], [0, 0]], + [[1, 0], [0, 1], [0, 1]], + [[1, 0], [0, 1], [1, 1]], + [[1, 0, 0], [0, 1, 0]], + [[1, 0, 0], [0, 0, 1]], + [[1, 0, 0], [0, 1, 0], [0, 0, 0]], + [[1, 0, 0], [0, 0, 1], [0, 0, 0]], + + [[1, 0, 0], [0, 0, 0], [0, 1, 0]], + [[1, 0, 0], [0, 0, 0], [0, 0, 1]], + + [[1, 0], [1, 1]], + [[1, 2], [1, 1]], + [[1, 2], [0, 1], [1, 1]], + ].each do |rows| + m = Matrix[*rows] + assert_equal 2, m.rank + assert_equal 2, m.transpose.rank + end + + [ + [[1, 0, 0], [0, 1, 0], [0, 0, 1]], + [[1, 1, 0], [0, 1, 1], [1, 0, 1]], + [[1, 1, 0], [0, 1, 1], [1, 0, 1]], + [[1, 1, 0], [0, 1, 1], [1, 0, 1], [0, 0, 0]], + [[1, 1, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]], + [[1, 1, 1], [1, 1, 2], [1, 3, 1], [4, 1, 1]], + ].each do |rows| + m = Matrix[*rows] + assert_equal 3, m.rank + assert_equal 3, m.transpose.rank + end + end end |