New user self-registration is currently disabled. Please email eigen-core-team @ if you need an account.
Bug 894 - isPositive returns false for SPD matrix after compute() on an already initialized LDLT object
isPositive returns false for SPD matrix after compute() on an already initial...
Product: Eigen
Classification: Unclassified
Component: Cholesky
3.3 (current stable)
x86 - 64-bit All
: Normal Wrong Result
Assigned To: Nobody
Depends on:
  Show dependency treegraph
Reported: 2014-10-19 05:41 UTC by srskko
Modified: 2014-10-20 10:53 UTC (History)
2 users (show)


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();
    std::cout << chol.isPositive() << std::endl;
    M = Eigen::MatrixXd::Random(10, 10);
    return 0;



Expected Output:


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:
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()
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!

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