title: Compute the unit vector for each row of an array
body: <p>I have a large (n x dim) array, each row is a vector in a space (whatever the dimension but let's do it in 2D):</p>
  <pre class="lang-python prettyprint-override"><code>import numpy as np
  
  A = np.array([[50,14],[26,11],[81,9],[-11,-19]])
  
  A.shape
   (4,2)
  </code></pre>
  <p>I want to quickly compute the unit vector for each of those rows.</p>
  <pre class="lang-python prettyprint-override"><code>N = np.linalg.norm(A, axis=1)
  
  # something like this, but for each row:
  A /= N # not working: 
         # ValueError: operands could not be broadcast together
         # with shapes (4,2) (4,) (4,2)
  
  # or in a pandas-like manner:
  np.divide(A, N, axis=1, inplace=True) # not working either
  </code></pre>
  <p>How could you do that properly?</p>