gerneral distance matrix smoothing