I have a (dense) matrix n x n x m and a sparse vector (scipy.sparse) 1 x m. If we look at my dense n x n x m matrix it could be interpreted as an n x n matrix with on each position a m x 1 vector. Now I want to compute the dot product of my sparse vector with each of the m x 1 dense vectors in the n x n matrix yielding a n x n matrix with all these dot products.
One way to do this is to build a for loop to loop through the n x n matrix and then use the .dot() function of scipy.sparse to compute the dot products with each vector in the matrix. However, I'm looking for a way to perform this calculation completely in a vectorized way for efficiency. Is this possible? If not, what's the fastest way in Python to loop through my n x n matrix?