From 8c7fe68f3874a9c094617d56bcbbfac6434ea9e0 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Thu, 13 Feb 2025 21:52:51 +0530 Subject: [PATCH 1/2] Detailed `showerror` for `SingularException` --- src/exceptions.jl | 4 ++++ test/dense.jl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/exceptions.jl b/src/exceptions.jl index 7791b1dd..1dd2ca17 100644 --- a/src/exceptions.jl +++ b/src/exceptions.jl @@ -28,6 +28,10 @@ struct SingularException <: Exception info::BlasInt end +function Base.showerror(io::IO, ex::SingularException) + print(io, "SingularException: matrix is singular; factorization failed. Zero eigenvalue found at index ", ex.info) +end + """ PosDefException diff --git a/test/dense.jl b/test/dense.jl index 1f953ea9..88eccfa6 100644 --- a/test/dense.jl +++ b/test/dense.jl @@ -1366,4 +1366,9 @@ end @test !any(LinearAlgebra.getstructure(A)) end +@testset "SingularException show" begin + A = diagm(0=> [1, 0]) + @test_throws "matrix is singular; factorization failed" inv(A) +end + end # module TestDense From c550974dcd271ef01bba5f8fc1a6ddb01dc59856 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sat, 15 Feb 2025 08:57:05 +0530 Subject: [PATCH 2/2] change to pivot Co-authored-by: Steven G. Johnson --- src/exceptions.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exceptions.jl b/src/exceptions.jl index 1dd2ca17..c346ce08 100644 --- a/src/exceptions.jl +++ b/src/exceptions.jl @@ -29,7 +29,7 @@ struct SingularException <: Exception end function Base.showerror(io::IO, ex::SingularException) - print(io, "SingularException: matrix is singular; factorization failed. Zero eigenvalue found at index ", ex.info) + print(io, "SingularException: matrix is singular; factorization failed. Zero pivot found at index ", ex.info) end """