Re: [eigen] Efficient way to store symmetric matrix for use with Cholesky?

[ Thread Index | Date Index | More Archives ]

arf, sorry you are right, my unit test was stupid enough to not catch that issue.

Anyway, now that's fixed. Thank you for the report!


On Wed, Jun 9, 2010 at 1:00 PM, SHIROKOBROD Oleg <Oleg.Shirokobrod@xxxxxxxxxx> wrote:

Hi Gael,


It seems that there is still a bug in LDLT. I discussed this case with Benoit



>a quick look at the code suggests that SelfAdjoitView::ldlt() is unimplemented, unless i missed it. So either we should implement it, or remove the declaration.

>Right now, you can do:   matrix.ldlt()   but not selfadjointview.ldlt().

>I guess the real problem is that we used to have a little bug in ldlt that makes it use more than just one triangular half of the matrix.

>See comment in LDLT.h. Maybe the first thing to do, is to fix this bug.



Here is a test case


typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Vector;

typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> Matrix;


Matrix M(3, 3);

Vector values(3);


// Fill the Vector velues

        vlues =









                        40.0               63000.0               129150000.0

                        0.0                 129150000.0        297675000000.0

                        0.0                  0.0                     731699325000000.0




M += values * values.transpose()


                        40.0               63000.0               129150000.0

                        63000.0          129150000.0        297675000000.0

                        129150000.0   297675000000.0   731699325000000.0


Eigen::LDLT<Matrix, Eigen::Upper> ldltOfM(M);


Vector rightHandSide(3);


// Fill the Vector rightHandSide

        rightHandSide =









 result rightHandSide






 result rightHandSide





As you see in the first case strictly lower triangular part of M is zero apart the second case with full selfajoint matrix filled.


Correct result is for the second case. So LDLT still uses by the bug lower triangular part of a matrix.






From: Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] On Behalf Of Gael Guennebaud
Sent: Tuesday, June 08, 2010 22:26
To: eigen@xxxxxxxxxxxxxxxxxxx
Subject: Re: [eigen] Efficient way to store symmetric matrix for use with Cholesky?



On Tue, Jun 8, 2010 at 7:02 PM, Manoj Rajagopalan <rmanoj@xxxxxxxxx> wrote:


  Right now I am using a full square matrix to store a symmetric matrix and
am calling LDLT on it. I believe a bug was recently fixed that gets the
Cholesky module accessing only one triangular part of the matrix, as it
should. Is there some way to just store one triangular part and call LDLT on
that instead of storing the entire matrix?


indeed, now the LDLT dec works as the LLT in the sense you can specify which triangular part has to considered:



LDLT<MatrixType,Upper> ldlt(mat);

Of course you still need a full dense matrix, but note that one half is free to store another triangular or selfadjoint matrix.

Now it seems you are looking for a compact storage for triangular matrices. This is currently not available in Eigen but if someone is willing to do it the idea is to split the triangular matrix into two triangles and one square and transpose one of the triangle such that it can be put in the remaining empty space as it is better explained there: The main advantage of this scheme is that's quite easy to implement matrix products, solvers and decompositions on top of it reusing dense algorithms. Since the benefits are relatively small, this is a low priority for us. Nevertheless, I think this is a quite nice project for someone who want to contribute because it mainly consists in relatively high level coding.



+++ Virus-scanned by MailControl for Oxford Instruments +++

This e-mail is confidential and is for the addressee only.   Please refer to for regulatory information.

Mail converted by MHonArc 2.6.19+