+ 2

How can i impliment matrix multiplication using the numpy library in python?

I created a numpy array on my program and I want to perform matrix multiplication/dot product on the array. Can someone help me ASAP?

14th Oct 2018, 8:25 AM
Renz Frederick Bañas
Renz Frederick Bañas - avatar
3 Antworten
+ 5
You can use the @ operator or the matmul function. (Python 3.5 or higher) import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([[5, 6], [7, 8]]) print(a @ b) # OR print(np.matmul(a, b)) Output: [[19, 22], [43, 50]] For older versions of Python, you could do a.dot(b), but @ is the recommended way.
14th Oct 2018, 9:23 AM
Kishalaya Saha
Kishalaya Saha - avatar
0
Use special methods
14th Oct 2018, 8:45 PM
Martin Tembo
Martin Tembo - avatar
0
Use special methods
14th Oct 2018, 8:45 PM
Martin Tembo
Martin Tembo - avatar