-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
It's sometimes useful to have multiple layers of blocks, see conversation in
I think one way to do this would be to support some sort of BlockView
that converts an AbstractBlockVector{T}
into an AbstractVector{Vector{T}}
:
struct BlockView{AT, p, BA <: AbstractBlockArray} <: AbstractArray{AT, p}
data::BA
end
_BlockView(data::BA) where BA<:AbstractBlockArray{T,p} where T = BlockView{Array{T,p},p,BA}(data)
getindex(A::BlockView, i...) = A[Block(i...)]
size(A::BlockView) = nblocks(A)
Then one create a hierarchical block array view (here we have sub-blocks of length 10 and super-blocks of length 5):
A_sub = PseudoBlockArray(randn(10*5*n), fill(10,5n))
A = PseudoBlockArray(BlockView(A_sub), fill(5,n))
A[Block(2)][3] # returns the 3rd sub-block of the 2nd super-block
I'm still working out how to get it to work with A[Block(2)][Block(3)]
...
schneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels