title: map a function to all columns for Scipy/numpy matrix
body: <p>I have a 40*4 matrix<code>M</code> and a vector<code>A</code> with 40 elements. I want to calculate the cosine distance between <code>A</code> and each column vector in M.</p>
  
  <p>Do I really need to write like this?</p>
  
  <pre><code> print [cosine(M[:,i],A) for i in range(A.shape[1])]
  </code></pre>
  
  <p>Or there's another better way to do this?</p>
  
  <p>The document of cosine can be viewed here: <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cosine.html#scipy.spatial.distance.cosine" rel="nofollow">http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cosine.html#scipy.spatial.distance.cosine</a></p>
  
  <p>Thanks!</p>