The AbstractBlockArray interface

The AbstractBlockArray interface

In order to follow the AbstractBlockArray the following methods should be implemented:

Methods to implementBrief description
nblocks(A)Tuple of number of blocks in each dimension
nblocks(A, i)Number of blocks in dimension i
blocksize(A, i...)Size of the block at block index i...
getblock(A, i...)X[Block(i...)], blocked indexing
setblock!(A, v, i...)X[Block(i...)] = v, blocked index assignment
Optional methods
getblock!(x, A, i)X[i], blocked index assignment with in place storage in x

For a more thorough description of the methods see the public interface documentation.

With the methods above implemented the following are automatically provided:

julia> A = BlockArray(rand(4, 5), [1,3], [2,3])
2×2-blocked 4×5 BlockArrays.BlockArray{Float64,2,Array{Float64,2}}:
0.61179   0.965631  │  0.696476   0.392796  0.712462
--------------------┼-------------------------------
0.620099  0.364706  │  0.0311643  0.27895   0.73477
0.215712  0.923602  │  0.279944   0.994497  0.383706
0.569955  0.754047  │  0.0190392  0.548297  0.687052
julia> blockcheckbounds(A, 5, 3)
ERROR: BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockArrays.BlockArray{Float64,2,Array{Float64,2}} at block index [5,3]