-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add support for sparse matrices #59
Comments
Definitely, would be happy to accept a PR for this. I would prefer a separate header, e.g. |
Great! This is a side project for me, so development is a little slow. I expect to have something ready near the end of the month. |
No rush, it's the same for me. For the approach keep in mind that the |
For anyone who comes across this in the future---if one can guarantee csc format from scipy, then here's a quick a dirty solution in pybind11: void to_sparse(const py::object& S, arma::sp_mat& out){
py::tuple shape = S.attr("shape").cast< py::tuple >();
const size_t nr = shape[0].cast< size_t >(), nc = shape[1].cast< size_t >();
arma::uvec ind = carma::arr_to_col(S.attr("indices").cast< py::array_t< arma::uword > >());
arma::uvec ind_ptr = carma::arr_to_col(S.attr("indptr").cast< py::array_t< arma::uword > >());
arma::vec data = carma::arr_to_col(S.attr("data").cast< py::array_t< double > >());
out = arma::sp_mat(ind, ind_ptr, data, nr, nc);
} |
This is something I'm missing a bit: a way to convert
scipy.sparse
'scsc_matrix
into an equivalentarma::sp_mat
matrix (and back). I plan to write a converter myself as I need this, but I can imagine it makes a nice addition to the project. If you want, I can open a PR for this soon.The text was updated successfully, but these errors were encountered: