import numpy as np
np.random.seed(0)
# Create a unitary matrix U
M = np.random.rand(3,3)
U, _ = np.linalg.qr(M)
# Find the indices of the largest element in each column (in absolute value)
largest_indices = np.argmax(np.abs(U), axis=0)
# Sort the indices based on the values in descending order
sorted_indices = np.argsort(largest_indices)
# Reorder the columns of U based on the sorted indices
U_out = U[:, sorted_indices]
print(f'U = \n {U}')
print(f'U_out = \n {U_out}')
也许您可以尝试下面的例子(但正如我在评论中所说,您不能总是保证所有列的最大绝对值都可以沿对角线排列)。
你会看到
U
你可以通过以下方式验证的幺正性这表明