I need to construct a matrix of this form:

where `A1, A2, ..., A_M`

are given (rectangular) matrices, and the zeros are blocks of appropriate sizes.

How can I do this in Julia, with as less code as possible? Maybe there is a package I can use?

There is the function `SparseArrays.blockdiag`

which does something close, but only works for sparse arrays. The matrices I have are not sparse.

A generalization of this is to construct block tridiagonal matrices (https://en.wikipedia.org/wiki/Block_matrix#Block_tridiagonal_matrices). But I havenβt found any packages for this.