spd_learn.functional.log_euclidean_multiply#

spd_learn.functional.log_euclidean_multiply(x: Tensor, y: Tensor) → Tensor[source]#

Logarithmic multiplication of SPD matrices under the Log-Euclidean metric.

Computes the logarithmic multiplication (denoted \(\odot\) in the literature) of two SPD matrices:

\[X \odot Y = \exp(\log(X) + \log(Y))\]

This operation endows the SPD manifold with a commutative Lie group structure [Arsigny et al., 2007]. The Lie group \((\mathcal{S}_{++}^n, \odot)\) is isomorphic to the additive group of symmetric matrices \((\mathcal{S}^n, +)\) via the matrix logarithm.

The Log-Euclidean framework, introduced by Arsigny et al. (2006, 2007), provides two algebraic structures on SPD matrices:

  1. A Lie group structure via logarithmic multiplication \(\odot\)

  2. A vector space structure by adding logarithmic scalar multiplication \(\circledast\) (see log_euclidean_scalar_multiply())

This operation is useful for implementing geometrically principled residual/skip connections in SPD neural networks [Katsman et al., 2023].

Parameters:
  • x (torch.Tensor) – First SPD tensor with shape (…, n, n).

  • y (torch.Tensor) – Second SPD tensor with shape (…, n, n).

Returns:

Product SPD tensor with shape (…, n, n).

Return type:

torch.Tensor

Notes

The logarithmic multiplication satisfies the following properties:

  • Commutative: \(X \odot Y = Y \odot X\)

  • Associative: \((X \odot Y) \odot Z = X \odot (Y \odot Z)\)

  • Identity element: \(X \odot I = X\) (identity matrix is the neutral element)

  • Inverse: \(X \odot X^{-1} = I\)

  • SPD-preserving: Output is SPD if inputs are SPD

The logarithmic multiplication coincides with standard matrix multiplication when the two matrices commute in the matrix sense.

See also

log_euclidean_scalar_multiply()

Scalar multiplication in Log-Euclidean space.

log_euclidean_geodesic()

Weighted combination (geodesic interpolation).

log_euclidean_mean()

Weighted mean of multiple SPD matrices.

LogEuclideanResidual

Module wrapper for this function.

References

The logarithmic multiplication was introduced by Arsigny et al. [2007] as part of the Log-Euclidean framework. The original papers are:

  • Arsigny, V., Fillard, P., Pennec, X., and Ayache, N. “Log-Euclidean metrics for fast and simple calculus on diffusion tensors.” Magnetic Resonance in Medicine, 56(2):411-421, 2006.

  • Arsigny, V., Fillard, P., Pennec, X., and Ayache, N. “Geometric means in a novel vector space structure on symmetric positive-definite matrices.” SIAM Journal on Matrix Analysis and Applications, 29(1):328-347, 2007.

For applications to residual neural networks on Riemannian manifolds, see Katsman et al. [2023].

Examples

>>> import torch
>>> from spd_learn.functional import log_euclidean_multiply
>>> X = torch.eye(3) * 2
>>> Y = torch.eye(3) * 3
>>> Z = log_euclidean_multiply(X, Y)
>>> # Z = exp(log(2*I) + log(3*I)) = exp(log(6)*I) = 6*I
>>> torch.allclose(Z, torch.eye(3) * 6, atol=1e-5)
True