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.
Note
This is a Cholesky-based fast path for tall or square matrices with full column rank, not a rank-revealing general pseudoinverse. Factorization errors are deliberately not checked because doing so synchronizes CUDA execution and prevents CUDA graph capture. Results are undefined for rank-deficient or otherwise invalid inputs.
- 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])