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
244 stars 52 forks source link

DefaultAlgorithmChoice.KrylovJL_LSMR is not defined #414

Closed cvsvensson closed 8 months ago

cvsvensson commented 10 months ago

DefaultAlgorithmChoice.KrylovJL_LSMR is used in the linked code, but it does not exist. https://github.com/SciML/LinearSolve.jl/blob/d863895dbf4eeb153f8deae331c7e4e0b74dc68a/src/default.jl#L144C11-L144C11

This code path is encountered in this MWE:

using LinearSolve
A = rand(3,2)
b = rand(3)
x = rand(2)
fo = FunctionOperator((u,p,t) -> A*u, x, b)
solve(LinearProblem(fo,b)) # UndefVarError: `KrylovJL_LSMR` not defined
ChrisRackauckas commented 10 months ago

@avik-pal is this related to your non-square defaults? It seems like it's missing the enum

avik-pal commented 10 months ago

No those ones existed from before

cvsvensson commented 10 months ago

Here's some more info. If size(A) == (2,3) instead, the same error occurs for KrylovJL_CRAIGMR. There is no problem if one supplies the algorithm explicitly to solve().

using LinearSolve
m, n = 3, 2 # Swap dimensions to get an error for KrylovJL_CRAIGMR instead
A = rand(m, n)
b = rand(m)
x = rand(n)
f = (du, u, p, t) -> mul!(du, A, u)
fadj = (du, u, p, t) -> mul!(du, A', u)
fo = FunctionOperator(f, x, b; op_adjoint = fadj)
prob = LinearProblem(fo, b)
solve(prob) # UndefVarError: `KrylovJL_LSMR` not defined
solve(prob, LinearSolve.KrylovJL_LSMR()) # This works

I tried simply adding KrylovJL_LSMR to the enum and a few other places, but the code execution ended up in gmres!, so I don't understand how the dispatch works.