spd_learn.functional.parallel_transport_airm#

spd_learn.functional.parallel_transport_airm(v, p, q)[source]#

Parallel transport of tangent vector under the Affine-Invariant metric.

Transports a tangent vector \(V \in T_P \mathcal{M}\) from the tangent space at \(P\) to the tangent space at \(Q\) along the geodesic connecting them, using the Affine-Invariant Riemannian Metric (AIRM) [Pennec et al., 2006].

Transport Formula

The transport is given by:

\[\Gamma_{P \rightarrow Q}(V) = E V E^T\]

where \(E = (Q P^{-1})^{1/2}\) is the principal square root of \(Q P^{-1}\).

Mathematical Derivation

The matrix \(Q P^{-1}\) is generally non-symmetric (even when \(P\) and \(Q\) are SPD), so computing its principal square root requires care. The principal square root is defined as the unique matrix \(E\) such that:

  1. \(E^2 = Q P^{-1}\)

  2. All eigenvalues of \(E\) have positive real parts

Numerically Stable Formula

We compute \(E\) using the equivalent stable formula:

\[E = Q^{1/2} (Q^{-1/2} P Q^{-1/2})^{-1/2} Q^{-1/2}\]

This formula avoids computing \(P^{-1}\) directly and uses only symmetric matrix square roots. To verify this is correct:

\[\begin{split}E^2 &= Q^{1/2} (Q^{-1/2} P Q^{-1/2})^{-1/2} Q^{-1/2} \cdot Q^{1/2} (Q^{-1/2} P Q^{-1/2})^{-1/2} Q^{-1/2} \\ &= Q^{1/2} (Q^{-1/2} P Q^{-1/2})^{-1} Q^{-1/2} \\ &= Q^{1/2} Q^{1/2} P^{-1} Q^{1/2} Q^{-1/2} \\ &= Q P^{-1}\end{split}\]
Parameters:
  • v (torch.Tensor) – Tangent vector at p, shape (…, n, n). Must be symmetric.

  • p (torch.Tensor) – Source point on SPD manifold, shape (…, n, n).

  • q (torch.Tensor) – Target point on SPD manifold, shape (…, n, n).

Returns:

Transported tangent vector at q, shape (…, n, n).

Return type:

torch.Tensor

Examples

>>> import torch
>>> from spd_learn.functional import parallel_transport_airm
>>> # Create random SPD matrices
>>> n = 3
>>> A = torch.randn(n, n)
>>> p = A @ A.T + torch.eye(n)
>>> B = torch.randn(n, n)
>>> q = B @ B.T + torch.eye(n)
>>> # Create a tangent vector at p (symmetric matrix)
>>> v = torch.randn(n, n)
>>> v = (v + v.T) / 2
>>> # Transport v from T_P to T_Q
>>> v_transported = parallel_transport_airm(v, p, q)

Notes

Isometry Property

Parallel transport preserves the AIRM inner product:

\[\langle \Gamma(U), \Gamma(V) \rangle_Q = \langle U, V \rangle_P\]

where \(\langle U, V \rangle_P = \text{tr}(P^{-1} U P^{-1} V)\).

Gradient Support

This function supports full gradient computation through all inputs (v, p, q). Gradients flow correctly for use in optimization when learning reference points.

References

See also

parallel_transport_lem()

Parallel transport under Log-Euclidean metric.

schild_ladder()

Numerical approximation via Schild’s ladder.

pole_ladder()

Numerical approximation via pole ladder.

airm_geodesic()

Geodesic under AIRM.

airm_distance()

Distance under AIRM.

SPDBatchNormMeanVar

Uses parallel transport for centering.