I have a numpy array where each element is a position, like this :
array([[1, 1, 0. ],
[2 , 2, 0. ],
[3 , 3, 1 ]])
And I want to compute the distance between each element. So here, the expected output is :
[0, 1.414213, 1.732050]
The distance is calculated as it follows :
For the first element it is 0 because ther isn't any element before. For the second it is sqrt((2 - 1)**2 + (2 - 1)**2 + (0 - 0)**2))
and so on
However, there is a lot of elements (around some thousands), and this operation is repeated multiple times. So I need a way to execute this very fast.
I was wondering if there is a library (or even better a numpy function) that could solve my problem. I used cdist
from scipy.spatial.distance before, but it doesn't work anymore (I have problems with scipy dependencies), so I'm searching for another way.