Registered Member
|
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 |
Registered Member
|
|
Moderator
|
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); |
Registered Member
|
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! |
Moderator
|
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.
|
Moderator
|
I added a bug entry for 3.4: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1404
|
Registered Member
|
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]