Works with NCC
More efficient computation of pairwise distances