Template Function navtk::block_diag(T&&…)

Function Documentation

template<typename ...T>
Matrix navtk::block_diag(T&&... matrices)

Create a block-diagonal matrix from the provided matrices.

Given square matrix inputs A, B and C, the output will have these arrays arranged along the diagonal:

{{A, 0, 0},
 {0, B, 0},
 {0, 0, C}}

Vectors are assumed to be horizontal matrices (single-row), matching the behavior of scipy.linalg.block_diag.

Parameters

matrices – A series of Tensor objects to be arranged.

Returns

A single matrix containing the input matrices arranged diagonally, such that the index of the top-left of a given matrix is (1, 1) plus the index of the bottom-right of the preceding matrix.