📜  Python| numpy matrix.cumprod()

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

Python| numpy matrix.cumprod()

Numpy matrix.cumprod()方法的帮助下,我们能够找到给定矩阵的cumulative product ,并将输出作为一维矩阵。

示例 #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]]