diff options
author | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2010-04-02 14:32:20 +0100 |
---|---|---|
committer | Jitse Niesen <jitse@maths.leeds.ac.uk> | 2010-04-02 14:32:20 +0100 |
commit | a16a36ecf2596fadffd6474d059c334baa905c06 (patch) | |
tree | 5fa0008c7cb51a991dd79c4b9465ebe645da8a94 /test/hessenberg.cpp | |
parent | 3a14a135331519f85b6490e803403d054598329e (diff) |
Add tests for real and complex Schur; extend test for Hessenberg.
Make a minor correction to the ComplexSchur class.
Diffstat (limited to 'test/hessenberg.cpp')
-rw-r--r-- | test/hessenberg.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/test/hessenberg.cpp b/test/hessenberg.cpp index d917be357..cba9c8fda 100644 --- a/test/hessenberg.cpp +++ b/test/hessenberg.cpp @@ -2,6 +2,7 @@ // for linear algebra. // // Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr> +// Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk> // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -28,19 +29,36 @@ template<typename Scalar,int Size> void hessenberg(int size = Size) { typedef Matrix<Scalar,Size,Size> MatrixType; - MatrixType m = MatrixType::Random(size,size); - HessenbergDecomposition<MatrixType> hess(m); - VERIFY_IS_APPROX(m, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint()); + // Test basic functionality: A = U H U* and H is Hessenberg + for(int counter = 0; counter < g_repeat; ++counter) { + MatrixType m = MatrixType::Random(size,size); + HessenbergDecomposition<MatrixType> hess(m); + VERIFY_IS_APPROX(m, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint()); + MatrixType H = hess.matrixH(); + for(int row = 2; row < size; ++row) { + for(int col = 0; col < row-1; ++col) { + VERIFY(H(row,col) == (typename MatrixType::Scalar)0); + } + } + } + + // Test whether compute() and constructor returns same result + MatrixType A = MatrixType::Random(size, size); + HessenbergDecomposition<MatrixType> cs1; + cs1.compute(A); + HessenbergDecomposition<MatrixType> cs2(A); + VERIFY_IS_EQUAL(cs1.matrixQ(), cs2.matrixQ()); + VERIFY_IS_EQUAL(cs1.matrixH(), cs2.matrixH()); + + // TODO: Add tests for packedMatrix() and householderCoefficients() } void test_hessenberg() { - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1(( hessenberg<std::complex<double>,1>() )); - CALL_SUBTEST_2(( hessenberg<std::complex<double>,2>() )); - CALL_SUBTEST_3(( hessenberg<std::complex<float>,4>() )); - CALL_SUBTEST_4(( hessenberg<float,Dynamic>(ei_random<int>(1,320)) )); - CALL_SUBTEST_5(( hessenberg<std::complex<double>,Dynamic>(ei_random<int>(1,320)) )); - } + CALL_SUBTEST_1(( hessenberg<std::complex<double>,1>() )); + CALL_SUBTEST_2(( hessenberg<std::complex<double>,2>() )); + CALL_SUBTEST_3(( hessenberg<std::complex<float>,4>() )); + CALL_SUBTEST_4(( hessenberg<float,Dynamic>(ei_random<int>(1,320)) )); + CALL_SUBTEST_5(( hessenberg<std::complex<double>,Dynamic>(ei_random<int>(1,320)) )); } |