Sparse matrix indexing with ranges is slow and memory hungry

This fixes the case when a whole column is indexed.  However, indexing
parts of columns still has that problem and needs a bigger rewrite.