Cosine and Mahalanobis distance

This PR implements Cosine and Mahalanobis distances.
I'm thinking it higher level than floats, but does not below here.