compute_outer function

Computes distance on all possible combinations