The orthogonal Procrustes problem
#求解线性方程组
import cv2
import numpy as np
N = 10
A = np.random.rand(N, N)
while np.linalg.matrix_rank(A) < N:
A = np.random.rand(N, N)
x = np.random.randn(N, 1)
b = A@x
ok, x_est = cv2.solve(A, b)
print('Solved:', ok)
if ok:
print('Residual:', cv2.norm(b-A@x_est))
print('Relative:', cv2.norm(x_est-x)/cv2.norm(x))