Python| numpy matrix.prod()
借助Numpy matrix.prod()
方法,我们可以从给定矩阵中获得同一轴上所有元素的累积乘积。
Syntax : matrix.prod(axis)
Return : Return product from given matrix
示例 #1:
在这个例子中,我们可以看到我们能够借助方法matrix.prod()
从给定矩阵中获得同一轴上所有元素的乘积。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg = np.matrix('[64, 1; 12, 3]')
# applying matrix.prod() method
geeks = gfg.prod(1)
print(geeks)
输出:
[[64]
[36]]
示例 #2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, -9]')
# applying matrix.prod() method
geeks = gfg.prod(0)
print(geeks)
输出:
[[ 28 80 -162]]