Algosim documentation: MatFromBlocks

MatFromBlocks

Creates a block matrix by specifying its blocks.

Syntax

Description

If n is a positive integer and A, B, ... a sequence of matrices, then MatFromBlocks(n, A, B, ...) returns the block matrix consisting of the blocks A, B, ... in row-major with n block columns.

The matrices must be of compatible sizes. The number of matrices need not be a multiple of n; the last block row of the result will be filled with zero blocks if trailing blocks are missing. The number of block rows in the result is #'(A, B, ...)/n.

Examples

A ≔ ❨❨1, 2❩, ❨3, 4❩❩; B ≔ ❨❨5, 1, 3❩, ❨1, 0, 2❩❩; C ≔ ❨❨5, 1❩, ❨0, 1❩❩; D ≔ ❨❨5, 1, 2❩, ❨5, 6 ,7❩❩;
MatFromBlocks(2, A, B, C, D)
⎛1  2  5  1  3⎞
⎜3  4  1  0  2⎟
⎜5  1  5  1  2⎟
⎝0  1  5  6  7⎠
MatFromBlocks(2, A, B, C)
⎛1  2  5  1  3⎞
⎜3  4  1  0  2⎟
⎜5  1  0  0  0⎟
⎝0  1  0  0  0⎠
MatFromBlocks(2, A, B)
⎛1  2  5  1  3⎞
⎝3  4  1  0  2⎠

See also