Advertisement
wagner-cipriano

Multiplicação de matrizes com numpy

Dec 11th, 2020
1,448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. #Multiplicação de matrizes com numpy:
  2. import numpy as np
  3.  
  4. m1 = np.matrix('1 1; 0 1')
  5. m2 = np.matrix('2 0; 3 4')
  6.  
  7. #elementwise product
  8. m1 * m2
  9.  
  10.  
  11. #Construção da matriz com arrays:
  12. m1 = np.array( [[1,1], [0,1]] )
  13. m2 = np.array( [[2,0], [3,4]] )
  14.  
  15. #matrix product
  16. np.dot(m1, m2)
  17. np.matmul(m1, m2)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement