title: Populate numpy matrix from the difference of two vectors
body: <p>Is it possible to construct a <code>numpy</code> matrix from a function? In this case specifically the function is the absolute difference of two vectors: <code>S[i,j] = abs(A[i] - B[j])</code>. A minimal working example that uses regular python:</p>
  
  <pre><code>import numpy as np
  
  A = np.array([1,3,6])
  B = np.array([2,4,6])
  S = np.zeros((3,3))
  
  for i,x in enumerate(A):
      for j,y in enumerate(B):
          S[i,j] = abs(x-y)
  </code></pre>
  
  <p>Giving:</p>
  
  <pre><code>[[ 1.  3.  5.]
   [ 1.  1.  3.]
   [ 4.  2.  0.]]
  </code></pre>
  
  <p>It would be nice to have a construction that looks something like:</p>
  
  <pre><code>def build_matrix(shape, input_function, *args)
  </code></pre>
  
  <p>where I can pass an input function with it's arguments and retain the speed advantage of numpy. </p>