This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 736

Summary: LDLT isPositive incorrectly returns false for a positive semidefinite matrix
Product: Eigen Reporter: Charles Collicutt <charles.collicutt>
Component: CholeskyAssignee: Jitse Niesen <jitseniesen>
Status: RESOLVED FIXED    
Severity: Unknown CC: gael.guennebaud, jitseniesen
Priority: Normal    
Version: 3.2   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 558    
Attachments:
Description Flags
Test case for LDLT::isPositive none

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
Comment 4 Nobody 2019-12-04 12:58:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/736.