数据挖掘 numpy进阶之线性代数
简单数组运算 参考numpy文件夹中的linalg.py获得更多信息。 import numpy import numpy.linalg as linalg a = numpy.array([ [1, 2], [3, 4] ], dtype=float) print("a: \n", a) print("a的转置: \n", a.transpose()) print("a的你矩阵: \n", linalg.inv(a)) u = numpy.eye(2) # 2×2单位矩阵, eye = I print("单位矩阵u: \n", u) print("u的迹: \n", numpy.trace(u)) j = numpy.array([ [0, -1], [1, 0] ], dtype=float) print("j: \n", j) print("j×j: \n", numpy.dot(j, j)) # 矩阵积 y = numpy.array([ [5], [7] ], dtype=float) print("y: \n", y) print("线性方程求解: \n", linalg.solve(a, y)) print("特征向量求解: \n", linalg.eig(j)) "E:\Python 3.6.2\python.exe" F:/PycharmProjects/test