python Library
testNumpyMatrix
Keine Erläuterungen gefunden.
import numpy as np x = np.ones(3) M = np.zeros((2,3)) M[0,0] = 1 M[0,1] = 2 M[1,0] = 3 M[1,1] = 4 N = np.matrix([[1, 2, 0], [3, 4, 0]]) z1 = np.matrix( [1.0, 1.0, 1.0] ) z2 = np.matrix([[1.0], [1.0], [1.0]]) #number of elements in matrix: print("size, No of entries:",M.size) #number of elements in matrix: print("shape M:",M.shape) print("shape N:",N.shape) NoRows, NoCols = M.shape for i in range(NoRows): for j in range(NoCols): print("M",i,j, M[i,j], "\t N",i,j, N[i,j]) #print("N",i,j, N[i,j]) y1 = np.dot(M, x) print("y1:", y1) y2 = N * z1.T print("y2:", y2) y3 = N * z2 print("y3:", y3)
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.