Skip to content

Commit 26ac213

Browse files
Merge pull request #448 from SciML/ap/patch_satest
Patch the Static Arrays tests
2 parents 814adc2 + 80af626 commit 26ac213

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ SciMLOperators = "0.3"
101101
Setfield = "1"
102102
SparseArrays = "1.9"
103103
Sparspak = "0.3.6"
104+
StableRNGs = "1"
104105
StaticArrays = "1.5"
105106
StaticArraysCore = "1.2"
106107
Test = "1"
@@ -129,8 +130,9 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
129130
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
130131
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
131132
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
133+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
132134
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
133135
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
134136

135137
[targets]
136-
test = ["Aqua", "Test", "IterativeSolvers", "InteractiveUtils", "JET", "KrylovKit", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "Enzyme", "FiniteDiff", "BandedMatrices", "FastAlmostBandedMatrices", "StaticArrays", "AllocCheck"]
138+
test = ["Aqua", "Test", "IterativeSolvers", "InteractiveUtils", "JET", "KrylovKit", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "Enzyme", "FiniteDiff", "BandedMatrices", "FastAlmostBandedMatrices", "StaticArrays", "AllocCheck", "StableRNGs"]

src/factorization_sparse.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ function _ldiv!(x::AbstractVector,
1313
SparseArrays.CHOLMOD.Factor}, b::AbstractVector)
1414
x .= A \ b
1515
end
16+
17+
# Ambiguity removal
18+
_ldiv!(::SVector,
19+
A::Union{SparseArrays.CHOLMOD.Factor, LinearAlgebra.QR, LinearAlgebra.QRCompactWY, SparseArrays.SPQR.QRSparse},
20+
b::AbstractVector) = (A \ b)
21+
_ldiv!(::SVector, A::Union{SparseArrays.CHOLMOD.Factor, LinearAlgebra.QR, LinearAlgebra.QRCompactWY, SparseArrays.SPQR.QRSparse},
22+
b::SVector) = (A \ b)

test/static_arrays.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using LinearSolve, StaticArrays, LinearAlgebra, Test
1+
using LinearSolve, StaticArrays, LinearAlgebra, Test, StableRNGs
22
using AllocCheck
33

4-
A = SMatrix{5, 5}(Hermitian(rand(5, 5) + I))
5-
b = SVector{5}(rand(5))
4+
rng = StableRNG(0)
5+
6+
A = SMatrix{5, 5}(Hermitian(rand(rng, 5, 5) + I))
7+
b = SVector{5}(rand(rng, 5))
68

79
@check_allocs __solve_no_alloc(A, b, alg) = solve(LinearProblem(A, b), alg)
810

@@ -27,16 +29,16 @@ for alg in (nothing, LUFactorization(), SVDFactorization(), CholeskyFactorizatio
2729
@test norm(A * sol .- b) < 1e-10
2830
end
2931

30-
A = SMatrix{7, 5}(rand(7, 5))
31-
b = SVector{7}(rand(7))
32+
A = SMatrix{7, 5}(rand(rng, 7, 5))
33+
b = SVector{7}(rand(rng, 7))
3234

3335
for alg in (nothing, SVDFactorization(), KrylovJL_LSMR())
3436
@inferred solve(LinearProblem(A, b), alg)
3537
@test_nowarn solve(LinearProblem(A, b), alg)
3638
end
3739

38-
A = SMatrix{5, 7}(rand(5, 7))
39-
b = SVector{5}(rand(5))
40+
A = SMatrix{5, 7}(rand(rng, 5, 7))
41+
b = SVector{5}(rand(rng, 5))
4042

4143
for alg in (nothing, SVDFactorization(), KrylovJL_LSMR())
4244
@inferred solve(LinearProblem(A, b), alg)

0 commit comments

Comments
 (0)