Assuming I have two matrices, A of dimensions r X c, and B of dimensions r X d (i.e., both matrices have the same number of rows and a different number of columns). Now, I want to compare every column in A to every column in B. That is, I want to find all the pairs (i,j), where column i in matrix A equals column j in matrix B. Obviously, this can be easily done with a loop but I was wondering if there is an efficient fancy numpy style way to do that (where the emphasis is on being efficient)?
Thanks!
np.where((A[:,None] == B[...,None]).all(0))