I have an 1D array of numbers, and want to calculate all pairwise euclidean distances. I have a method (thanks to SO) of doing this with broadcasting, but it\'s inefficient
Using half the memory, but 6 times slower than np.abs(r - r[:, None]):
np.abs(r - r[:, None])
triu = np.triu_indices(r.shape[0],1) dists2 = abs(r[triu[1]]-r[triu[0]])