LDLT: Report sign consistent with D for indefinite matrices.

See http://forum.kde.org/viewtopic.php?f=74&t=106942
This commit is contained in:
Jitse Niesen
2012-07-22 21:39:38 +01:00
parent 907f4562ac
commit fd5749f51c
2 changed files with 21 additions and 0 deletions

View File

@@ -281,6 +281,13 @@ template<> struct ldlt_inplace<Lower>
if(sign)
*sign = real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0 ? 1 : -1;
}
else if(sign)
{
// LDLT is not guaranteed to work for indefinite matrices, but let's try to get the sign right
int newSign = real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0;
if(newSign != *sign)
*sign = 0;
}
// Finish early if the matrix is not full rank.
if(biggest_in_corner < cutoff)