From d69b1a228b4e0ac834c47a674725f0b08bd2da0e Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 12 Jun 2023 10:26:22 -0400 Subject: [PATCH] Add check call to getrf! (#50134) * Add check call to getrf! `lu!(A; check=false)` is supposed to disable the checking and leave it to the user: > When check = true, an error is thrown if the decomposition fails. When check = false, responsibility for checking the decomposition's validity (via issuccess) lies with the user. However, this is not quite true since `lu!` calls `getrf!` which internally does a check for `chkfinite` which does throw an error. This updates the `getrf!` function to have a `check` argument which is then used by `lu!` to fully disable the error throwing checks. * Update lapack.jl --- stdlib/LinearAlgebra/src/lapack.jl | 4 ++-- stdlib/LinearAlgebra/src/lu.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/LinearAlgebra/src/lapack.jl b/stdlib/LinearAlgebra/src/lapack.jl index 066a858cacb30..6353f9fa8d266 100644 --- a/stdlib/LinearAlgebra/src/lapack.jl +++ b/stdlib/LinearAlgebra/src/lapack.jl @@ -554,9 +554,9 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty # * .. Array Arguments .. # INTEGER IPIV( * ) # DOUBLE PRECISION A( LDA, * ) - function getrf!(A::AbstractMatrix{$elty}) + function getrf!(A::AbstractMatrix{$elty}; check = true) require_one_based_indexing(A) - chkfinite(A) + check && chkfinite(A) chkstride1(A) m, n = size(A) lda = max(1,stride(A, 2)) diff --git a/stdlib/LinearAlgebra/src/lu.jl b/stdlib/LinearAlgebra/src/lu.jl index a93803ca2ea45..5d69090f27e44 100644 --- a/stdlib/LinearAlgebra/src/lu.jl +++ b/stdlib/LinearAlgebra/src/lu.jl @@ -79,7 +79,7 @@ transpose(F::LU{<:Real}) = TransposeFactorization(F) # the following method is meant to catch calls to lu!(A::LAPACKArray) without a pivoting stategy lu!(A::StridedMatrix{<:BlasFloat}; check::Bool = true) = lu!(A, RowMaximum(); check=check) function lu!(A::StridedMatrix{T}, ::RowMaximum; check::Bool = true) where {T<:BlasFloat} - lpt = LAPACK.getrf!(A) + lpt = LAPACK.getrf!(A; check) check && checknonsingular(lpt[3]) return LU{T,typeof(lpt[1]),typeof(lpt[2])}(lpt[1], lpt[2], lpt[3]) end