sparsemat / sprs

sparse linear algebra library for rust
Apache License 2.0
394 stars 46 forks source link

Implement BiCGSTAB #340

Closed jlogan03 closed 12 months ago

jlogan03 commented 12 months ago

Some thoughts about this implementation -

Pros

Cons

I spent a solid 8 hours attempting to make a version that is generic over the value type. This did not go well.

Some of the implementations of the underlying matrix-vector and vector-scalar operations are not fully generic, so the trait bounds on the impl end up being more than 10 lines long and incredibly unclear as to which types will and will not be compatible, and the type system ultimately fails on overflow due to inferring generic outputs across iterations in the solver loop.

This could all be fixed to some extent, but would require quite a bit of work to go back into the core of the crate and make a single definition of what trait bounds constitute a mathematical field over which we can do linear algebra, then propagate that definition to every struct and impl in the crate, which I believe is out of scope for this PR.

jlogan03 commented 12 months ago

@mulimoen I like the approx usage for testing, but had to roll it back because we don't keep approx as a default feature so it crashes the tests. I'd be happy to bring it back if we want to update either default features to include approx, or to include the approx feature for testing

mulimoen commented 12 months ago

I don't feel strongly about approx, bit of a pain to enable it for doctests. A bit of resolver history: The resolver previously merged features across build types, so having approx on during tests would enable it also for regular builds. Since we are using resolver v2 we can now use it for tests only