mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-19 16:19:37 +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);
|
||||
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
|
||||
matV.col(j) = m_eivec.col(j).template cast<ComplexScalar>();
|
||||
|
@ -114,6 +114,17 @@ void test_eigensolver_generic()
|
||||
|
||||
// Test problem size constructors
|
||||
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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user