Fix real schur and polynomial solver.

For certain inputs, the real schur decomposition might get stuck in a cycle.
Exceptional shifts are supposed to knock us out of that - but previously
they were only ever applied at iteration 10 and 30, which doesn't help if
the cycle starts after cycle 30.  Modified to apply a shift every 16 iterations
(for reference, LAPACK seems to do it every 6 iterations).

Also added an assert in polynomial solver to verify that the schur decomposition
was successful.

Fixes #2633.
This commit is contained in:
Antonio Sanchez
2024-02-16 13:11:54 -08:00
parent 287c801780
commit 3ee06ec52f
3 changed files with 39 additions and 27 deletions

View File

@@ -98,6 +98,16 @@ template<typename MatrixType> void schur(int size = MatrixType::ColsAtCompileTim
}
}
void test_bug2633() {
Eigen::MatrixXd A(4, 4);
A << 0, 0, 0, -2,
1, 0, 0, -0,
0, 1, 0, 2,
0, 0, 2, -0;
RealSchur<Eigen::MatrixXd> schur(A);
VERIFY(schur.info() == Eigen::Success);
}
EIGEN_DECLARE_TEST(schur_real)
{
CALL_SUBTEST_1(( schur<Matrix4f>() ));
@@ -107,4 +117,6 @@ EIGEN_DECLARE_TEST(schur_real)
// Test problem size constructors
CALL_SUBTEST_5(RealSchur<MatrixXf>(10));
CALL_SUBTEST_6(( test_bug2633() ));
}