Imlementation of the evaluation of cummulated distance matrix function