Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement construction from an input sparse vector / matrix #20

Open
rob-p opened this issue May 20, 2022 · 2 comments
Open

Implement construction from an input sparse vector / matrix #20

rob-p opened this issue May 20, 2022 · 2 comments

Comments

@rob-p
Copy link

rob-p commented May 20, 2022

I've been reading about this classic algorithm, and I was surprised (and happy) to see that one of the few implementations I could find was written in Rust!

Given that this method does particularly well at compressing sparse matrices, I wonder if it would make sense to have a constructor / builder that takes as input a matrix that is already sparse (e.g. represented as CSR, given the row-oriented nature of the algorithm). That way, one could avoid having to take an already sparse representation and densify it before applying this compression.

Thanks!
Rob

@ltratt
Copy link
Member

ltratt commented May 20, 2022

Perhaps the easiest way would be to allow an iterator as an input method (perhaps it could take (r, c, e) where r is the row, c the column, and e the element). If someone wanted to prototype such a thing I think I and @ptersilie would happily review!

@ptersilie
Copy link
Member

This sounds good to me. Though I think I should also mention that this implementation is not as optimal as it could be. If I remember correctly, we only shift in one direction (to the right) when creating the sparse vector. This could be made more optimal by allowing shifts to the left as well, which I think would allow for smaller vectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants