Registered Member
|
Hi,
I am dealing with a sparse matrix which is composed of blocks of dense matrices (MatrixXd). matSparse = | A 0| |0 B | with A and B dense matrices In a perfect world, I would fill my matrix by assigning my dense blocks into sub-matrices of the sparse one. Unfortunately, it is not possible (cf documentation) Do you know any mean to do it efficiently ? Thanks ! |
Moderator
|
|
Registered Member
|
Great !
Thank you very much, I will give it a try ! I have also a side question : Is it possible to perform multiple matrix-matrix products with eigen in only one operation ? C1 = A1 * B1 C2 = A2 * B2 ... Cn = An * Bn I have seen some approaches using multidimensional arrays, but is it possible with eigen ? I fact, my first question was related to this problem, but I fear that the performances may be very bad ! Thanks a lot ! PS : I love Eigen, the syntax is very elegant ! |
Moderator
|
oh, then what you actually want is to form a DiagonalMatrix<MatrixXd> but, really just write a for loop, this is what will be the simplest and most efficient. Inserting your dense objects into a sparse matrix will be costly and the products will be mush slower.
|
Registered Member
|
Just a for loop ?
In fact, my dense matrices are "quite" small (typically 1000x40), so I thought I could improve the efficiency of the operations by packing them together rather than looping. In this case, perhaps openmp directives would also improve the efficiency of the for loop ? But what I am wondering is the following : what is the most efficient between : * sequential loop, then use eigen's multithreaded operators * multithreaded loop and sequential eigen operators Thanks a lot for your sound answers ! |
Moderator
|
If, for instance, the B_i would all be the same then yes packing the matrices A_j into a single big one would improve performances. However, here there is nothing that can be done except looping over each individual products.
Using OpenMP here is a good idea and in general it is always better to parallelize at the highest level as possible, that is why in Eigen don't hurry to parallelize our own algorithms and only matrix-matrix product are parallelized. |
Registered Member
|
OK,
I'll give it a try. Thank you very much ! |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]