aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Cholesky/LDLT.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h
index 68e54b1d4..a73a9c19f 100644
--- a/Eigen/src/Cholesky/LDLT.h
+++ b/Eigen/src/Cholesky/LDLT.h
@@ -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)