Skip to content

Commit 5f465da

Browse files
oscardssmithKristofferC
authored andcommitted
Merge pull request #50525 from oscardssmith/fix-generic_lu_fact-check=false
only check that values are finite in `generic_lufact` when `check=true` (cherry picked from commit 824cdf1)
1 parent 15f417f commit 5f465da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdlib/LinearAlgebra/src/lu.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ lu!(A::AbstractMatrix, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype
132132
generic_lufact!(A, pivot; check = check)
133133
function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T);
134134
check::Bool = true) where {T}
135-
LAPACK.chkfinite(A)
135+
check && LAPACK.chkfinite(A)
136136
# Extract values
137137
m, n = size(A)
138138
minmn = min(m,n)

stdlib/LinearAlgebra/test/lu.jl

+7
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,11 @@ end
464464
@test Matrix(F1) Matrix(F2) C
465465
end
466466

467+
@testset "matrix with Nonfinite" begin
468+
lu(fill(NaN, 2, 2), check=false)
469+
lu(fill(Inf, 2, 2), check=false)
470+
LinearAlgebra.generic_lufact!(fill(NaN, 2, 2), check=false)
471+
LinearAlgebra.generic_lufact!(fill(Inf, 2, 2), check=false)
472+
end
473+
467474
end # module TestLU

0 commit comments

Comments
 (0)