fork download
  1. import numpy as np
  2.  
  3. mA = np.array([[1, 2, 3],[4, 5, 6],[7, 8, 9]])
  4. mB = np.array([[14, 32, 50],[32, 77, 122],[50, 122, 194]])
  5.  
  6. #transposta
  7. mT = mA.transpose()
  8.  
  9. #multiplica
  10. mR = np.dot(mA, mT)
  11.  
  12. #compara matrizes
  13. if np.array_equal(mR, mB):
  14. print "correto\n"
  15. else:
  16. print "incorreto\n"
  17.  
  18. #apenas para mostrar os valores das matrizes
  19. print "Matriz A"
  20. print mA
  21.  
  22. print "\nMatriz A'"
  23. print mT
  24.  
  25. print "\nMatrizA * MatrizA'"
  26. print mR
  27.  
  28. print "\nMatriz B"
  29. print mB
Success #stdin #stdout 0.02s 83072KB
stdin
Standard input is empty
stdout
correto

Matriz A
[[1 2 3]
 [4 5 6]
 [7 8 9]]

Matriz A'
[[1 4 7]
 [2 5 8]
 [3 6 9]]

MatrizA * MatrizA'
[[ 14  32  50]
 [ 32  77 122]
 [ 50 122 194]]

Matriz B
[[ 14  32  50]
 [ 32  77 122]
 [ 50 122 194]]