Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-227

Log-Euclidean Distance 2x2

Problem

Compute the log-Euclidean distance between two symmetric positive definite 2x2 matrices:

d(A, B) = ||log(A) - log(B)||_F

where log of a SPD matrix is computed from its eigendecomposition (orthonormal eigenvectors).

Hint

Log-Euclidean distances respect the manifold geometry of SPD matrices.

Test cases

case 1
in: [[[2,0],[0,3]],[[2,0],[0,3]]]
expected: 0
case 2
in: [[[1,0],[0,1]],[[2,0],[0,4]]]
expected: 1.5499242141443583
case 3
in: [[[1,0],[0,1]],[[2.718281828459045,0],[0,2.718281828459045]]]
expected: 1.4142135623730951
case 4
in: [[[2,1],[1,2]],[[3,1],[1,3]]]
expected: 0.7504758415354572
Starter codePython
def log_euclidean_distance_2x2(A, B):
    # Your code here
    pass

4 test cases · run your code against them in the editor