bug #985: RealQZ failed when either matrix had zero rows or columns (report and patch by Ben Goodrich)

Also added a regression test
(transplanted from 1efae98fee
)
This commit is contained in:
Christoph Hertzberg 2015-03-30 23:56:20 +02:00
parent bf650a3686
commit 0fb74c1f8b
2 changed files with 22 additions and 6 deletions

View File

@ -240,10 +240,10 @@ namespace Eigen {
m_S.coeffRef(i,j) = Scalar(0.0);
m_S.rightCols(dim-j-1).applyOnTheLeft(i-1,i,G.adjoint());
m_T.rightCols(dim-i+1).applyOnTheLeft(i-1,i,G.adjoint());
// update Q
if (m_computeQZ)
m_Q.applyOnTheRight(i-1,i,G);
}
// update Q
if (m_computeQZ)
m_Q.applyOnTheRight(i-1,i,G);
// kill T(i,i-1)
if(m_T.coeff(i,i-1)!=Scalar(0))
{
@ -251,10 +251,10 @@ namespace Eigen {
m_T.coeffRef(i,i-1) = Scalar(0.0);
m_S.applyOnTheRight(i,i-1,G);
m_T.topRows(i).applyOnTheRight(i,i-1,G);
// update Z
if (m_computeQZ)
m_Z.applyOnTheLeft(i,i-1,G.adjoint());
}
// update Z
if (m_computeQZ)
m_Z.applyOnTheLeft(i,i-1,G.adjoint());
}
}
}

View File

@ -25,6 +25,22 @@ template<typename MatrixType> void real_qz(const MatrixType& m)
MatrixType A = MatrixType::Random(dim,dim),
B = MatrixType::Random(dim,dim);
// Regression test for bug 985: Randomly set rows or columns to zero
Index k=internal::random<int>(0, dim-1);
switch(internal::random<int>(0,10)) {
case 0:
A.row(k).setZero(); break;
case 1:
A.col(k).setZero(); break;
case 2:
B.row(k).setZero(); break;
case 3:
B.col(k).setZero(); break;
default:
break;
}
RealQZ<MatrixType> qz(A,B);
VERIFY_IS_EQUAL(qz.info(), Success);