distance function that returns the distance among vecs