sparsemat / sprs

sparse linear algebra library for rust
Apache License 2.0
411 stars 47 forks source link

Implement BiCGSTAB #340

Closed jlogan03 closed 1 year ago

jlogan03 commented 1 year 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 1 year 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 1 year 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