Python| numpy matrix.cumprod()
在Numpy matrix.cumprod()
方法的帮助下,我们能够找到给定矩阵的cumulative product
,并将输出作为一维矩阵。
Syntax : matrix.cumprod()
Return : Return cumulative product of matrix
示例 #1:
在这个例子中,我们可以看到在matrix.cumprod()
方法的帮助下,我们能够找到给定矩阵的累积乘积。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg = np.matrix('[6, 2, 3]')
# applying matrix.cumprod() method
geeks = gfg.cumprod()
print(geeks)
输出:
[[ 6 12 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]')
# applying matrix.cumprod() method
geeks = gfg.cumprod()
print(geeks)
输出:
[[ 1 2 6 24 120 720]]