矩陣相乘
矩陣相乘
Example Code
- import numpy as np
- martixA = np.arange(9).reshape((3,3))
- martixB = np.arange(9).reshape((3,3))
- print('martixA = martixB = ')
- print(martixA)
- print('martixA product martixB = ')
- print(np.matmul(martixA, martixB))
Note and Comments
- import numpy as np: 讀入numpy函式庫並命名為np
- np.arange(l).reshape((m,n)) 生成一個有l個元素的陣列, 並重新將此陣列重新分割爲m*n的矩陣
- np.matmul(martixA, martixB) 矩陣相乘
result