import numpy as np import torch as torch # 0 1 0 1 1 # 1 0 1 0 0 # 0 1 0 0 1 #
1 0 0 0 1 # 1 0 1 1 0 x=np.array([[0 ,1 ,0 ,1, 1], [1 ,0, 1, 0, 0],[0, 1, 0, 0,
1],[1, 0, 0, 0, 1],[1, 0, 1, 1, 0]]) # a = torch.tensor([[1,2,3],[4,5,6]]) a,b
= np.linalg.eig(x) for i in range (len(a)): print('特征值,',a[i],'对应的特征向量',b[:,i])
特征值, 2.4811943040920177 对应的特征向量 [-0.5298991 -0.35775124 -0.35775124
-0.42713229 -0.5298991 ]
特征值, -2.0000000000000018 对应的特征向量 [-5.00000000e-01 5.00000000e-01
-5.00000000e-01 1.62803112e-16
5.00000000e-01]
特征值, -1.170086486626034 对应的特征向量 [-0.43248663 0.19929465 0.19929465
0.73923874 -0.43248663]
特征值, 1.5260202360125897e-17 对应的特征向量 [ 5.00000000e-01 5.00000000e-01
-5.00000000e-01 2.79154475e-16
-5.00000000e-01]
特征值, 0.6888921825340182 对应的特征向量 [ 0.1793384 -0.57645095 -0.57645095
0.52065737 0.1793384 ]