From 5dfc85c3a329e2663bd29ab351d42b2518b4bad2 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 25 Feb 2024 09:27:52 -0800 Subject: [PATCH] Try and fix ambiguity? --- src/common.jl | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/common.jl b/src/common.jl index 0d1e419ff..a53741411 100644 --- a/src/common.jl +++ b/src/common.jl @@ -206,7 +206,29 @@ function SciMLBase.solve(prob::StaticLinearProblem, args...; kwargs...) end function SciMLBase.solve(prob::StaticLinearProblem, - alg::Union{Nothing, SciMLLinearSolveAlgorithm}, args...; kwargs...) + alg::Nothing, args...; kwargs...) + if alg === nothing || alg isa DirectLdiv! + u = prob.A \ prob.b + elseif alg isa LUFactorization + u = lu(prob.A) \ prob.b + elseif alg isa QRFactorization + u = qr(prob.A) \ prob.b + elseif alg isa CholeskyFactorization + u = cholesky(prob.A) \ prob.b + elseif alg isa NormalCholeskyFactorization + u = cholesky(Symmetric(prob.A' * prob.A)) \ (prob.A' * prob.b) + elseif alg isa SVDFactorization + u = svd(prob.A) \ prob.b + else + # Slower Path but handles all cases + cache = init(prob, alg, args...; kwargs...) + return solve!(cache) + end + return SciMLBase.build_linear_solution(alg, u, nothing, prob) +end + +function SciMLBase.solve(prob::StaticLinearProblem, + alg::SciMLLinearSolveAlgorithm, args...; kwargs...) if alg === nothing || alg isa DirectLdiv! u = prob.A \ prob.b elseif alg isa LUFactorization