Numpy dot()

dot()返回数组的点积

示例代码:

常数:两数相乘

In [2]: a = 2                                                                   

In [3]: b = 3                                                                   

In [4]: np.dot(a, b)                                                            
Out[4]: 6

一维数组:向量点积

In [5]: a = [2, 3]                                                              

In [6]: b = [3, 4]                                                              

In [7]: np.dot(a, b)                                                            
Out[7]: 18

复数:向量点积

In [8]: a = [2j, 3j]                                                            

In [9]: b = [3j, 2j]                                                            

In [10]: np.dot(a, b)                                                           
Out[10]: (-12+0j)

二维数组:矩阵乘法,即矩阵积

In [12]: a = [[1, 2], [2, 3]]                                                   

In [13]: b = [[2, 3], [3, 4]]                                                   

In [14]: np.dot(a ,b)                                                           
Out[14]: 
array([[ 8, 11],
       [13, 18]])

参考:
[1] https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html

你可能感兴趣的:(Numpy,numpy,python)