spd_learn.functional.log_euclidean_distance#

spd_learn.functional.log_euclidean_distance(A, B)[source]#

Computes the Log-Euclidean distance between SPD matrices.

The Log-Euclidean Metric (LEM) simplifies computations by using the matrix logarithm to map the SPD manifold diffeomorphically to the Euclidean vector space of symmetric matrices. The mapping \(\log: \mathcal{S}_{++}^n \to \mathcal{S}^n\) is a global diffeomorphism.

The Log-Euclidean distance is defined as the Frobenius norm of the difference of the matrix logarithms:

\[d_{\text{LEM}}(A, B) = \| \log(A) - \log(B) \|_F\]

This metric endows SPD matrices with a commutative Lie group structure, where the group operation is \(A \odot B = \exp(\log(A) + \log(B))\).

Parameters:
  • A (torch.Tensor) – SPD matrices with shape (…, n, n).

  • B (torch.Tensor) – SPD matrices with shape (…, n, n). Must be broadcastable with A.

Returns:

Distances with shape (…).

Return type:

torch.Tensor

Notes

Unlike the Affine-Invariant Riemannian Metric (AIRM), the Log-Euclidean metric is not affine-invariant. It is invariant only under orthogonal transformations (rotations): \(d(QAQ^\top, QBQ^\top) = d(A, B)\) for orthogonal \(Q\). However, it offers computational advantages as all operations reduce to standard Euclidean operations in the log-domain.

See also

airm_distance()

Distance under affine-invariant metric.

bures_wasserstein_distance()

Distance under Bures-Wasserstein metric.

log_cholesky_distance()

Distance under Log-Cholesky metric.

log_euclidean_mean()

Computes the weighted mean under Log-Euclidean metric.

References

See [Arsigny et al., 2007] for more details.