pwtools.num.distsq

pwtools.num.distsq(arrx, arry)[source]

Squared distances between all points in arrx and arry:

\[\begin{split}r_{ij}^2 = \sum_k (\texttt{arrx}[i,k] - \texttt{arry}[j,k])^2 \\ i = 1..M_x \\ j = 1..M_y \\ k = 1..N\end{split}\]
This is like

scipy.spatial.distance.cdist(arrx, arry)**2.0

This is a wrapper for pwtools._flib.distsq().

Parameters:
  • arrx (ndarray (Mx,N), (My,N)) – Mx (My) points in N-dim space

  • arry (ndarray (Mx,N), (My,N)) – Mx (My) points in N-dim space

Return type:

2d array (Mx,My)