2020-08-03
阅读量:
1026
如何使用Numpy的乘法计算?
使用Numpy的乘法也称为向量化,其主要目的是减少或消除程序中的for循环的显式使用,通过该向量计算变得更快。
Numpy是python中用于数组处理和操作的包中的内置。对于更大的矩阵操作,我们使用numpy python包,它比迭代的一个方法快1000倍。
# We need install numpy in order to import it
import numpy as np
# input two matrices
mat1 = ([1, 6, 5],[3 ,4, 8],[2, 12, 3])
mat2 = ([3, 4, 6],[5, 6, 7],[6,56, 7])
# This will return dot product
res = np.dot(mat1,mat2)
# print resulted matrix
print(res)
输出:
[[63 320 83]
[77 484 102]
[84 248 117]]






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
3条评论