cumsum2

Syntax

cumsum2(X)

Arguments

X is a scalar, vector or matrix

Details

If X is a vector, calculate the cumulative sum of squares of X and return a vector of the same length as X.

If X is a matrix, conduct the aforementioned calculation within each column of X. The result is a matrix with the same shape as X.

Examples

$ x=[2,3,4];
$ cumsum2 x;
[4,13,29]

$ m=matrix(1 2 3, 4 5 6);
$ m;

#0

#1

1

16

5

41

14

77

Related function: cumsum