Skip to content

Commit

Permalink
Move ARPACKException here from LinearAlgebra, fixes #64. (#65)
Browse files Browse the repository at this point in the history
* Move ARPACKException here from LinearAlgebra, fixes #64.

* Fix test failure on Julia 1.2 due to new eigenvalue sorting.
  • Loading branch information
fredrikekre committed Apr 15, 2019
1 parent 04defa4 commit 6c1bfec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion 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

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Expand Up @@ -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

Expand Down

0 comments on commit 6c1bfec

Please sign in to comment.