spd_learn.functional.log_cholesky_distance#
- spd_learn.functional.log_cholesky_distance(A, B)[source]#
Compute the distance in the Log-Cholesky metric.
The Log-Cholesky distance between two SPD matrices \(A\) and \(B\) is the Frobenius norm of the difference of their Log-Cholesky representations:
\[d_{LC}(A, B) = \|\log_{\text{chol}}(L_A) - \log_{\text{chol}}(L_B)\|_F\]where \(A = L_A L_A^T\) and \(B = L_B L_B^T\) are the Cholesky decompositions.
- Parameters:
A (torch.Tensor) – SPD matrices of shape (…, n, n).
B (torch.Tensor) – SPD matrices of shape (…, n, n). Must be broadcastable with A.
- Returns:
Distances of shape (…) (batch dimensions).
- Return type:
Notes
This metric is computationally cheaper than the affine-invariant Riemannian metric (AIRM) since it avoids eigendecomposition. The complexity is \(O(n^3/3)\) for the Cholesky decomposition.
The Log-Cholesky distance is not affine-invariant, but it is invariant under lower triangular transformations with positive diagonal [Lin, 2019].
See also
log_cholesky_mean()Fréchet mean under Log-Cholesky metric.
log_cholesky_geodesic()Geodesic interpolation under Log-Cholesky metric.
airm_distance()Distance under AIRM.
log_euclidean_distance()Distance under Log-Euclidean metric.
bures_wasserstein_distance()Distance under Bures-Wasserstein metric.
Examples
>>> import torch >>> A = torch.eye(3) >>> B = 2 * torch.eye(3) >>> dist = log_cholesky_distance(A, B) >>> print(f"Distance: {dist.item():.4f}") Distance: 1.2012