📜  Numpy ndarray.dot()函数| Python

📅  最后修改于: 2022-05-13 01:55:16.750000             🧑  作者: Mango

Numpy ndarray.dot()函数| Python

numpy.ndarray.dot()函数返回两个数组的点积。

代码#1:

# Python program explaining
# numpy.ndarray.dot() function
  
# importing numpy as geek 
import numpy as geek
  
arr1 = geek.eye(3)
arr = geek.ones((3, 3)) * 3
  
gfg = arr1.dot( arr )
  
print( gfg)

输出 :

[[ 3.  3.  3.]
 [ 3.  3.  3.]
 [ 3.  3.  3.]]


代码#2:

# Python program explaining
# numpy.ndarray.dot() function
  
# importing numpy as geek 
import numpy as geek
  
arr1 = geek.eye(3)
arr = geek.ones((3, 3)) * 3
  
gfg = arr1.dot(arr).dot(arr)
  
print( gfg)

输出 :

[[ 27.  27.  27.]
 [ 27.  27.  27.]
 [ 27.  27.  27.]]