Created
February 8, 2017 10:14
-
-
Save JoaoRodrigues/3c05cab226fa651b85340407cec913a9 to your computer and use it in GitHub Desktop.
Pairwise Distance Calculation on Nx3 (xyz) Matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jit() | |
def pw_dist(xyz_array): | |
"""Iteration-based pairwise distance calculator""" | |
A = xyz_array | |
M, N = A.shape | |
max_d = 0.0 | |
for i in xrange(M): | |
print(i) | |
_t = [] | |
_x, _y, _z = A[i,0], A[i,1], A[i,2] | |
for j in xrange(i+1, M): | |
d = (_x - A[j,0])**2 + (_y - A[j,1])**2 + (_z - A[j,2])**2 | |
_t.append(d) | |
_md = max(_t) | |
if _md > max_d: | |
max_d = _md | |
return max_d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment