Posts

Showing posts with the label list of list

exp(A), A is a matrix

Programe is: # # Calculate A**n, A is a matrix,  n is an integer #                 A has maximum 15 rows and 15 columns # AA =  [[1,2,3,4],       [2,3,4,5],       [3,4,5,6],       [4,5,6,7]] AAA = [[2,2],       [2,2]] BB =  [[1,1,1,1],       [1,1,1,1],       [1,1,1,1],       [2,2,2,2]] NN_row = 4 NN_column = 4 def product_AB(A, B, N_row, N_column):     C =  [[1,1,1,1],       [1,1,1,1],       [1,1,1,1],       [2,2,2,2]]    # C = [[0]*N_row]*N_column     for i in range(N_row):         for j in range(N_column):             C[i][j]=0             for k in range(N_column):                 C[i][j] += A[i][k]*B[k][j]     retur...