sparsemat / sprs

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

wrap scipy matrixes in Rust #289

Open kno10 opened 3 years ago

kno10 commented 3 years ago

It would be great if one could use this to access scipy csr_matrix/csc_matrix from Rust for writing extensions. There is rust-numpy to work with numpy arrays from rust, but that does not include scipy sparse matrixes. But it would be great to write performance-critical operations in rust, and allow "driving" them from Python.

mulimoen commented 3 years ago

Are you looking for a python wrapper around this (#200) or something different? The crate is generic on storage type so you should be able to regenerate the matrix on the rust side if you have the raw buffers.

kno10 commented 3 years ago

No, the opposite. Process scipy csr matrixes with rust without copying them first. Use case: a user does the preprocessing into tf-idf matrix in python, then calls a fast rust library for the analysis.

mulimoen commented 3 years ago

A TryInto<CsMatViewI> impl? A direct implementation seems out of scope for this crate, as we have to pull in so many dependencies. This should be as simple as calling new_unchecked using the buffers given by scipy. Just make sure the indices are sorted on the python side.