From 1c71fda0cbc868dcb0db5c73d9088f7c8f3a247c Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Wed, 12 Jul 2023 15:25:32 -0400 Subject: [PATCH 1/3] only check that values are finite when check=true --- stdlib/LinearAlgebra/src/lu.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/lu.jl b/stdlib/LinearAlgebra/src/lu.jl index 5d69090f27e44..f45386fa7649c 100644 --- a/stdlib/LinearAlgebra/src/lu.jl +++ b/stdlib/LinearAlgebra/src/lu.jl @@ -133,7 +133,7 @@ lu!(A::AbstractMatrix, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype generic_lufact!(A, pivot; check = check) function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T); check::Bool = true) where {T} - LAPACK.chkfinite(A) + check && LAPACK.chkfinite(A) # Extract values m, n = size(A) minmn = min(m,n) From bfbff0f3a467e6aae4ec24113ed9dd4c04faee28 Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Wed, 12 Jul 2023 15:33:25 -0400 Subject: [PATCH 2/3] add tests --- stdlib/LinearAlgebra/test/lu.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/LinearAlgebra/test/lu.jl b/stdlib/LinearAlgebra/test/lu.jl index aa73bee6ddc38..d414ab0be953d 100644 --- a/stdlib/LinearAlgebra/test/lu.jl +++ b/stdlib/LinearAlgebra/test/lu.jl @@ -464,4 +464,11 @@ end @test Matrix(F1) ≈ Matrix(F2) ≈ C end +@testset "matrix with Nonfinite" + lu(fill(NaN, 2, 2), check=false) + lu(fill(Inf, 2, 2), check=false) + LinearAlgebra.generic_lufact!(fill(NaN, 2, 2), check=false) + LinearAlgebra.generic_lufact!(fill(Inf, 2, 2), check=false) +end + end # module TestLU From 6ef6a0ceb9de0af289eb4d302733d627fb6bd7d8 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Wed, 12 Jul 2023 16:45:31 -0400 Subject: [PATCH 3/3] typo --- stdlib/LinearAlgebra/test/lu.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/test/lu.jl b/stdlib/LinearAlgebra/test/lu.jl index d414ab0be953d..25a75e13233f0 100644 --- a/stdlib/LinearAlgebra/test/lu.jl +++ b/stdlib/LinearAlgebra/test/lu.jl @@ -464,7 +464,7 @@ end @test Matrix(F1) ≈ Matrix(F2) ≈ C end -@testset "matrix with Nonfinite" +@testset "matrix with Nonfinite" begin lu(fill(NaN, 2, 2), check=false) lu(fill(Inf, 2, 2), check=false) LinearAlgebra.generic_lufact!(fill(NaN, 2, 2), check=false)