累积连乘

王朝百科·作者佚名  2010-10-30  
宽屏版  字体: |||超大  

累积连乘(cumprod )

矩阵的运算

matlab中的算法描述如下:

B = cumprod(A) returns the cumulative product along different dimensions of an array.

If A is a vector, cumprod(A) returns a vector containing the cumulative product of the elements of A.

If A is a matrix, cumprod(A) returns a matrix the same size as A containing the cumulative products for each column of A.

If A is a multidimensional array, cumprod(A) works on the first nonsingleton dimension.

B = cumprod(A,dim) returns the cumulative product of the elements along the dimension of A specified by scalar dim. For example,

cumprod(A,1) increments the first (row) index, thus working along the rows of A.

中文翻译如下:

B = cumprod(A)返回数组不同程度的累积连乘的结果。

如果A是一个向量,将返回一个包含A各元素累积连乘的结果的向量,元素个数与原向量相同。

如果A是一个矩阵,将返回一个和A同样大小的,包含A每一列向量累积连乘的结果的矩阵。

如果A是一个多为向量,cumprod(A)只对第一个nonsingleton(sorry,不认识也查不到)的维度上有效。

matlab中给出的例子如下:

输入:cumprod(1:5)

返回:ans =

1 2 6 24 120

输入:A = [1 2 3; 4 5 6];

cumprod(A)

返回:ans =

1 2 3

4 10 18

再输入:cumprod(A,2)

返回:ans =

1 2 6

4 20 120

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有