bigdecimal-rs icon indicating copy to clipboard operation
bigdecimal-rs copied to clipboard

Matrix multiplication

Open BlinkyStitt opened this issue 7 years ago • 3 comments

Hello! I'm wanting to do some matrix multiplication with BigDecimal. Do you know of any matrix crates that are compatible?

I tried using https://docs.rs/matrix/0.21.12/matrix/, but got this error:

368 |                     sparse.set((i, j), BigDecimal::from(1.0));
    |                            ^^^ the trait `matrix::Element` is not implemented for `bigdecimal::BigDecimal`

I don't think it would be too hard to add this trait, but if someone's already done the work that would be great.

If no one has done the work, I think I need to do something like this in my code: https://doc.rust-lang.org/book/second-edition/ch19-03-advanced-traits.html#using-the-newtype-pattern-to-implement-external-traits-on-external-types

Although, I think it might be easier to modify BigDecimal and add an optional dependency on matrix kind of like how there is an optional dependency on serde.

I'm new to Rust, so any pointers are appreciated.

BlinkyStitt avatar Oct 16 '18 01:10 BlinkyStitt

Found another problem that I think is a blocker. matrix's Element trait needs Copy, but BigInt (and BigDecimal) do not impl Copy: https://github.com/rust-num/num/issues/191

BlinkyStitt avatar Oct 16 '18 02:10 BlinkyStitt

Found another problem that I think is a blocker. matrix's Element trait needs Copy,

Why would it need T: Copy? That sounds like a waste of time and space.

rubdos avatar Oct 18 '18 13:10 rubdos

@WyseNynja Have you found a workable solution yet? I'm also looking to do matrix multiplication on big integers / fractions. I was looking at the ndarray crate, but it also requires Copy, at least for matrix multiplications.

dengelt avatar Mar 19 '22 01:03 dengelt