Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle LU failure and Symmetric QR #494

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LinearSolve"
uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
authors = ["SciML"]
version = "2.29.0"
version = "2.29.1"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
24 changes: 23 additions & 1 deletion src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
fact = lu(A, check = false)
end
cache.cacheval = fact

if !LinearAlgebra.issuccess(fact)
return SciMLBase.build_linear_solution(

Check warning on line 98 in src/factorization.jl

View check run for this annotation

Codecov / codecov/patch

src/factorization.jl#L98

Added line #L98 was not covered by tests
alg, cache.u, nothing, cache; retcode = ReturnCode.Failure)
end

cache.isfresh = false
end

Expand Down Expand Up @@ -187,7 +193,11 @@
A = convert(AbstractMatrix, A)
if ArrayInterface.can_setindex(typeof(A))
if alg.inplace && !(A isa SparseMatrixCSC) && !(A isa GPUArraysCore.AnyGPUArray)
fact = qr!(A, alg.pivot)
if A isa Symmetric
fact = qr(A, alg.pivot)

Check warning on line 197 in src/factorization.jl

View check run for this annotation

Codecov / codecov/patch

src/factorization.jl#L197

Added line #L197 was not covered by tests
else
fact = qr!(A, alg.pivot)
end
else
fact = qr(A) # CUDA.jl does not allow other args!
end
Expand All @@ -203,6 +213,12 @@
ArrayInterface.qr_instance(convert(AbstractMatrix, A), alg.pivot)
end

function init_cacheval(alg::QRFactorization, A::Symmetric, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
return qr(convert(AbstractMatrix, A), alg.pivot)
end

const PREALLOCATED_QR_ColumnNorm = ArrayInterface.qr_instance(rand(1, 1), ColumnNorm())

function init_cacheval(alg::QRFactorization{ColumnNorm}, A::Matrix{Float64}, b, u, Pl, Pr,
Expand Down Expand Up @@ -1023,6 +1039,12 @@
end
fact = RecursiveFactorization.lu!(A, ipiv, Val(P), Val(T), check = false)
cache.cacheval = (fact, ipiv)

if !LinearAlgebra.issuccess(fact)
return SciMLBase.build_linear_solution(

Check warning on line 1044 in src/factorization.jl

View check run for this annotation

Codecov / codecov/patch

src/factorization.jl#L1044

Added line #L1044 was not covered by tests
alg, cache.u, nothing, cache; retcode = ReturnCode.Failure)
end

cache.isfresh = false
end
y = ldiv!(cache.u, @get_cacheval(cache, :RFLUFactorization)[1], cache.b)
Expand Down
Loading