Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make extension depend on StaticArrays and optimize lu_instance #449

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"

[extensions]
Expand All @@ -27,7 +27,7 @@ ArrayInterfaceChainRulesExt = "ChainRules"
ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore"
ArrayInterfaceReverseDiffExt = "ReverseDiff"
ArrayInterfaceSparseArraysExt = "SparseArrays"
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
ArrayInterfaceStaticArraysExt = "StaticArrays"
ArrayInterfaceTrackerExt = "Tracker"

[compat]
Expand Down Expand Up @@ -66,4 +66,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"

[targets]
test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "StaticArraysCore", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays"]
test = ["SafeTestsets", "Pkg", "Test", "Aqua", "Random", "SparseArrays", "SuiteSparse", "BandedMatrices", "BlockBandedMatrices", "GPUArraysCore", "StaticArrays", "Tracker", "ReverseDiff", "ChainRules", "FillArrays", "ComponentArrays"]
30 changes: 0 additions & 30 deletions ext/ArrayInterfaceStaticArraysCoreExt.jl

This file was deleted.

34 changes: 34 additions & 0 deletions ext/ArrayInterfaceStaticArraysExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module ArrayInterfaceStaticArraysExt

import ArrayInterface
using LinearAlgebra
import StaticArrays: SArray, SMatrix, SVector, StaticMatrix, StaticArray, SizedArray, MArray, MMatrix, LU

function ArrayInterface.undefmatrix(::MArray{S, T, N, L}) where {S, T, N, L}
return MMatrix{L, L, T, L*L}(undef)
end
# SArray doesn't have an undef constructor and is going to be small enough that this is fine.
function ArrayInterface.undefmatrix(s::SArray)
v = vec(s)
return v.*v'
end

ArrayInterface.ismutable(::Type{<:StaticArray}) = false
ArrayInterface.ismutable(::Type{<:MArray}) = true
ArrayInterface.ismutable(::Type{<:SizedArray}) = true

Check warning on line 18 in ext/ArrayInterfaceStaticArraysExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/ArrayInterfaceStaticArraysExt.jl#L18

Added line #L18 was not covered by tests

ArrayInterface.can_setindex(::Type{<:StaticArray}) = false
ArrayInterface.can_setindex(::Type{<:MArray}) = true
ArrayInterface.buffer(A::Union{SArray, MArray}) = getfield(A, :data)

function ArrayInterface.lu_instance(A::SMatrix{N,N}) where {N}
LU(LowerTriangular(A), UpperTriangular(A), SVector{N}(1:N))
end

function ArrayInterface.lu_instance(A::StaticMatrix{N,N}) where {N}
lu(one(A))
end

ArrayInterface.restructure(x::SArray{S}, y) where {S} = SArray{S}(y)

end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
@time @safetestset "BlockBandedMatrices" begin include("blockbandedmatrices.jl") end
@time @safetestset "Core" begin include("core.jl") end
@time @safetestset "AD Integration" begin include("ad.jl") end
@time @safetestset "StaticArraysCore" begin include("staticarrayscore.jl") end
@time @safetestset "StaticArrays" begin include("staticarrays.jl") end
@time @safetestset "ChainRules" begin include("chainrules.jl") end
end

Expand Down
File renamed without changes.
Loading