Internal Documentation

Internal Documentation

Contents

Index

Internals

blockindex2global{N}(block_sizes::BlockSizes{N}, block_index::BlockIndex{N}) -> inds

Converts from a block index to a tuple containing the global indices

source
global2blockindex{N}(block_sizes::BlockSizes{N}, inds...) -> BlockIndex{N}

Converts from global indices inds to a BlockIndex.

source
BlockRange(startblock, stopblock)

represents a cartesian range of blocks.

The relationship between Block and BlockRange mimicks the relationship between CartesianIndex and CartesianRange.

source
BlockIndexRange(block, startind:stopind)

represents a cartesian range inside a block.

source
BlockSlice(indices)

Represent an AbstractUnitRange of indices that attaches a block.

Upon calling to_indices(), Blocks are converted to BlockSlice objects to represent the indices over which the Block spans.

This mimics the relationship between Colon and Base.Slice.

source
BlockArrays.unblockFunction.
unblock(block_sizes, inds, I)

Returns the indices associated with a block as a BlockSlice.

source
SubBlockIterator(subcumulsize::Vector{Int}, cumulsize::Vector{Int})
SubBlockIterator(A::AbstractArray, bs::BlockSizes, dim::Integer)

An iterator for iterating BlockIndexRange of the blocks specified by cumulsize. The Block index part of BlockIndexRange is determined by subcumulsize. That is to say, the Block index first specifies one of the block represented by subcumulsize and then the inner-block index range specifies the region within the block. Each such block corresponds to a block specified by cumulsize.

Note that the invariance subcumulsize ⊂ cumulsize must hold and must be ensured by the caller.

Examples

julia> using BlockArrays 

julia> import BlockArrays: SubBlockIterator, BlockIndexRange, cumulsizes

julia> A = BlockArray(1:6, 1:3);

julia> subcumulsize = cumulsizes(A, 1);

julia> @assert subcumulsize == [1, 2, 4, 7]

julia> cumulsize = [1, 2, 4, 5, 7];

julia> for idx in SubBlockIterator(subcumulsize, cumulsize)
           B = @show view(A, idx)
           @assert !(parent(B) isa BlockArray)
           idx :: BlockIndexRange
           idx.block :: Block{1}
           idx.indices :: Tuple{UnitRange}
       end
view(A, idx) = [1]
view(A, idx) = [2, 3]
view(A, idx) = [4]
view(A, idx) = [5, 6]

julia> [idx.block.n[1] for idx in SubBlockIterator(subcumulsize, cumulsize)]
4-element Array{Int64,1}:
 1
 2
 3
 3

julia> [idx.indices[1] for idx in SubBlockIterator(subcumulsize, cumulsize)]
4-element Array{UnitRange{Int64},1}:
 1:1
 1:2
 1:1
 2:3
source