Clustering, nearest-neighbour search and any "find me the closest" feature all rest on a distance matrix. Writing one with broadcasting instead of two loops is the moment broadcasting stops feeling like a rule and starts being useful.
Write pairwise_distances(a, b).
a has shape (n, d) and b has shape (m, d). Return the (n, m) array where entry [i, j] is the straight-line distance between row i of a and row j of b.
You have read the opening. The rest is free with a Bezen account, and no card is needed.
Behind the sign-in