本文主要是介绍【python】numpy库计算矩阵特征值和特征向量,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
0.环境
1.前提
2.全部代码
0.环境
windows + eclipse + python
1.前提
我的邻接矩阵是固定的,11*11
2.全部代码
要将邻接矩阵使用numpy赋值
#计算矩阵特征值
import numpy as np
A = np.array([[0,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,1,1], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0],[1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0]])
eig_values, eig_vectors = np.linalg.eig(A)print("特征值:", eig_values)
print("特征向量:", eig_vectors)
输出结果
--END--
这篇关于【python】numpy库计算矩阵特征值和特征向量的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!