mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb (Matrix#inverse_from): use #quo. backported r9490.
* lib/matrix.rb (Matrix#determinant): ditto. [ruby-core:27507] * lib/matrix.rb (Matrix#rank): ditto. * lib/matrix.rb (Matrix::Scalar#initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b4da253400
commit
655cb34f17
2 changed files with 10 additions and 1 deletions
|
@ -569,7 +569,7 @@ class Matrix
|
|||
|
||||
#
|
||||
# Returns the inverse of the matrix.
|
||||
# Matrix[[1, 2], [2, 1]].inverse
|
||||
# Matrix[[-1, -1], [0, -1]].inverse
|
||||
# => -1 1
|
||||
# 0 -1
|
||||
#
|
||||
|
|
|
@ -144,4 +144,13 @@ class TestMatrix < Test::Unit::TestCase
|
|||
assert_equal 3, m.transpose.rank
|
||||
end
|
||||
end
|
||||
|
||||
def test_inverse
|
||||
assert_equal(Matrix[[-1, 1], [0, -1]], Matrix[[-1, -1], [0, -1]].inverse)
|
||||
end
|
||||
|
||||
def test_determinant
|
||||
assert_equal(45, Matrix[[7,6], [3,9]].determinant)
|
||||
assert_equal(-18, Matrix[[2,0,1],[0,-2,2],[1,2,3]].determinant)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue