matrix_pinv#

sionna.phy.utils.matrix_pinv(tensor: torch.Tensor) torch.Tensor[source]#

Computes the Moore–Penrose (or pseudo) inverse of a matrix

Given a batch of \(M \times K\) matrices \(\mathbf{A}\) with rank \(K\) (i.e., linearly independent columns), the function returns \(\mathbf{A}^+\), such that \(\mathbf{A}^{+}\mathbf{A}=\mathbf{I}_K\).

The two inner dimensions are assumed to correspond to the matrix rows and columns, respectively.

Parameters:

tensor (torch.Tensor) – […, M, K], torch.float | torch.complex. Input tensor of rank greater than or equal to two.

Outputs:

pinv – […, K, M], torch.float | torch.complex. A tensor containing the matrix pseudo inverse of the last two dimensions of tensor.

Examples

>>> import torch
>>> from sionna.phy.utils.linalg import matrix_pinv
>>> a = torch.randn(4, 2)
>>> matrix_pinv(a).shape
torch.Size([2, 4])