spd_learn.functional.distance_thompson#
- spd_learn.functional.distance_thompson(A, B, squared=False)[source]#
Thompson distance between SPD/HPD matrices.
The Thompson 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_2 = \max_i | \log(\lambda_i) |\]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.
- Returns:
d – Thompson distance between A and B.
- Return type:
float or ndarray, shape (…,)
Notes
Added in version 0.10.
Changed in version 0.12: Add support for NumPy and PyTorch.
See also
References
[1]On certain contraction mappings in a partially ordered vector space A.C.Thompson. Proceedings of the American Mathematical Society, 1963.