scikit-learn/scikit-learn — pull request #2954 by larsmans (2014-03-10 13:56:14+00:00)
Title: ENH pairwise L1 distances for sparse matrices

Simple, O(n_features) temp space algorithm: densify row by row, then subtract and compute L1 norm.

Added BLAS support code (cblas_dasum) to speed this up by a factor of two on x86-64 w/ GCC and ATLAS for pair of 93% sparse matrices of shape 1000*3000. That's an order of magnitude faster than the dense version.

Also cleaned up chi2 kernel code while I was at it and added a nogil decl.

This replaces #2849 which does the same thing but in a more complicated way and builds CSR matrices as output. I don't think that's necessary for the typical use case (k-medians algorithm, pairwise argmin).