Similarity matrix computation