0 0        numpy计算矩阵的一些函数用法

2013-11-04
 import numpy as npa = np.matrix([ [1, 2, 3, 4],                        [5, 5, 6, 8],                       [7, 9, 9, 1],                       [4, 6, 7, 1]                      ])#矩阵加减法：e = a + a#ore = a - a#矩阵乘法:b = a * a            #not matrix multiplication!#orc = np.dot(a, a)          #matrix multiplication#ord = anp.dot(a, a, d)          #matrix multiplication#转置矩阵(transpose)g = a.transpose()#orh = a.T               #not matrix transpose!#逆矩阵(inverse)#The inverse of a matrix A is the matrix B such that AB=I where I is the identity matrix consisting of ones down the main diagonal. Usually B is denoted B=A-1 . #In SciPy, the matrix inverse of the Numpy array, A, is obtained using linalg.inv (A) , or using A.I f = np.linalg.inv(a)#orf = a ** (-1)#orf = a.I#行列式(determinant)j = np.linalg.det(a)#伴随矩阵(adjoint)#(need more test)m = np.dot(np.linalg.det(a), np.linalg.inv(a)) # A-1 = A'' / |A|  ==>   A''= A-1|A|  #矩阵范数(matrix norms)k = np.linalg.norms(a)

0条评论