Refactored similarity computation to use BLAS routines