Bug 736 - LDLT isPositive incorrectly returns false for a positive semidefinite matrix
LDLT isPositive incorrectly returns false for a positive semidefinite matrix
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Cholesky
3.2
All All
: Normal Unknown
Assigned To: Jitse Niesen
:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2014-02-04 17:34 UTC by Charles Collicutt
Modified: 2014-02-06 12:37 UTC (History)
2 users (show)



Attachments
Test case for LDLT::isPositive (599 bytes, text/x-c++src)
2014-02-04 17:34 UTC, Charles Collicutt
no flags Details

Description Charles Collicutt 2014-02-04 17:34:36 UTC
Created attachment 419 [details]
Test case for LDLT::isPositive

According to the documentation for Eigen 3.2.0, LDLT::isPositive should return true if a matrix is positive semidefinite.

See: http://eigen.tuxfamily.org/dox/classEigen_1_1LDLT.html#a02588e810c938a215dfd59d933488ba3

However, it returns false on some positive definite matrices. There is an example attached to this bug report.

Given the matrix:

1 0 0
0 0 0
0 0 1

Both isPositive and isNegative return false. However, the eigenvalues are all non-negative and have no imaginary parts:

1 + 0i
0 + 0i
1 + 0i

So this is a positive semidefinite matrix. LDLT::isPositive should return true.
Comment 1 Charles Collicutt 2014-02-04 17:36:44 UTC
Typo: "it returns false on some positive definite matrices" should be "it returns false on some positive semidefinite matrices".

Also, I've tested this with a fresh checkout from bitbucket.org and it behaves the same as the 3.2.0 release.
Comment 2 Jitse Niesen 2014-02-06 10:51:44 UTC
I can confirm this. Even worse, isPositive and isNegative both return false for the zero matrix, which is of course both positive semi-definite and negative semi-definite. It does not seem that the case of the zero matrix is taken into account in the current implementation.

In the presence of round-off error, the difference between positive definite and positive semi-definite is of course rather tricky, but for these matrices we should be able to do the right thing.

Related may be the fix of bug 608.
Comment 3 Jitse Niesen 2014-02-06 12:37:56 UTC
I just committed a fix.

changeset:   5751:b7308ae775bb
user:        Jitse Niesen <jitse@maths.leeds.ac.uk>
date:        Thu Feb 06 11:06:06 2014 +0000
summary:     Fix bug 736: LDLT isPositive returns false for a positive semidefinite matrix

changeset:   5752:6bb4d49bca4e
branch:      3.2
tag:         tip
parent:      5748:79cff6ee0ed5
user:        Jitse Niesen <jitse@maths.leeds.ac.uk>
date:        Thu Feb 06 11:06:06 2014 +0000
summary:     Fix bug 736: LDLT isPositive returns false for a positive semidefinite matrix

Note You need to log in before you can comment on or make changes to this bug.