sarah-ek / faer-rs

Linear algebra foundation for the Rust programming language
https://faer-rs.github.io
MIT License
1.82k stars 61 forks source link

Normal math operators can't be used with sparse matrices #94

Closed alexander-novo closed 7 months ago

alexander-novo commented 9 months ago

Is your feature request related to a problem? Please describe. Normal math operators like +, -, *, == etc. can't be used on sparse matrices. There are currently two bounds that can't be satisfied:

1) The inner storage types of sparse matrices have to impl GenericMatrix, which they don't. 2) The generic sparse types have to implement the matrix operation traits like MatMul, MatAdd etc. Right now MatMul is implemented for sparse types, but not any of the other operations.

Describe the solution you'd like Right now, to multiply a sparse matrix with another matrix, you must manually invoke the MatMul implementation as so:

<SparseRowMat<_> as MatMul<DenseCol>>::mat_mul(lhs, rhs.as_ref());

And there's no way to add or subtract sparse matrices. It would be nice to be able to do something like lhs * &rhs and lhs + &rhs like normal. As well, it would also be nice to have a Debug and Index implementation for sparse matrices.

sarah-ek commented 7 months ago

other than sparse-sparse matrix multiplication (which is more complex than the other operations), i finished implementing everything else you suggested. should be available in the next release

sarah-ek commented 7 months ago

all of the operations should be supported now in 0.18