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
248 stars 53 forks source link

Method ambiguity with sparse matrices and operator assumptions #369

Closed DanielVandH closed 7 months ago

DanielVandH commented 1 year ago
julia> using LinearSolve, SparseArrays

julia> A = sparse(rand(3,3));

julia> b = rand(3);

julia> prob = LinearProblem(A, b);

julia> assumptions = LinearSolve.OperatorAssumptions(condition=LinearSolve.OperatorCondition.WellConditioned);

julia> solve(prob; assumptions)
ERROR: MethodError: defaultalg(::SparseMatrixCSC{Float64, Int64}, ::Vector{Float64}, ::OperatorAssumptions{Nothing}) is ambiguous.

Candidates:
  defaultalg(A::SparseArrays.AbstractSparseMatrixCSC{<:Union{Float64, ComplexF64}, Ti}, b, assump::OperatorAssumptions) where Ti
    @ LinearSolve C:\Users\User\.julia\packages\LinearSolve\19ohw\src\default.jl:79
  defaultalg(A, b, assump::OperatorAssumptions{Nothing})
    @ LinearSolve C:\Users\User\.julia\packages\LinearSolve\19ohw\src\default.jl:31
  defaultalg(A::SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, b, assump::OperatorAssumptions) where {Tv, Ti}
    @ LinearSolve C:\Users\User\.julia\packages\LinearSolve\19ohw\src\default.jl:69

Possible fix, define
  defaultalg(::SparseArrays.AbstractSparseMatrixCSC{<:Union{Float64, ComplexF64}, Ti}, ::Any, ::OperatorAssumptions{Nothing}) where Ti

Stacktrace:
 [1] init(::LinearProblem{…}, ::Nothing; assumptions::OperatorAssumptions{…}, kwargs::@Kwargs{})
   @ LinearSolve C:\Users\User\.julia\packages\LinearSolve\19ohw\src\default.jl:246
 [2] solve(::LinearProblem{…}; kwargs::@Kwargs{…})
   @ LinearSolve C:\Users\User\.julia\packages\LinearSolve\19ohw\src\common.jl:187
 [3] top-level scope
   @ REPL[14]:1
Some type information was truncated. Use `show(err)` to see complete types.

On v1.10.0-beta2.

PaoloBiolghini commented 7 months ago

Hi, I have run exactly the same code now and it doesn't return any error; maybe has been solve with some update of SparseArrays or idk :)

ChrisRackauckas commented 7 months ago

It does seem to be fixed.