Stop cg_lanczos! resolving to the shifted workspace - #1251
Merged
Conversation
`get_KrylovJL_solver` tested `KrylovAlg === Krylov.cg_lanczos!` twice. The
first branch returned `CgLanczosShiftWorkspace`, so it won, and the second
branch returning `CgLanczosWorkspace` was unreachable.
`cg_lanczos!` is listed in the `KrylovJL` docstring as a supported
`KrylovAlg`, so this is reachable from documented usage:
solve(LinearProblem(A, b), KrylovJL(KrylovAlg = Krylov.cg_lanczos!))
MethodError: no method matching CgLanczosShiftWorkspace(::Matrix{Float64}, ::Vector{Float64})
Dropping the first branch lets it fall through to the right workspace. The
solve then succeeds, to a relative error of 5.9e-9 on a symmetric positive
definite system.
`cg_lanczos_shift!` and `cgls_lanczos_shift!` are deliberately left
unmapped. Both exist in Krylov 0.10, but they take a `shifts` argument that
this wrapper never passes, and neither appears in the docstring's list, so
they keep hitting "Invalid Krylov method detected" rather than being
advertised and broken.
Spotted in SciML#554, which is otherwise superseded: block GMRES and MINRES are
already interfaced through `BlockGmresWorkspace` and `BlockMinresWorkspace`
for a matrix right-hand side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
get_KrylovJL_solvermatchedcg_lanczos!twice. The first branch returned the shifted workspace and won, so the correct branch below it was dead code. Sincecg_lanczos!is listed in theKrylovJLdocstring,KrylovJL(KrylovAlg = Krylov.cg_lanczos!)threw aMethodErrorfrom the workspace constructor. Dropping the stray branch fixes it.The shifted variants stay unmapped on purpose: they take a
shiftsargument this wrapper never passes, and they are not in the documented list.Spotted in #554, which is otherwise superseded now that block GMRES and MINRES are reached by passing a matrix
btoKrylovJL_GMRES/KrylovJL_MINRES.AI Disclosure: Used Opus 5