diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-23 02:09:03 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-23 02:09:03 +0000 |
commit | d07ce082a683fbcf55bbbefc342ceaf064a12bde (patch) | |
tree | 570c5161a20c4adadf0d6039bf1af73ae58e6855 /test/matrix/test_matrix.rb | |
parent | 0b7d473734d0dec8520afe7a36540aa1f40d2532 (diff) | |
download | ruby-d07ce082a683fbcf55bbbefc342ceaf064a12bde.tar.gz |
* lib/matrix/eigenvalue_decomposition.rb (tridiagonalize): fix
indentation to avoid a warning when the command line option -w of
ruby is specified.
* lib/matrix/eigenvalue_decomposition.rb (hessenberg_to_real_schur):
change the name of a block parameter to avoid a warning when the
command line option -w of ruby is specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/matrix/test_matrix.rb')
-rw-r--r-- | test/matrix/test_matrix.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index e2530f7366..a578aeb1c8 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -582,4 +582,30 @@ class TestMatrix < Test::Unit::TestCase assert_equal @e2, @e2.vstack(@e2) assert_equal SubMatrix, SubMatrix.vstack(@e1).class end + + def test_eigenvalues_and_eigenvectors_symmetric + m = Matrix[ + [8, 1], + [1, 8] + ] + values = m.eigensystem.eigenvalues + assert_in_epsilon(7.0, values[0]) + assert_in_epsilon(9.0, values[1]) + vectors = m.eigensystem.eigenvectors + assert_in_epsilon(-vectors[0][0], vectors[0][1]) + assert_in_epsilon(vectors[1][0], vectors[1][1]) + end + + def test_eigenvalues_and_eigenvectors_nonsymmetric + m = Matrix[ + [8, 1], + [4, 5] + ] + values = m.eigensystem.eigenvalues + assert_in_epsilon(9.0, values[0]) + assert_in_epsilon(4.0, values[1]) + vectors = m.eigensystem.eigenvectors + assert_in_epsilon(vectors[0][0], vectors[0][1]) + assert_in_epsilon(-4 * vectors[1][0], vectors[1][1]) + end end |