Advertisement
furas

Ręczne transponowanie macierzy

Dec 17th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3. #------------------------------------
  4.  
  5. def macierz_transponowana(A):
  6.  
  7.    m, n = A.shape
  8.  
  9.    B = np.empty([n,m], dtype=int)
  10.  
  11.    for i in range(0,n):
  12.       for j in range(0,m):
  13.          B[i][j]=A[j][i]
  14.  
  15.    return B
  16.  
  17. #------------------------------------
  18.  
  19. m = np.random.randint(1,10)
  20. n = np.random.randint(1,10)
  21.  
  22. X = np.random.randint(0,10,(m,n))
  23.  
  24. print X
  25.  
  26. Y = macierz_transponowana(X)
  27.  
  28. print Y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement