Registered Member
|
Hi,
I'm working with V3 of Eigen. I'm looking at the test case of the matrix. [1,0] [0,-1] This matrix isn't semi-positive definite. Nor is it semi-negative definite. Running it through LDLT I get the following results: reconstructedMatrix ; [1,0] [0,-1] isPositive : True (Which is wrong!) isNegative : False info : Success If you contrast this to the same input for LLT I get a failure code from info(), which is what I would expect since LLT only works on SPD matrices. In the docs it says that we can use LDLT on semi-positive definite or semi-negative matrices. If the input isn't one of these, as in the above case, it seems it should either fail or give a correct output. Is it possible to have this behaviour, please? Or is it not easy to do with this algo? Certainly it would help in the sense I that I wouldn't need an independent check on the correctness of the input in my code. Thanks very much. Really impressed with Eigen by the way. |
Moderator
|
Hi,
your matrix is a special case because it is diagonal. Therefore, the factorization went well, and it assumed the matrix was positive because the first pivot was 1. In a more general case, the factorization would have failed. I'm not sure we want to abort the factorization if it can really be done. So I propose the following simple fix: line 284 add:
|
Registered Member
|
|
Registered Member
|
In what sense would it fail? I tried a couple of indefinite matrices, and the LDLT class seems to work fine. Perhaps you mean that the algorithm can be unstable if the matrix is close to singular? I cannot see anything wrong with that, so I committed your fix to the development branch. |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]