This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Cholesky decomposition and Inverses

Tags: None
(comma "," separated)
snorri
Registered Member
Posts
2
Karma
0

Cholesky decomposition and Inverses

Fri Mar 20, 2009 9:41 am
Just after some advice on the best way to take a cholesky decomposition of matrices around size 100x100 to obtain an inverse. Just to test I was trying a quick program (-02 -DNDEBUG -march=core2) with the following code for the inverse calculation bit:

Code: Select all
#define SIZE 100
Matrix A;

...

    MatrixXf identity(SIZE,SIZE); identity = MatrixXf::Identity(SIZE,SIZE);
    Matrix inverse;

    LLT lltOfA(A);
    for (int i = 0; i < SIZE; ++i ) {
        lltOfA.solve(identity.col(i),&inverse.col(i));
    }

...

As it is, it's much slower than the default inverse() method using the LU decomposition by about 40%.

Is it just because the cholesky hasn't been thoroughly optimised yet or is there a better way to attack this?

Daniel Stonier.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
what about:

Matrix inv = Matrix::Identity();
A.llt().solveInPlace(inv);

there is no way Cholesky could be slower than LU.
snorri
Registered Member
Posts
2
Karma
0
ggael wrote:what about:

Matrix inv = Matrix::Identity();
A.llt().solveInPlace(inv);

there is no way Cholesky could be slower than LU.


Oh indeed!

I didn't realise you could pass the entire matrix into the solver. The block operations were taking up all the extra time.

Cheers.
Daniel Stonier.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell