aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Cholesky
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-22 21:39:38 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2012-07-22 21:39:38 +0100
commitfd5749f51c899941323a2c3a2b1e152102bacebe (patch)
tree3e8507d11e15c2a307ac16ca1c40879d54c94e89 /Eigen/src/Cholesky
parent907f4562acf9de792290e459758f430e79476e7a (diff)
LDLT: Report sign consistent with D for indefinite matrices.
Diffstat (limited to 'Eigen/src/Cholesky')
-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)