diff --git a/Project.toml b/Project.toml index 217aed0..dc29985 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArrayLayouts" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" authors = ["Sheehan Olver "] -version = "0.4.10" +version = "0.4.11" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" diff --git a/src/memorylayout.jl b/src/memorylayout.jl index 60a1e1a..0638e48 100644 --- a/src/memorylayout.jl +++ b/src/memorylayout.jl @@ -530,7 +530,12 @@ sublayout(L::AbstractFillLayout, inds::Type) = L reshapedlayout(L::AbstractFillLayout, _) = L adjointlayout(::Type, L::AbstractFillLayout) = L transposelayout(L::AbstractFillLayout) = L +# TODO: Move to FillArrays.jl +_getindex_value(V::SubArray) = getindex_value(parent(V)) +sub_materialize(::AbstractFillLayout, V, ax) = Fill(_getindex_value(V), ax) +sub_materialize(::ZerosLayout, V, ax) = Zeros(ax) +sub_materialize(::OnesLayout, V, ax) = Ones(ax) abstract type AbstractBandedLayout <: MemoryLayout end abstract type AbstractTridiagonalLayout <: AbstractBandedLayout end diff --git a/test/test_layouts.jl b/test/test_layouts.jl index 2b88627..8e76e11 100644 --- a/test/test_layouts.jl +++ b/test/test_layouts.jl @@ -294,6 +294,10 @@ struct FooNumber <: Number end @test MemoryLayout(Fill(1+0im,10)') == DualLayout{FillLayout}() @test MemoryLayout(Adjoint(Fill(1+0im,10,2))) == FillLayout() @test MemoryLayout(Transpose(Fill(1+0im,10,2))) == FillLayout() + + @test layout_getindex(Fill(1,10), 1:3) ≡ Fill(1,3) + @test layout_getindex(Ones(1,10), 1, 1:3) ≡ Ones(3) + @test layout_getindex(Zeros(5,10,12), 1, 1:3,4:6) ≡ Zeros(3,3) end @testset "Triangular col/rowsupport" begin