I have the following function to compute distance between two points that are represented by matrices. i.e. points is a list of matrices, and other_points is an array of matrices.
def find_dist(points: list, other_points: np.array,) -> int:
min_dists = [np.min(np.linalg.norm(other_points - i, axis=1), axis=0) for i in points]
Is there a better way to achieve the above to optimize performance? I tried to use np.ufunc.outer as following but the logic gets messed up. I am not sure how to use np.ufunc.outer to achieve the above:
min_dists = [np.min(np.subtract.outer(other_points, i), axis=0) for i in points]
Thanks!