Internal Documentation

Contents

Index

Internals

BlockArrays.blockcolsupportFunction
blockcolsupport(A, j)

Return an iterator containing the possible non-zero blocks in the j-th block-column of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
2×3-blocked 3×3 BlockMatrix{Int64}:
 1  │  4  │  7
 ───┼─────┼───
 2  │  5  │  8
 3  │  6  │  9

julia> BlockArrays.blockcolsupport(B, 2) |> collect
2-element Vector{Block{1, Int64}}:
 Block(1)
 Block(2)
BlockArrays.blockrowsupportFunction
blockrowsupport(A, k)

Return an iterator containing the possible non-zero blocks in the k-th block-row of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
2×3-blocked 3×3 BlockMatrix{Int64}:
 1  │  4  │  7
 ───┼─────┼───
 2  │  5  │  8
 3  │  6  │  9

julia> BlockArrays.blockrowsupport(B, 2) |> collect
3-element Vector{Block{1, Int64}}:
 Block(1)
 Block(2)
 Block(3)
BlockArrays.BlockedUnitRangeType
BlockedUnitRange

is an AbstractUnitRange{Int} that has been divided into blocks, and is used to represent axes of block arrays. Construction is typically via blockedrange which converts a vector of block lengths to a BlockedUnitRange.

Examples

julia> blockedrange([2,2,3])
3-blocked 7-element BlockedUnitRange{Vector{Int64}}:
 1
 2
 ─
 3
 4
 ─
 5
 6
 7
BlockArrays.BlockRangeType
BlockRange(axes::Tuple{AbstractUnitRange{Int}})
BlockRange(sizes::Vararg{Integer})

Represent a Cartesian range of blocks.

The relationship between Block and BlockRange mimics the relationship between CartesianIndex and CartesianIndices.

Examples

julia> BlockRange(2:3, 3:4) |> collect
2×2 Matrix{Block{2, Int64}}:
 Block(2, 3)  Block(2, 4)
 Block(3, 3)  Block(3, 4)

julia> BlockRange(2, 2) |> collect # number of elements, starting at 1
2×2 Matrix{Block{2, Int64}}:
 Block(1, 1)  Block(1, 2)
 Block(2, 1)  Block(2, 2)

julia> Block(1):Block(2)
BlockRange(1:2)
BlockArrays.BlockSliceType
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.

BlockArrays.unblockFunction
unblock(block_sizes, inds, I)

Returns the indices associated with a block as a BlockSlice.

BlockArrays.SubBlockIteratorType
SubBlockIterator(subblock_lasts::Vector{Int}, block_lasts::Vector{Int})
SubBlockIterator(A::AbstractArray, bs::NTuple{N,AbstractUnitRange{Int}} where N, dim::Integer)

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

Note that the invariance subblock_lasts ⊂ block_lasts must hold and must be ensured by the caller.

Examples

julia> using BlockArrays

julia> import BlockArrays: SubBlockIterator, BlockIndexRange

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

julia> subblock_lasts = axes(A, 1).lasts;

julia> @assert subblock_lasts == [1, 3, 6];

julia> block_lasts = [1, 3, 4, 6];

julia> for idx in SubBlockIterator(subblock_lasts, block_lasts)
           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:1
view(A, idx) = 2:3
view(A, idx) = 4:4
view(A, idx) = 5:6

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

julia> [idx.indices[1] for idx in SubBlockIterator(subblock_lasts, block_lasts)]
4-element Vector{UnitRange{Int64}}:
 1:1
 1:2
 1:1
 2:3
BlockArrays.blockcheckbounds_indicesFunction
blockcheckbounds_indices(Bool, IA::Tuple{Vararg{BlockRange{1}}}, I::Tuple{Vararg{Integer}})

Return true if the "requested" indices in the tuple Block.(I) fall within the bounds of the "permitted" indices specified by the tuple IA. This function recursively consumes elements of these tuples in a 1-for-1 fashion.

The actual bounds-checking is performed by blockcheckindex.

Examples

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

julia> blockaxes(B)
(BlockRange(Base.OneTo(3)), BlockRange(Base.OneTo(3)))

julia> BlockArrays.blockcheckbounds_indices(Bool, blockaxes(B), (1,2))
true

julia> BlockArrays.blockcheckbounds_indices(Bool, blockaxes(B), (4,1))
false
BlockArrays.blockcheckindexFunction
blockcheckindex(Bool, inds::BlockRange{1}, index::Integer)

Return true if Block(index) is within the bounds of inds.

Examples

julia> BlockArrays.blockcheckindex(Bool, BlockRange(1:2), 1)
true

julia> BlockArrays.blockcheckindex(Bool, BlockRange(1:2), 3)
false