I have a square matrix of like this:
[[ 1., 2., 3.],
[ 4., 5., 6.],
[ 7., 8., 9.]]
and want a matrix like this:
[[0., 27., 108.],
[27., 0., 27.],
[108., 27., 0.]]
which contains the (here: squared euclidean) distance between each row vector and the other rows in the columns.
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?