What methods should be defined for a type to be `<:AbstractMatrix`



I want to define a type of block diagonal matrix where the diagonal blocks are the same (usually small, always square) size. If there are k blocks, each of size m×m it seems reasonable to use a length k vector of StaticArrays.MMatrix{m,m} to store such arrays.

What methods should be defined if I want this type to be a subtype of AbstractMatrix?


size(::BlockDiagonal) and getindex(::BlockDiagonal, ::Int, ::Int) are all you need to get started. Everything else is just optimizations. See https://docs.julialang.org/en/stable/manual/interfaces/#man-interface-array-1 for more details.