Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-270

Procrustes Rotation via SVD

Problem

Given U and V from the SVD of the cross-covariance M = U*S*V^T, return the optimal orthogonal Procrustes rotation:

R = U * diag(1, det(U*V^T)) * V^T

The determinant correction guarantees det(R) = 1, ruling out reflections.

Hint

Without the determinant correction, the SVD solution could be a reflection.

Test cases

case 1
in: [[[1,0],[0,1]],[[1,0],[0,1]]]
expected: [[1,0],[0,1]]
case 2
in: [[[1,0],[0,1]],[[0,-1],[1,0]]]
expected: [[0,1],[-1,0]]
case 3
in: [[[1,0],[0,1]],[[1,0],[0,-1]]]
expected: [[1,0],[0,1]]
case 4
in: [[[0,1],[1,0]],[[0,1],[1,0]]]
expected: [[1,0],[0,1]]
Starter codePython
def procrustes_rotation(U, V):
    # Your code here
    pass

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