0

Using python and numpy I have the following problem. I have two lists of 2D points which are actually Mx2 and Nx2 sized matrices (let's call A and B respectively). What I intend to reach is a MxN sized matrix where the (i,j). th entry is the Euclidean distance between the points A[i,:] and B[j,:]. Simply doing a matrix multiplication np.dot(A,np.tranpose(B)) will just give me the dot products between the points so this does not work for me. Since M and N in the scale of tens of thousands, using for loops are prohibitively slow for me. We have numpy.apply_along_axisbut as far as I know this is not much different than a for loop under the hood. So, what would be the most fast way to do that?

Ufuk Can Bicici
  • 3,589
  • 4
  • 28
  • 57

0 Answers0