a = np.array([[1,2,3],[4,5,6],[7,8,9]])
b = np.array([[1,4,7],[2,5,8],[3,6,9]])
# 创建一个以a的行为行,b的列为列的矩阵
num_add = np.zeros((a.shape[0],b.shape[1]))
for i in range(a.shape[0]):
for j in range(b.shape[1]):
for h in range(a.shape[1]):
num_add[i][j] = num_add[i][j] +a[i][h] * b[h][j]
print(num_add)
不用numpy,实现矩阵连乘
最新推荐文章于 2024-05-06 19:19:55 发布