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

Cholesky with Eigen is slow

Tags: None
(comma "," separated)
bobo01
Registered Member
Posts
10
Karma
0

Cholesky with Eigen is slow

Thu Apr 24, 2014 5:55 am
Hello

I am working on a 241x241 double matrix and a 241 vector. I want to solve Ax=b, where b is unknown. The matrix is positive definite and is suitable for Cholesky.

In my Eigen code I write the following:

Code: Select all
VectorXd x= A.ldlt().solve(B)


I am using an ARM Cortex A9 and it takes 40ms to execute this code. Can someone verify that this is as quick as I can get? I expected quicker as my own written code also executes in 40ms. I was hoping that Eigen would be quicker than me.

I am using O3 optimisation with NEON supported and the -DNDEBUG flag set, although as the NEON for the A9 only supports single precision, I am not sure that this is in use.

Can I do anything else to make it quicker? I was hoping for around 20ms.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Cholesky with Eigen is slow

Thu Apr 24, 2014 11:29 am
Indeed, NEON supports only single precision so you're loosing Eigen's SIMD capabilities. If your matrices are well conditioned you might try using float and/or Eigen's LLT factorization which has the advantage to leverage matrix-matrix operations instead of matrix-vector ones.
bobo01
Registered Member
Posts
10
Karma
0

Re: Cholesky with Eigen is slow

Fri Apr 25, 2014 7:09 am
Using LLT, I got speeds of 13.9ms. I will need to check if this is good enough. I don't know yet the differences between LLT and LDLT :) But that 13.9ms is very good, better than I expected.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Cholesky with Eigen is slow

Fri Apr 25, 2014 8:10 am
LDLT does numerical pivoting thus its superior numerical stability. LDLT can also handle indefinite matrices. If your matrices are positive definite, then LLT should be fine.
bobo01
Registered Member
Posts
10
Karma
0

Re: Cholesky with Eigen is slow

Fri Apr 25, 2014 9:58 am
Just one more thing regarding Cholesky. Does anyone know if it supports complex numbers too? Will that be slower?
jitseniesen
Registered Member
Posts
204
Karma
2

Re: Cholesky with Eigen is slow

Fri Apr 25, 2014 11:40 am
bobo01 wrote:Just one more thing regarding Cholesky. Does anyone know if it supports complex numbers too? Will that be slower?

Yes, it supports complex numbers. And yes, it will be slower.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell