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

row-major sparse product

Tags: None
(comma "," separated)
matthieun
Registered Member
Posts
5
Karma
0

row-major sparse product

Tue Mar 07, 2017 10:54 am
Hi here !

I am trying to update my code from Eigen3.2.7 to Eigen3.3.3 and I am surprised about the row-major sparse matrix product.

(rmat for row-major sparse matrices and cmat for col-major).

rmat += rmat*rmat was compiling with Eigen3.2.7 but is no longer with 3.3.3 as rmat*rmat seems to return a cmat.
What was happening with 3.2.7? Was there an implicit cast or was rmat*rmat returning a rmat?

I can easily check every parts of code that is no longer compiling to decide if I should explicitly cast rmat*rmat to a rmat or if I can do better.
But what about every pieces of code that do compile anyway such as rmat = rmat*rmat, am I losing time in those situations?

Thanks for your help.

- Matthieu
matthieun
Registered Member
Posts
5
Karma
0

Re: row-major sparse product

Mon Mar 13, 2017 12:49 pm
Did anybody know/notice these changes?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: row-major sparse product

Mon Mar 13, 2017 2:44 pm
This is a bit tricky to explain, but essentially, the sparse*sparse product code is designed for:

C = A * B

and the ideal evaluation logic is then decided regarding the storage order of A, B, and C.

For C += A*B, the expression is evaluated as:

T = A*B;
C += T;

unfortunately,currently, the storage order of T is decided solely on A and B, whereas it should be decided on T. You can workaround by explicitly evaluating A*B into a temporary of appropriate storage order: C += rmat(A*B);
matthieun
Registered Member
Posts
5
Karma
0

Re: row-major sparse product

Mon Mar 13, 2017 4:32 pm
Thanks Gael for you answer.

What surprised me is Eigen3.2.7 was taking rmat += rmat*rmat with no warning, while with Eigen3.3.3 it does not compile at all!
Was Eigen3.2.7 already using a temporary?
I just want to be sure that I am not using more temporaries than before.

BTW if the resulting code is similar I prefer the new non-compiling version that is way more explicit!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: row-major sparse product

Mon Mar 13, 2017 4:51 pm
Yes, there was a temporary, it's just that the logic to compute the storage order of the temp changed. Thinking about your use case, it should be possible to slightly extend the current implementation to natively support += within the sparse-sparse product. This would be much better.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: row-major sparse product

Mon Mar 13, 2017 4:54 pm
matthieun
Registered Member
Posts
5
Karma
0

Re: row-major sparse product

Thu Mar 16, 2017 9:18 am
Thank you!


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]