SciML / LinearSolve.jl

LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface.
https://docs.sciml.ai/LinearSolve/stable/
Other
245 stars 52 forks source link

Disallow algorithm switching? #311

Closed fredrikekre closed 10 months ago

fredrikekre commented 1 year ago

While looking around the code base for #309 it seems like a lot of complexity/extra code is a result of that you can reinitialize a LinearCache with a new algorithm. Is this useful in practice? It doesn't seem like much or a restriction to have to use the original LinearProblem when switching algs.

ChrisRackauckas commented 1 year ago

I don't recall what extra code was specifically for that, but yeah it's not the most useful feature since if you have to reinit for a new algorithm then you have to rebuild effectively the whole cache so it's not very different from just doing init again, so it might as well just be init. So if you have a simplification in mind I'd be happy to see it.

Though I think you may instead be referring to the issue of handling the default algorithm? That needs a cache of all caches in order to have a single type for all caches. I was going to open an issue about better handling that by getting rid of a ton of type parameters and hardcoding some types in there, but that's a bit nasty since there's a few variations that can happen with sparse vs non-sparse so the big type parameter version exists for now. But I don't see another way to do the initialization of the default method because even though it won't switch algorithms, it needs to have all of the caches so that its statically determinable what the cache type is, given that the algorithm choice is runtime information.