Implemented similarity matrix computation