p_mat_dist function

Point distance function