Registered Member
|
Hello
I want to find a fast method to multiply a full dense matrix of size 50 by 1000 by a vector of size 1000 by 1 whose 80% of the coefficients are zeros. I tried several approaches (method 2 to 4 in the code below) but could not get it running faster that the normal matrix multiplication (method 1 in the code below) while i would expect a 80% speedup achievable. I managed to get a very small speedup using pointers arithmetic, but the speedup is not as good as expected because the use of pointers arithmetic prevents the use of optimization based on SSE instructions (Streaming SIMD Extensions). How could i get closer to 80% speedup using eigen accelerated functions? thanks
Last edited by martin_IM on Wed Feb 01, 2012 11:10 am, edited 2 times in total.
|
Moderator
|
This is because the default dense vector*matrix product is highly optimized, and your vector is not sparse enough to compensate for a more naive matrix-vector product algorithm. You might try to compress the matrix M wrt the sparsity of B such that:
A = M*B = M' * B' where B' contains no zero. But I'm afraid the extra copy will cost too much, let's try and see! Btw, M.col(j) returns a proxy, no copy occurs. Actually Map and M.col(i) are based on the same MapBase class, they are the same thing ! |
Registered Member
|
I tried the solution proposed by ggael but my implementation is even slower due to copies i guess...
|
Registered users: Bing [Bot], Google [Bot]