Block Diagonal Matrix

class fastmat.BlockDiag

Bases: Matrix

\[M = \mathrm{diag}\left\{\left( A_{i}\right)_{i}\right\},\]

where the \(A_{i}\) can be fast transforms of *any* type.

>>> # import the package
>>> import fastmat as fm
>>>
>>> # define the blocks
>>> A = fm.Circulant(x_A)
>>> B = fm.Circulant(x_B)
>>> C = fm.Fourier(n)
>>> D = fm.Diag(x_D)
>>>
>>> # define the block
>>> # diagonal matrix
>>> M = fm.BlockDiag(A, B, C, D)

Assume we have two circulant matrices \(A\) and \(B\), an \(N\)-dimensional Fourier matrix \(C\) and a diagonal matrix \(D\). Then we define

\[\begin{split}M = \begin{bmatrix} A & & & \\ & B & & \\ & & C & \\ & & & D \end{bmatrix}.\end{split}\]

Meta types can also be nested, so that a block diagonal matrix can contain products of block matrices as its entries. Note that the efficiency of the fast transforms decreases the more building blocks they have.

>>> import fastmat as fm
>>> # import the package
>>>
>>> # define the blocks
>>> A = fm.Circulant(x_A)
>>> B = fm.Circulant(x_B)
>>> F = fm.Fourier(n)
>>> D = fm.Diag(x_D)
>>>
>>> # define a product
>>> P = fm.Product(A.H, B)
>>>
>>> # define the block
>>> # diagonal matrix
>>> M = fm.BlockDiag(P, F, D)

Assume we have a product \(P\) of two matrices \(A^\mathrm{H}\) and \(B\), an \(N\)-dimensional Fourier matrix \({\mathcal{F}}\) and a diagonal matrix \(D\). Then we define

\[\begin{split}M = \begin{bmatrix} A^\mathrm{H} \cdot B & & \\ & {\mathcal{F}} & \\ & & D \end{bmatrix}.\end{split}\]

Todo

  • BlockDiag should simply skip all Zero Matrices (flag them as “None”)?

__init__()

Initialize a BlockDiag matrix instance.

Parameters
*matricesfastmat.Matrix

The matrix instances to be put along the main diagonal of the block diagonal matrix, beginning at index (0, 0) with the first matrix.

**optionsoptional

Additional keyworded arguments. Supports all optional arguments supported by fastmat.Matrix.