QuantEcon / CompEcon.jl

Julia versions of the CompEcon routines by Miranda and Fackler.
BSD 3-Clause "New" or "Revised" License
47 stars 27 forks source link

ENH: specialize `row_kron` for sparse input #1

Closed sglyon closed 8 years ago

sglyon commented 9 years ago

Right now the Sparse matrix version of row_kron simply constructs a sparse matrix and hand off to the dense version of the function. This duplicates a lot of work, we could save some time by only dealing directly with the non-zero elements

sglyon commented 9 years ago

We kinda do this when both inputs are sparse because we do spzeros(out_type, dim1, dim2) and then hand off to our row_kron! method.

This issue really is about specializing row_kron! to only look at non-zero elements.

sglyon commented 9 years ago

Ok so we've improved here, but we can do even better.

In the current implementation we have a specialized case for two sparse matrices. It is pretty good, but can be faster by accessing the fields of the SparseMatrixCSC directly instead of using things like findnz.

We can get inspiration from the implementation of kron in the Base: