Matrix assignment
>>> x1=np.arange(0,5) # array([0, 1, 2, 3, 4])>>> x2=np.arange(1,6) # array([1, 2, 3, 4, 5])>>> x3=np.linspace(0,5,6) # array([ 0., 1., 2., 3., 4., 5.])
Matrix transpose
>>> Transpose (x2.reshape () # If the dimension is not changed, the returned value is still array ([1, 2, 3, 4, 5]) array ([1], [2], [3], [4], [5])
Matrix Multiplication
#[0, 1, 2, 3, 4] x [1, 2, 3, 4, 5]‘>>> dot(x1.reshape(1,5),transpose(x2.reshape(1,5)))array([[40]])
Matrix Inversion
>>> linalg.inv([[1,2],[3,4]])array([[-2. , 1. ], [ 1.5, -0.5]])
File Access
>>> A = NP. arange () >>>. shape = 3, 4> aarray ([0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]) >>>. tofile (". bin ") >>> B = NP. fromfile (". bin ", dtype = NP. float) # Read data by float type> B # The data read is an incorrect array ([2.12199579e-314, 6.36598737e-314, 1.06099790e-313, 1.4854255e-313, 1.90979621e-313, 2.33419537e-313])>. dtype # view dtypedtype ('int32 ')> B = NP. fromfile (". bin ", dtype = NP. int32) # Read data according to the int32 type >>> B # The data is a one-dimensional array ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])> B. shape = 3, 4 # modify the shape of B according to the shape of a> B # This time, array ([0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11])
Numpy matrix operation