cumsum

Details

Cumulatively calculate the sum of the elements in X.

Note:
DolphinDB's cumsum function works the same as NumPy's numpy.cumsum, except that it only accepts a single parameter, X, and does not support parameters like axis, dtype, or out in numpy.cumsum.

Similar to NumPy's numpy.cumsum, but DolphinDB's cumsum accumulates along columns by default for matrices (equivalent to numpy.cumsum with axis=0), and only accepts one parameter X without support for the axis, dtype, or out parameters available in numpy.cumsum.

Returns

LONG/DOUBLE type, with the same data form as X.

Examples

x=[2,3,4];
cumsum(x);
// output: [2,5,9]

m=matrix(1 2 3, 4 5 6);
m;
#0 #1
1 4
2 5
3 6
cumsum(m);
#0 #1
1 4
3 9
6 15

Related functions: cumsum2, cumsum3, cumsum4