diff --git a/src/libarpack.jl b/src/libarpack.jl index bcf6d18..c532fb9 100644 --- a/src/libarpack.jl +++ b/src/libarpack.jl @@ -1,6 +1,28 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -import LinearAlgebra: BlasInt, ARPACKException +import LinearAlgebra: BlasInt +@static if isdefined(LinearAlgebra, :ARPACKException) + import LinearAlgebra: ARPACKException +else + struct ARPACKException <: Exception + info::BlasInt + end + + function Base.showerror(io::IO, ex::ARPACKException) + print(io, "ARPACKException: ") + if ex.info == -8 + print(io, "error return from calculation of a real Schur form.") + elseif ex.info == -9 + print(io, "error return from calculation of eigenvectors.") + elseif ex.info == -14 + print(io, string("did not find any eigenvalues to sufficient accuracy. ", + "Try with a different starting vector or more Lanczos vectors ", + "by increasing the value of ncv.")) + else + print(io, "unspecified ARPACK error: $(ex.info)") + end + end +end ## aupd and eupd wrappers diff --git a/test/runtests.jl b/test/runtests.jl index 0a2cd5d..559770a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -101,7 +101,7 @@ using Test, LinearAlgebra, SparseArrays, Random k = 3 A = randn(n,n); A = A'A B = randn(n,k); B = B*B' - @test sort(eigs(A, B, nev = k, sigma = 1.0)[1]) ≈ sort(eigvals(A, B)[1:k]) + @test sort(eigs(A, B, nev = k, sigma = 1.0)[1]) ≈ sort(eigvals(A, B); by=abs)[1:k] end end