Skip to content

eigs fails when called on some matrix with which=:SM #131

@laurentbartholdi

Description

@laurentbartholdi

I have a largeish sparse, symmetric matrix on which eigs(mat,which=:SM) fails; but it succeeds on small submatrices.

TL;dr: it seems bunchkaufman! is called with a sparse matrix, but it can only accept strided matrices.

julia> mat = sparse([1, 2, 34, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 2, 33, 34], [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 33, 34, 34, 34], Float32[12.0, 8.0, 1.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 1.0, 1.0, 1.0, 4.0])
34×34 SparseMatrixCSC{Float32, Int64} with 38 stored entries:
⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐
⠀⠀⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀
⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛

julia> eigs(mat) # this is fine
(Float32[12.000001, 8.449489, 8.000001, 8.0, 8.0, 8.0], Float32[1.0000001 -7.030933f-8 … 0.0 0.0; 5.9604645f-8 0.6738876 … 0.027224585 -0.00036482513; … ; 0.0 0.67388695 … -0.0272246 0.0003648214; 1.8559231f-7 0.30290544 … 0.0 0.0], 6, 1, 20, Float32[-1.2639064f-15, 6.4955343f-9, 2.1896764f-9, -2.1639128f-8, -3.943517f-9, -2.0025592f-8, -4.8012203f-9, -3.2126188f-8, 1.7540275f-8, 8.445834f-9  …  7.8725595f-9, 1.7422437f-8, 3.789941f-8, -2.3730575f-8, 5.321133f-8, 1.9782162f-8, 1.8557815f-8, -1.6891136f-8, -6.495541f-9, -1.921318f-15])

julia> eigs(mat,which=:SM) # ka-boom!
ERROR: MethodError: no method matching bunchkaufman!(::Hermitian{Float32, SparseMatrixCSC{Float32, Int64}}, ::Bool; check=true)
Closest candidates are:
  bunchkaufman!(::Hermitian{T, S} where {T<:Union{ComplexF32, ComplexF64}, S<:StridedMatrix{T}}, ::Bool; check) at /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/bunchkaufman.jl:102
  bunchkaufman!(::Union{Hermitian{T, S}, Symmetric{T, S}, Symmetric{Complex{T}, S}} where {T<:Union{Float32, Float64}, S<:(StridedMatrix{T} where T)}, ::Bool; check) at /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/bunchkaufman.jl:96
  bunchkaufman!(::StridedMatrix{var"#s815"} where var"#s815"<:Union{Float32, Float64, ComplexF32, ComplexF64}, ::Bool; check) at /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/bunchkaufman.jl:108
Stacktrace:
 [1] bunchkaufman(A::Hermitian{Float32, SparseMatrixCSC{Float32, Int64}}, rook::Bool; check::Bool)
   @ LinearAlgebra /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/bunchkaufman.jl:196
 [2] _factorize(A::Hermitian{Float32, SparseMatrixCSC{Float32, Int64}}; check::Bool)
   @ LinearAlgebra /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/symmetric.jl:645
 [3] _factorize(A::Hermitian{Float32, SparseMatrixCSC{Float32, Int64}})
   @ LinearAlgebra /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/symmetric.jl:643
 [4] factorize(A::Hermitian{Float32, SparseMatrixCSC{Float32, Int64}})
   @ LinearAlgebra /usr/local/src/julia/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/symmetric.jl:641
 [5] factorize(A::SparseMatrixCSC{Float32, Int64})
   @ SparseArrays /usr/local/src/julia/usr/share/julia/stdlib/v1.7/SparseArrays/src/linalg.jl:1612
 [6] _eigs(A::SparseMatrixCSC{Float32, Int64}, B::UniformScaling{Bool}; nev::Int64, ncv::Int64, which::Symbol, tol::Float64, maxiter::Int64, sigma::Nothing, v0::Vector{Float32}, ritzvec::Bool, explicittransform::Symbol, check::Int64)
   @ Arpack ~/.julia/packages/Arpack/S16ni/src/Arpack.jl:211
 [7] #eigs#10
   @ ~/.julia/packages/Arpack/S16ni/src/Arpack.jl:51 [inlined]
 [8] #eigs#9
   @ ~/.julia/packages/Arpack/S16ni/src/Arpack.jl:50 [inlined]
 [9] top-level scope
   @ REPL[153]:1

julia> eigs(mat[1:33,1:33],which=:SM) # on that top block, all is fine too
(Float32[7.999999, 8.0, 8.0, 8.0, 8.0, 8.0], Float32[-1.4790526f-8 1.7125398f-17 … -1.5129569f-9 2.8769254f-10; 0.29630464 0.0011543621 … 0.018754192 0.09862298; … ; 0.16326842 0.32161772 … 0.04730363 0.013291076; -0.06902978 0.38974732 … -0.41718462 -0.14601785], 6, 1, 20, Float32[-2.1406748f-18, -2.7734992f-10, 1.06227f-10, 3.3392237f-11, -6.1807434f-11, 5.5903016f-10, 6.26343f-11, 3.1210298f-10, -1.538405f-10, -3.69939f-10  …  -1.0335148f-10, 3.7906647f-11, 1.1831452f-10, 7.2083906f-10, -9.563203f-11, -9.36515f-11, -6.767832f-10, 8.40918f-10, 5.816487f-10, 3.533424f-10])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions