Python| numpy matrix.dot()
在Numpy matrix.dot()
方法的帮助下,我们能够找到两个给定矩阵的product
,并将输出作为新的维度矩阵。
Syntax : matrix.dot()
Return : Return product of two matrix
示例 #1:
在这个例子中,我们可以看到在matrix.dot()
方法的帮助下,我们能够找到两个给定矩阵的乘积。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg1 = np.matrix('[6, 2, 3]')
gfg2 = np.matrix('[4; 5; 9]')
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
print(geeks)
输出:
[[61]]
示例 #2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg1 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
gfg2 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
print(geeks)
输出:
[[ 30 36 42]
[ 66 81 96]
[102 126 150]]