Diagonal Block Matrix¶
- class fastmat.DiagBlocks¶
Bases:
Matrix
For given \(n,m \in \mathbb{N}\) this class allows to define a block matrix \(M \in \mathbb{C}^{nm \times nm}\), where each block is a diagonal matrix \(D_{ij} \in \mathbb{C}^{m \times m}\). This obviously allows efficient storage and computations.
>>> # import the package >>> import fastmat as fm >>> # define the sizes >>> n,m = 2, >>> # define the diagonals >>> d = np.random.randn( >>> n, >>> n, >>> m) >>> # define the block >>> # matrix diagonal-wise >>> M = fm.DiagBlocks(d)
We have randomly drawn the defining elements \(d\) from a standard Gaussian distribution, which results in
\[\begin{split}M = \begin{bmatrix} d_{1,1,1} & & & d_{1,2,1} & & \\ & d_{1,1,2} & & & d_{1,2,2} & \\ & & d_{1,1,3} & & & d_{1,2,3} \\ d_{2,1,1} & & & d_{2,2,1} & & \\ & d_{2,1,2} & & & d_{2,2,2} & \\ & & d_{2,1,3} & & & d_{2,2,3} \\ \end{bmatrix}.\end{split}\]- __init__()¶
Initialize DiagBlocks matrix instance.
- Parameters
- tenDiags
numpy.ndarray
The generating 3d-array of the flattened diagonal tensor this matrix describes. The matrix data type is determined by the data type of this array.
- **optionsoptional
Additional keyworded arguments. Supports all optional arguments supported by
fastmat.Matrix
.
- tenDiags