mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
fix bug #410: fix a possible out of range access in EigenSolver
This commit is contained in:
parent
362fcabc44
commit
a108216af1
@ -339,7 +339,7 @@ typename EigenSolver<MatrixType>::EigenvectorsType EigenSolver<MatrixType>::eige
|
|||||||
EigenvectorsType matV(n,n);
|
EigenvectorsType matV(n,n);
|
||||||
for (Index j=0; j<n; ++j)
|
for (Index j=0; j<n; ++j)
|
||||||
{
|
{
|
||||||
if (internal::isMuchSmallerThan(internal::imag(m_eivalues.coeff(j)), internal::real(m_eivalues.coeff(j))))
|
if (internal::isMuchSmallerThan(internal::imag(m_eivalues.coeff(j)), internal::real(m_eivalues.coeff(j))) || j+1==n)
|
||||||
{
|
{
|
||||||
// we have a real eigen value
|
// we have a real eigen value
|
||||||
matV.col(j) = m_eivec.col(j).template cast<ComplexScalar>();
|
matV.col(j) = m_eivec.col(j).template cast<ComplexScalar>();
|
||||||
|
@ -114,6 +114,17 @@ void test_eigensolver_generic()
|
|||||||
|
|
||||||
// Test problem size constructors
|
// Test problem size constructors
|
||||||
CALL_SUBTEST_5(EigenSolver<MatrixXf>(s));
|
CALL_SUBTEST_5(EigenSolver<MatrixXf>(s));
|
||||||
|
|
||||||
|
// regression test for bug 410
|
||||||
|
CALL_SUBTEST_2(
|
||||||
|
{
|
||||||
|
MatrixXd A(1,1);
|
||||||
|
A(0,0) = std::sqrt(-1.);
|
||||||
|
Eigen::EigenSolver<MatrixXd> solver(A);
|
||||||
|
MatrixXd V(1, 1);
|
||||||
|
V(0,0) = solver.eigenvectors()(0,0).real();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
EIGEN_UNUSED_VARIABLE(s)
|
EIGEN_UNUSED_VARIABLE(s)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user