akubera / bigdecimal-rs

Arbitrary precision decimal crate for Rust
Other
302 stars 73 forks source link

Matrix multiplication #48

Open BlinkyStitt opened 6 years ago

BlinkyStitt commented 6 years ago

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 commented 6 years ago

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

rubdos commented 6 years ago

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.

dengelt commented 2 years ago

@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.