WIP: Optimizing and refactoring the computation of the similarity matrix

* Refactoring in a class so that we can cache some cluster-independent information
* Optimization with the covariance matrices