Skip to content

Commit 4ebf3e8

Browse files
Merge pull request #358 from oscardssmith/fix-and-test-undefmatrix
fix and test undef matrix for MArray
2 parents a260a8a + 6d4d997 commit 4ebf3e8

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

.github/workflows/Downstream.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ jobs:
2222
- {user: SciML, repo: DiffEqBase.jl, group: Core}
2323
- {user: SciML, repo: DiffEqBase.jl, group: Downstream}
2424
- {user: SciML, repo: DiffEqBase.jl, group: Downstream2}
25-
- {user: SciML, repo: DiffEqSensitivity.jl, group: Core1}
26-
- {user: SciML, repo: DiffEqSensitivity.jl, group: Core2}
27-
- {user: SciML, repo: DiffEqSensitivity.jl, group: Core3}
28-
- {user: SciML, repo: DiffEqSensitivity.jl, group: Core4}
29-
- {user: SciML, repo: DiffEqSensitivity.jl, group: Core5}
25+
- {user: SciML, repo: SciMLSensitivity.jl, group: Core1}
26+
- {user: SciML, repo: SciMLSensitivity.jl, group: Core2}
27+
- {user: SciML, repo: SciMLSensitivity.jl, group: Core3}
28+
- {user: SciML, repo: SciMLSensitivity.jl, group: Core4}
29+
- {user: SciML, repo: SciMLSensitivity.jl, group: Core5}
3030
- {user: SciML, repo: OrdinaryDiffEq.jl, group: Core}
3131
- {user: SciML, repo: OrdinaryDiffEq.jl, group: Interface}
3232
- {user: SciML, repo: DelayDiffEq.jl, group: Interface}

lib/ArrayInterfaceStaticArraysCore/src/ArrayInterfaceStaticArraysCore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import StaticArraysCore, ArrayInterfaceCore, Adapt
44
using LinearAlgebra
55

66
function ArrayInterfaceCore.undefmatrix(::StaticArraysCore.MArray{S, T, N, L}) where {S, T, N, L}
7-
return MMatrix{L, L, T, L*L}(undef)
7+
return StaticArraysCore.MMatrix{L, L, T, L*L}(undef)
88
end
99
# SArray doesn't have an undef constructor and is going to be small enough that this is fine.
1010
function ArrayInterfaceCore.undefmatrix(s::StaticArraysCore.SArray)

lib/ArrayInterfaceStaticArraysCore/test/runtests.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using StaticArrays, ArrayInterfaceCore, ArrayInterfaceStaticArraysCore, Test
22
using LinearAlgebra
3+
using ArrayInterfaceCore: undefmatrix, zeromatrix
34

45
x = @SVector [1,2,3]
56
@test ArrayInterfaceCore.ismutable(x) == false
@@ -26,4 +27,19 @@ z = rand(4)
2627
zr = ArrayInterfaceCore.restructure(x, z)
2728
@test zr isa SMatrix{2, 2}
2829
@test Base.size(zr) == (2,2)
29-
@test vec(zr) == vec(z)
30+
@test vec(zr) == vec(z)
31+
32+
33+
@testset "zeromatrix and unsafematrix" begin
34+
for T in (Int, Float32, Float64)
35+
for (vectype, mattype) in ((SVector{4,T}, SMatrix{4,4,T,16}),
36+
(MVector{4,T}, MMatrix{4,4,T,16}),
37+
(SMatrix{2,2,T,4}, SMatrix{4,4,T,16}),
38+
(MMatrix{2,2,T,4}, MMatrix{4,4,T,16}))
39+
v = vectype(rand(T, 4))
40+
um = undefmatrix(v)
41+
@test typeof(um) == mattype
42+
@test zeromatrix(v) == zeros(T,length(v),length(v))
43+
end
44+
end
45+
end

0 commit comments

Comments
 (0)