mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
561fbde435
commit
c33d5a80c7
2 changed files with 103 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Nov 11 02:14:48 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* test/matrix/test_matrix.rb (TestMatrix#test_rank):
|
||||
added a test method for r24969.
|
||||
|
||||
Tue Nov 10 08:23:21 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* process.c (rb_f_exec, rb_f_system, rb_f_spawn): mentioned abou
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue