spd_learn.functional.distance_riemann#
- spd_learn.functional.distance_riemann(A, B, squared=False)[source]#
Affine-invariant Riemannian distance between SPD/HPD matrices.
The affine-invariant Riemannian distance between two SPD/HPD matrices \(\mathbf{A}\) and \(\mathbf{B}\) is [1]:
\[d(\mathbf{A},\mathbf{B}) = \Vert \log(\mathbf{B}^{-1/2} \mathbf{A} \mathbf{B}^{-1/2}) \Vert_F = {\left( \sum_i \log(\lambda_i)^2 \right)}^{1/2}\]where \(\lambda_i\) are the joint eigenvalues of \(\mathbf{A}\) and \(\mathbf{B}\).
- Parameters:
A (ndarray, shape (..., n, n)) – First SPD/HPD matrices.
B (ndarray, shape (..., n, n)) – Second SPD/HPD matrices, same dimensions as A.
squared (bool, default=False) –
Return squared distance.
Added in version 0.5.
- Returns:
d – Affine-invariant Riemannian distance between A and B.
- Return type:
float or ndarray, shape (…,)
Notes
Changed in version 0.12: Add support for NumPy and PyTorch.
See also
References
[1]A metric for covariance matrices W. Förstner & B. Moonen. Geodesy-the Challenge of the 3rd Millennium, 2003