title: Compute all cosine similarities in a matrix
body: <p>Say I have a matrix <code>mat</code> an <code>100 x 200</code> array. </p>
  
  <p>My question is twofold: </p>
  
  <ol>
  <li><p>How can I compute the cosine similarity of the first row against all the other rows? I tried using <code>sklearn</code>'s <code>cosine_similarity</code> function but passing in a <code>100 x 200</code> matrix gives me a <code>100 x 100</code> array (instead of a <code>100 x 1</code> array).</p></li>
  <li><p>If I wanted to compute the cosine similarities of all the rows against the others, say compute all 100 C 2 = 4950 different combinations of all the rows, would it be fastest <strong>not</strong> to use something like <code>sklearn</code> but actually store the norms of each of the rows by <code>np.linalg.norm</code> and then compute each similarity by <a href="https://stackoverflow.com/questions/18424228/cosine-similarity-between-2-number-lists"><code>cos_sim = dot(a, b)/(norm(a)*norm(b))</code></a>?</p></li>
  </ol>