spinguin.core.intersect_indices

spinguin.core.intersect_indices#

This module contains a Cython function for finding the intersection of two sorted 2D arrays.

intersect_indices(A, B, row_len) tuple[ndarray, ndarray]#

Fast O(n) implementation for finding the indices of common rows from two 2D arrays. The arrays must be pre-prepared into contiguous 1D format. Each row in the original 2D array must be unique and they must be sorted in lexicographic order.

Parameters:
  • A (ndarray) – First array converted to contiguous 1D format. Data type must be np.longlong.

  • B (ndarray) – Second array converted to contiguous 1D format. Data type must be np.longlong.

  • row_len (int) – Length of the rows. Data type must be np.longlong.

Returns:

  • A_ind (ndarray) – Indices of the common elements in array A.

  • B_ind (ndarray) – Indices of the common elements in array B.