Registered Member
|
Dear all,
I am a newcomer to Eigen, and I have the following question. I multiply two (large) square matrices, A and B. Actually, I only need the diagonal of A*B, not all the product matrix. On judging from the time taken by Eigen to complete the operation v = (A*B).diagonal();, I suspect that Eigen <first> calculates A*B and <then> extracts the diagonal, which is quite a waste of CPU. Is this correct? If so, is there a way to calculate the diagonal, discarding the other components of A*B? Thanks for your help |
Registered Member
|
Yes, this is correct. In most case, it's best to calculate the product first, but in your case it is probably better to calculate the coefficients you need one by one. You can instruct Eigen to do this using: v = A.lazyProduct(B).diagonal(); |
Registered Member
|
Thank you jitseniesen, it seems to work faster now!
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]