From f93654ae16b261e462ee00c5255072f8dd7d387b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 26 Oct 2015 16:00:25 +0100 Subject: [PATCH] bug #1098: fix regression introduced when generalizing some compute() methods in changeset 7031a851d45a8526474ac1ac972ad12a48e99f1a . --- Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h | 2 +- test/eigensolver_complex.cpp | 6 ++++++ test/eigensolver_generalized_real.cpp | 8 ++++++++ test/eigensolver_generic.cpp | 6 ++++++ test/eigensolver_selfadjoint.cpp | 6 ++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 4d62708ad..c64555096 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -411,7 +411,7 @@ SelfAdjointEigenSolver& SelfAdjointEigenSolver if(n==1) { - m_eivalues.coeffRef(0,0) = numext::real(matrix.coeff(0,0)); + m_eivalues.coeffRef(0,0) = numext::real(matrix(0,0)); if(computeEigenvectors) m_eivec.setOnes(n,n); m_info = Success; diff --git a/test/eigensolver_complex.cpp b/test/eigensolver_complex.cpp index 0d4e2dc87..ad982ed40 100644 --- a/test/eigensolver_complex.cpp +++ b/test/eigensolver_complex.cpp @@ -125,6 +125,12 @@ template void eigensolver(const MatrixType& m) ComplexEigenSolver eiNaN(a); VERIFY_IS_EQUAL(eiNaN.info(), NoConvergence); } + + // regression test for bug 1098 + { + ComplexEigenSolver eig(a.adjoint() * a); + eig.compute(a.adjoint() * a); + } } template void eigensolver_verify_assert(const MatrixType& m) diff --git a/test/eigensolver_generalized_real.cpp b/test/eigensolver_generalized_real.cpp index 566a4bdc6..a46a2e50e 100644 --- a/test/eigensolver_generalized_real.cpp +++ b/test/eigensolver_generalized_real.cpp @@ -39,6 +39,14 @@ template void generalized_eigensolver_real(const MatrixType VectorType realEigenvalues = eig.eigenvalues().real(); std::sort(realEigenvalues.data(), realEigenvalues.data()+realEigenvalues.size()); VERIFY_IS_APPROX(realEigenvalues, symmEig.eigenvalues()); + + // regression test for bug 1098 + { + GeneralizedSelfAdjointEigenSolver eig1(a.adjoint() * a,b.adjoint() * b); + eig1.compute(a.adjoint() * a,b.adjoint() * b); + GeneralizedEigenSolver eig2(a.adjoint() * a,b.adjoint() * b); + eig2.compute(a.adjoint() * a,b.adjoint() * b); + } } void test_eigensolver_generalized_real() diff --git a/test/eigensolver_generic.cpp b/test/eigensolver_generic.cpp index c5441ac4e..c42fcaeba 100644 --- a/test/eigensolver_generic.cpp +++ b/test/eigensolver_generic.cpp @@ -70,6 +70,12 @@ template void eigensolver(const MatrixType& m) EigenSolver eiNaN(a); VERIFY_IS_EQUAL(eiNaN.info(), NoConvergence); } + + // regression test for bug 1098 + { + EigenSolver eig(a.adjoint() * a); + eig.compute(a.adjoint() * a); + } } template void eigensolver_verify_assert(const MatrixType& m) diff --git a/test/eigensolver_selfadjoint.cpp b/test/eigensolver_selfadjoint.cpp index 4c3de7a80..a7b4deb5d 100644 --- a/test/eigensolver_selfadjoint.cpp +++ b/test/eigensolver_selfadjoint.cpp @@ -156,6 +156,12 @@ template void selfadjointeigensolver(const MatrixType& m) SelfAdjointEigenSolver eiSymmNaN(symmC); VERIFY_IS_EQUAL(eiSymmNaN.info(), NoConvergence); } + + // regression test for bug 1098 + { + SelfAdjointEigenSolver eig(a.adjoint() * a); + eig.compute(a.adjoint() * a); + } } void bug_854()