Skip to content

Commit 4a5efd7

Browse files
authored
layout_getindex now works with Fill (#46)
* layout_getindex now works with Fill * Update memorylayout.jl
1 parent c6ef01e commit 4a5efd7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.4.10"
4+
version = "0.4.11"
55

66
[deps]
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/memorylayout.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,12 @@ sublayout(L::AbstractFillLayout, inds::Type) = L
530530
reshapedlayout(L::AbstractFillLayout, _) = L
531531
adjointlayout(::Type, L::AbstractFillLayout) = L
532532
transposelayout(L::AbstractFillLayout) = L
533+
# TODO: Move to FillArrays.jl
534+
_getindex_value(V::SubArray) = getindex_value(parent(V))
533535

536+
sub_materialize(::AbstractFillLayout, V, ax) = Fill(_getindex_value(V), ax)
537+
sub_materialize(::ZerosLayout, V, ax) = Zeros(ax)
538+
sub_materialize(::OnesLayout, V, ax) = Ones(ax)
534539

535540
abstract type AbstractBandedLayout <: MemoryLayout end
536541
abstract type AbstractTridiagonalLayout <: AbstractBandedLayout end

test/test_layouts.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ struct FooNumber <: Number end
294294
@test MemoryLayout(Fill(1+0im,10)') == DualLayout{FillLayout}()
295295
@test MemoryLayout(Adjoint(Fill(1+0im,10,2))) == FillLayout()
296296
@test MemoryLayout(Transpose(Fill(1+0im,10,2))) == FillLayout()
297+
298+
@test layout_getindex(Fill(1,10), 1:3) Fill(1,3)
299+
@test layout_getindex(Ones(1,10), 1, 1:3) Ones(3)
300+
@test layout_getindex(Zeros(5,10,12), 1, 1:3,4:6) Zeros(3,3)
297301
end
298302

299303
@testset "Triangular col/rowsupport" begin

0 commit comments

Comments
 (0)