spd_learn.functional.orthogonal_polar_factor#
- spd_learn.functional.orthogonal_polar_factor(W: Tensor) Tensor[source]#
Compute the orthogonal polar factor of a matrix.
Projects a matrix onto the Stiefel manifold \(\text{St}(n, k)\) via polar decomposition. The orthogonal polar factor is:
\[W_{\perp} = W (W^\top W)^{-1/2}\]This is the unique matrix with orthonormal columns that is closest to \(W\) in Frobenius norm.
- Parameters:
W (torch.Tensor) – Input matrix with shape (…, n, k) where n >= k.
- Returns:
Orthogonal polar factor with shape (…, n, k) satisfying \(W_{\perp}^\top W_{\perp} = I_k\).
- Return type:
Notes
This function uses the matrix inverse square root computed via eigendecomposition for numerical stability.
Examples
>>> import torch >>> from spd_learn.functional import orthogonal_polar_factor >>> W = torch.randn(8, 4) >>> W_orth = orthogonal_polar_factor(W) >>> # Verify orthonormality >>> torch.allclose(W_orth.T @ W_orth, torch.eye(4), atol=1e-5) True
See also
matrix_inv_sqrtMatrix inverse square root.
stiefel_()In-place Stiefel initialization.