Fork me on GitHub

 这个函数在的数字信号处理中用处还是比较广泛的,函数的具体定义如下所示:

numpy.dot(a, b, out=None)

  该函数的作用是获取两个元素a,b的乘积,表示的含义如下所示:

dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])

  使用方法如下所示:

单个数:

>>> np.dot(3, 4)
12

复数:

>>> np.dot([2j, 3j], [2j, 3j])
(-13+0j)

二维矩阵:

>>> a = [[1, 0], [0, 1]]
>>> b = [[4, 1], [2, 2]]
>>> np.dot(a, b)
array([[4, 1],
       [2, 2]])

 

>>> a = np.arange(3*4*5*6).reshape((3,4,5,6))
>>> b = np.arange(3*4*5*6)[::-1].reshape((5,4,6,3))
>>> np.dot(a, b)[2,3,2,1,2,2]
499128
>>> sum(a[2,3,2,:] * b[1,2,:,2])
499128

  参考文档:

1 https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html

posted on 2018-10-15 19:02  虚生  阅读(8932)  评论(0编辑  收藏  举报