diff --git a/Project.toml b/Project.toml index 5f8f811ee..207955ffd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "LinearSolve" uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" -version = "3.86.1" +version = "3.86.2" authors = ["SciML"] [deps] diff --git a/test/Core/sized_matrix.jl b/test/Core/sized_matrix.jl new file mode 100644 index 000000000..5200b8cda --- /dev/null +++ b/test/Core/sized_matrix.jl @@ -0,0 +1,27 @@ +using LinearSolve, StaticArrays, RecursiveFactorization, LinearAlgebra, Test + +# A `SizedMatrix` (StaticArrays) is an in-place, dense matrix whose +# `ArrayInterface.lu_instance` returns a `StaticArrays.LU` (fields `L`/`U`/`p`), +# not a `LinearAlgebra.LU`. `init_cacheval` for `GenericLUFactorization` / +# `RFLUFactorization` must not assume `lu_instance` yields a `LinearAlgebra.LU` +# and reach for its `factors`/`info` fields. Regression for +# SciML/LinearSolve.jl#1056: `init` used to throw +# `type StaticArrays.LU has no field factors`, which broke the downstream +# OrdinaryDiffEq "Sized Matrix Tests" (`Rodas4` over a `SizedMatrix` state, whose +# default solver initializes the `GenericLU`/`RFLU` cachevals). + +A = SizedMatrix{9, 9}(rand(9, 9) + 9I) +b = SizedVector{9}(rand(9)) + +# `init` is where `init_cacheval` runs; this is the call that used to throw. +@testset "init does not assume LinearAlgebra.LU for $(typeof(alg))" for alg in ( + LinearSolve.GenericLUFactorization(), LinearSolve.RFLUFactorization(), + ) + @test init(LinearProblem(A, b), alg) isa LinearSolve.LinearCache +end + +@testset "default init/solve LinearProblem(SizedMatrix)" begin + cache = init(LinearProblem(A, b)) + sol = solve!(cache) + @test sol.retcode == ReturnCode.Success +end diff --git a/test/runtests.jl b/test/runtests.jl index 118343b96..bfd9cdfb9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -70,6 +70,7 @@ else @time @safetestset "Nonstructural Zeros" include("Core/nonstructural_zeros.jl") @time @safetestset "Default Alg Tests" include("Core/default_algs.jl") @time @safetestset "FixedSizeArrays" include("Core/fixedsizearrays.jl") + @time @safetestset "SizedMatrix" include("Core/sized_matrix.jl") @time @safetestset "Adjoint Sensitivity" include("Core/adjoint.jl") @time @safetestset "ForwardDiff Overloads" include("Core/forwarddiff_overloads.jl") @time @safetestset "Traits" include("Core/traits.jl")