title: How does pytorch calculate matrix pairwise distance? Why isn't 'self' distance not zero?
body: <p>If this is a naive question, please forgive me, my test code like this:</p>
  
  <pre><code>import torch
  from torch.nn.modules.distance import PairwiseDistance
  
  list_1 = [[1., 1.,],[1., 1.]]
  list_2 = [[1., 1.,],[2., 1.]]
  
  mtrxA=torch.tensor(list_1)
  mtrxB=torch.tensor(list_2)
  
  print "A-B distance     :",PairwiseDistance(2).forward(mtrxA, mtrxB)
  print "A 'self' distance:",PairwiseDistance(2).forward(mtrxA, mtrxA)
  print "B 'self' distance:",PairwiseDistance(2).forward(mtrxB, mtrxB)
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>A-B distance     : tensor([1.4142e-06, 1.0000e+00])
  A 'self' distance: tensor([1.4142e-06, 1.4142e-06])
  B 'self' distance: tensor([1.4142e-06, 1.4142e-06])
  </code></pre>
  
  <p>Questions are:</p>
  
  <ol>
  <li><p>How does pytorch calculate pairwise distance? Is it to calculate row vectors distance?</p></li>
  <li><p>Why isn't 'self' distance 0?</p></li>
  </ol>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>After changing list_1 and list_2 to this:</p>
  
  <pre><code>list_1 = [[1., 1.,1.,],[1., 1.,1.,]]
  list_2 = [[1., 1.,1.,],[2., 1.,1.,]]
  </code></pre>
  
  <p>Result becomes:</p>
  
  <pre><code>A-B distance     : tensor([1.7321e-06, 1.0000e+00])
  A 'self' distance: tensor([1.7321e-06, 1.7321e-06])
  B 'self' distance: tensor([1.7321e-06, 1.7321e-06])
  </code></pre>