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

Recomputing M^T * M when M has same sparsity pattern

Tags: None
(comma "," separated)
evouga
Registered Member
Posts
4
Karma
0
I need to compute the sparse matrix-matrix product M^T*M many times, where the values of M's entries changes every time, but the sparsity pattern stays the same. Is there any way of more efficiently computing the product, other than just

MTM = M.transpose()*M;

each time?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Yes, here is what you could do:

first time:

R = M.adjoint() * M;

then:

loop over the non-zeros of R as usual (see http://eigen.tuxfamily.org/dox-devel/gr ... tml#title2), and in the nested for loops:

it.valueRef() = M.col(it.row()).dot(M.col(it.col));

This should work, please let us know whether you get a significant gain...
evouga
Registered Member
Posts
4
Karma
0
Actually I get a significant speed *loss.*

If I write my own code to compute the sparse column dot product I still get a speed loss, though slightly less.


Bookmarks



Who is online

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