title: What is the most efficient way to create a 'difference matrix' i.e., the difference between each row and all others?
body: <p>I have a square matrix of like this:</p>
  
  <pre><code>[[ 1.,  2.,  3.],
   [ 4.,  5.,  6.],
   [ 7.,  8.,  9.]]
  </code></pre>
  
  <p>and want a matrix like this:</p>
  
  <pre><code>[[0.,   27., 108.],
   [27.,   0.,  27.],
   [108., 27.,   0.]]
  </code></pre>
  
  <p>which contains the (here: squared euclidean) distance between each row vector and the other rows in the columns.</p>
  
  <p>What is the most efficient way of creating such a matrix? Is there a way to do this with a "clever" Numpy operation, perhaps without explicit iteration?</p>