Speeding up element-wise multiplication between sparse and dense vectors



Hello,

I have a large 10^8+ elements sparse matrix X with no more
than 5% non-zero elements. I run an algorithm on X which
takes much longer if X is sparse compared to when it's dense.

The bottle neck is a computation of the form:
temp_result = sum(non_sparse_vec_01 .* X(:,i) .*
non_sparse_vec_02)

i.e the sum of an elementwise multiplication between dense
and sparse vectors.

Any ideas on how to speed up the computation?

There are 2 obvious options but both have drawbacks:
1. Convert the entire X to full -> speeds up but is memory
intensive
2. Convert columns of X into full when required -> not
memory intensive but conversion time cancels out what is
gained in time...

I also considered working only on the elements corresponding
to the nnz entires in X(:,i) -> since the final output is a
sum... but I only gain little.

Any help is appreciated.


/David
.



Relevant Pages