I have two sparse matrices (a and b) in python of the following dimensions:
a = <240760x2177930 sparse matrix of type '<class 'numpy.float64'>'
with 1127853 stored elements in Compressed Sparse Row format>
and
b = <240760x2177930 sparse matrix of type '<class 'numpy.float64'>'
with 439309 stored elements in Compressed Sparse Row format>
Question: I'd like to get a column vector of length 240760 that is the row-wise dot product of the two matrices. For example, dot(a[0],b[0]) would be the first element of my output vector. dot(a[1],b[1]) would be the second, and so forth.
Is there a vectorized easy way to accomplish this?
EDIT: One way to accomplish this would be to convert each row into a dense vector, flatten it out, and use numpy.dot(). Something like:
np.dot(np.array(a[0]).flatten(),np.array(b[0]).flatten()).
But this requires iterating row wise and convert each row into a dense vector, which is very time consuming. I'm thinking there's probably an easier way to do this...
a.multiply(b).sum(1)? It yields a vector of the right length, I'm just not really sure what it's doing. The wholecsr_matrixAPI is so foreign to me. - David