Skip to content

Commit 005caa9

Browse files
Keep static failure solutions cache-free
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 6487e3d commit 005caa9

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/common.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ function SciMLBase.solve(
775775
# with the (zero-)initialized `u` instead of throwing.
776776
u = prob.u0 !== nothing ? prob.u0 : __init_u0_from_Ab(prob.A, prob.b)
777777
return SciMLBase.build_linear_solution(
778-
alg, u, nothing, prob; retcode = ReturnCode.Failure
778+
alg, u, nothing, nothing; retcode = ReturnCode.Failure
779779
)
780780
end
781781
u = F \ prob.b
@@ -790,7 +790,7 @@ function SciMLBase.solve(
790790
if !gesv_ok
791791
u = prob.u0 !== nothing ? prob.u0 : __init_u0_from_Ab(prob.A, prob.b)
792792
return SciMLBase.build_linear_solution(
793-
alg, u, nothing, prob; retcode = ReturnCode.Failure
793+
alg, u, nothing, nothing; retcode = ReturnCode.Failure
794794
)
795795
end
796796
elseif alg isa QRFactorization

test/Core/lightweight_solution.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LinearSolve, LinearAlgebra, SparseArrays, StableRNGs, Test
1+
using LinearSolve, LinearAlgebra, SparseArrays, StableRNGs, StaticArrays, Test
22

33
# LinearSolve 5.0: `solve!`/`solve` return a lightweight `LinearSolution` that
44
# no longer carries the `LinearCache` (`sol.cache === nothing`). Anyone who
@@ -49,6 +49,14 @@ rng = StableRNG(7)
4949
# also returns a cache-free solution
5050
sol = solve!(init(LinearProblem(copy(Asing), copy(b)), nothing; verbose = false))
5151
@test sol.cache === nothing
52+
53+
Astatic = @SMatrix [1.0 1.0; 1.0 1.0]
54+
bstatic = @SVector [1.0, 1.0]
55+
for alg in (LUFactorization(), GESVFactorization())
56+
sol = solve(LinearProblem(Astatic, bstatic), alg)
57+
@test sol.retcode == ReturnCode.Failure
58+
@test sol.cache === nothing
59+
end
5260
end
5361

5462
@testset "warm aliased refactorize+solve loop is allocation-free" begin

0 commit comments

Comments
 (0)