sparsemat / sprs

sparse linear algebra library for rust
Apache License 2.0
386 stars 45 forks source link

Implementing the Kronecker product #209

Closed mulimoen closed 4 years ago

mulimoen commented 4 years ago

I would like to see an implementation of the kronecker product in this library, which can be used for i.e. translating multi-dimensional spaces down to a single dimension.

Currently I use the following: https://gist.github.com/mulimoen/6321497759ce8ec0a14dcf4bb1bd9706

Let me know if you'd like me to make a pull request!

vbarrielle commented 4 years ago

Having the Kronecker product in the library seems nice, I haven't had the time to read your implementation yet but I'm in favor of a pull request :)

vbarrielle commented 4 years ago

Quickly skimming I can see that you have special cased the cartesian product {CSC, CSR}^2 but I think it should be possible to reduce to one or two implementations, eg the CSC-CSC case may be implementable in terms of the CSR-CSR case. And it may be reasonable to convert from CSC to CSR in the CSR-CSC case, that can even bring performance improvements (at least in the case where the left hand side matrix is larger than the right hand side, but it's possible there's a transposition trick to always convert the smallest matrix).