Skip to content

Commit 054c8c6

Browse files
committed
add singularity checks
1 parent c51bad0 commit 054c8c6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/blas.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,11 @@ for (fname, elty) in ((:dtrsv_,:Float64),
13691369
throw(DimensionMismatch(lazy"size of A is $n != length(x) = $(length(x))"))
13701370
end
13711371
chkstride1(A)
1372+
if diag == 'N'
1373+
for i in 1:n
1374+
iszero(A[i,i]) && throw(SingularException(i))
1375+
end
1376+
end
13721377
px, stx = vec_pointer_stride(x, ArgumentError("input vector with 0 stride is not allowed"))
13731378
GC.@preserve x ccall((@blasfunc($fname), libblastrampoline), Cvoid,
13741379
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt},
@@ -2217,6 +2222,12 @@ for (mmname, smname, elty) in
22172222
end
22182223
chkstride1(A)
22192224
chkstride1(B)
2225+
if diag == 'N'
2226+
M = side == 'L' ? A : B
2227+
for i in 1:n
2228+
iszero(M[i,i]) && throw(SingularException(i))
2229+
end
2230+
end
22202231
ccall((@blasfunc($smname), libblastrampoline), Cvoid,
22212232
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{UInt8},
22222233
Ref{BlasInt}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},

0 commit comments

Comments
 (0)