title: Dot product sparse matrices
body: <p>I have two sparse matrices (<code>a</code> and <code>b</code>) in python of the following dimensions:</p>
  
  <pre><code>a = &lt;240760x2177930 sparse matrix of type '&lt;class 'numpy.float64'&gt;'
      with 1127853 stored elements in Compressed Sparse Row format&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>b = &lt;240760x2177930 sparse matrix of type '&lt;class 'numpy.float64'&gt;'
      with 439309 stored elements in Compressed Sparse Row format&gt;
  </code></pre>
  
  <p><strong>Question</strong>: I'd like to get a column vector of length 240760 that is the row-wise dot product of the two matrices.  For example, <code>dot(a[0],b[0])</code> would be the first element of my output vector. <code>dot(a[1],b[1])</code> would be the second, and so forth.</p>
  
  <p>Is there a vectorized easy way to accomplish this?</p>
  
  <p><strong><em>EDIT:</em></strong>  One way to accomplish this would be to convert each row into a dense vector, flatten it out, and use <code>numpy.dot()</code>.  Something like: </p>
  
  <pre><code>np.dot(np.array(a[0]).flatten(),np.array(b[0]).flatten()).  
  </code></pre>
  
  <p>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...</p>