Post date: Jan 20, 2018 2:13:5 AM
This is an algorithm to see how two vectors match. The algorithm sums the minimum distance (L1) sum of two vectors the intent of which would be to compare it with the sums of other vectors in order to detect the best match (smallest minimum distance sum).
import numpy as np
def min_matching_sum(ref, qry):
length = len(ref)
ref_mat = np.tile(ref,(length,1))
ref_mat = ref_mat.T # ref as repeated col vec
qry_mat = np.tile(qry,(length,1))
diff_mat = np.abs(ref_mat - qry_mat)
return np.sum(np.min(diff_mat, axis=0))
np.argmin can be used within the routine to find out the positions of the best matches. The nice thing of this algorithm is that there is no explicit iteration code so hopefully it will go fast enough.