add function to compute similarity matrix