This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 894 - isPositive returns false for SPD matrix after compute() on an already initialized LDLT object
Summary: isPositive returns false for SPD matrix after compute() on an already initial...
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Cholesky (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - 64-bit All
: Normal Wrong Result
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-19 05:41 UTC by srskko
Modified: 2019-12-04 13:50 UTC (History)
2 users (show)



Attachments

Description srskko 2014-10-19 05:41:51 UTC
If you initialize an LDLT object with a non positive definite matrix and then call compute() with a positive definite matrix argument, LDLT keeps returning isPositive() == false.

Example code:

#include <Eigen/Core>
#include <Eigen/Cholesky>
#include <iostream>

int main()
{
    Eigen::MatrixXd M = Eigen::MatrixXd::Random(10, 10);
    Eigen::LDLT<Eigen::MatrixXd> chol(M);
    std::cout << chol.isPositive() << std::endl;
    M = (M * M.transpose()).eval();
    M = 0.5 * (M + M.transpose()).eval();
    chol.compute(M);
    std::cout << chol.isPositive() << std::endl;
    M = Eigen::MatrixXd::Random(10, 10);
    return 0;
}

Output:

0
0

Expected Output:

0
1 

The problem appears both on linux and mac, for version 3.2.2 and the latest mercurial revision, haven't tested other configurations.
If I compile against the eigen 3.2.0 shipped with ubuntu 14.04 the example correctly displays 0 1, so I suppose this is a regression.
PS: first bug report ever, so I apologize if it's not clear/proper
Comment 1 Gael Guennebaud 2014-10-20 10:50:33 UTC
Thank you for the report, fixed:

https://bitbucket.org/eigen/eigen/commits/3e1f580fdb6c/
Changeset:   3e1f580fdb6c
User:        ggael
Date:        2014-10-20 08:48:40+00:00
Summary:     Fix bug 894: the sign of LDLT was not re-initialized at each call of compute()

https://bitbucket.org/eigen/eigen/commits/c1fd3a329542/
Branch:      3.2
Comment 2 Gael Guennebaud 2014-10-20 10:53:58 UTC
btw, your bug report is very clear, a self-compilable example is a must to have to get bugs fixed quickly and save us time!
Comment 3 Nobody 2019-12-04 13:50:16 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/894.

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