JuliaLinearAlgebra / IterativeSolvers.jl

Iterative algorithms for solving linear systems, eigensystems, and singular value problems
MIT License
399 stars 105 forks source link

MethodError: no method matching mul! with lsqr on julia 1.1 #243

Closed davidhien closed 5 years ago

davidhien commented 5 years ago

After updating to Julia 1.1.0 i get the following error when calling lsqr:

ERROR: MethodError: no method matching mul!(::SparseVector{Float64,Int64}, ::LinearAlgebra.Adjoint{Float64,SparseMatrixCSC{Float64,Int64}}, ::SparseMatrixCSC{Float64,Int64})
Closest candidates are:
  mul!(::AbstractArray, ::Number, ::AbstractArray) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\LinearAlgebra\src\generic.jl:26
  mul!(::AbstractArray, ::AbstractArray, ::Number) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\LinearAlgebra\src\generic.jl:27
  mul!(::AbstractArray{Ty,1}, ::LinearAlgebra.Adjoint{#s623,#s622} where #s622<:SparseMatrixCSC where #s623, ::AbstractSparseArray{Tx,Ti,1} where Ti) where {Tx, Ty} at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\SparseArrays\src\sparsevector.jl:1631
  ...
Stacktrace:
 [1] #lsqr_method!#68(::Int64, ::Float64, ::Float64, ::Float64, ::Int64, ::Bool, ::Function, ::ConvergenceHistory{false,Nothing}, ::SparseVector{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\david\.julia\packages\IterativeSolvers\QuajJ\src\lsqr.jl:129
 [2] (::getfield(IterativeSolvers, Symbol("#kw##lsqr_method!")))(::NamedTuple{(:maxiter,),Tuple{Int64}}, ::typeof(IterativeSolvers.lsqr_method!), ::ConvergenceHistory{false,Nothing}, ::SparseVector{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}) at .\none:0
 [3] #lsqr!#67(::Int64, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::SparseVector{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\david\.julia\packages\IterativeSolvers\QuajJ\src\lsqr.jl:74
 [4] lsqr! at C:\Users\david\.julia\packages\IterativeSolvers\QuajJ\src\lsqr.jl:70 [inlined]
 [5] #lsqr#66(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\david\.julia\packages\IterativeSolvers\QuajJ\src\lsqr.jl:8
 [6] lsqr(::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}) at C:\Users\david\.julia\packages\IterativeSolvers\QuajJ\src\lsqr.jl:8
 [7] top-level scope at none:0

This was the output from running

using IterativeSolvers

A = sprand(100, 20, 0.2)
b = sprand(100,1,0.2)

lsqr(A,b)

To me it seems that Julia 1.1.0 does not allow SparseVector to be the type of the first argument in mul!(a,b,c). Any fix or hint on how to fix this would be appreciated.

dkarrasch commented 5 years ago

It seems to work if you make b dense.

davidhien commented 5 years ago

Works for me, thanks.