Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think the relevant code is here:

The algorithm does take into account the sparse nature, but it does have a triple-nested for-loop, enumerating all the indices. It may be that for moderate sparsity this is faster than just enumerating the non-zero entries, but especially for your example it's pretty clear a much more efficient implementation is possible.