title: numpy divide along axis
body: <p>Is there a numpy function to divide an array along an axis with elements from another array? For example, suppose I have an array <strong>a</strong> with shape (l,m,n) and an array <strong>b</strong> with shape (m,); I'm looking for something equivalent to:</p>
  
  <pre><code>def divide_along_axis(a,b,axis=None):
      if axis is None:
          return a/b
      c = a.copy()
      for i, x in enumerate(c.swapaxes(0,axis)):
          x /= b[i]
      return c
  </code></pre>
  
  <p>For example, this is useful when normalizing an array of vectors:</p>
  
  <pre><code>&gt;&gt;&gt; a = np.random.randn(4,3)
  array([[ 1.03116167, -0.60862215, -0.29191449],
         [-1.27040355,  1.9943905 ,  1.13515384],
         [-0.47916874,  0.05495749, -0.58450632],
         [ 2.08792161, -1.35591814, -0.9900364 ]])
  &gt;&gt;&gt; np.apply_along_axis(np.linalg.norm,1,a)
  array([ 1.23244853,  2.62299312,  0.75780647,  2.67919815])
  &gt;&gt;&gt; c = divide_along_axis(a,np.apply_along_axis(np.linalg.norm,1,a),0)
  &gt;&gt;&gt; np.apply_along_axis(np.linalg.norm,1,c)
  array([ 1.,  1.,  1.,  1.])
  </code></pre>