Fix bug #791: infinite loop in JacobiSVD in the presence of NaN.

(grafted from d6236d3b26
)
This commit is contained in:
Gael Guennebaud
2014-09-10 11:54:20 +02:00
parent c67a7148c4
commit e0ab58d815
2 changed files with 14 additions and 5 deletions

View File

@@ -861,7 +861,8 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
using std::max;
RealScalar threshold = (max)(considerAsZero, precision * (max)(abs(m_workMatrix.coeff(p,p)),
abs(m_workMatrix.coeff(q,q))));
if((max)(abs(m_workMatrix.coeff(p,q)),abs(m_workMatrix.coeff(q,p))) > threshold)
// We compare both values to threshold instead of calling max to be robust to NaN (See bug 791)
if(abs(m_workMatrix.coeff(p,q))>threshold || abs(m_workMatrix.coeff(q,p)) > threshold)
{
finished = false;