Skip to content

Commit d1d5304

Browse files
Add singularity check for robust LU factorization
1 parent 0fd5a0b commit d1d5304

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/array/lu.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ end
3636

3737
function update_ipiv!(ipivl::AbstractVector{Int}, piv_idx::AbstractVector{Int}, piv_val::AbstractVector{T}, k::Int, nb::Int) where T
3838
max_piv_idx = argmax(abs.(piv_val))
39+
max_piv_val = abs(piv_val[max_piv_idx])
40+
isapprox(max_piv_val, zero(T); atol=eps(T)) && throw(SingularException(k))
3941
ipivl[1] = (max_piv_idx+k-2)*nb + piv_idx[max_piv_idx]
4042
end
4143

0 commit comments

Comments
 (0)