Contents Previous Next Subchapters Current Chapters-> prctile ftail tpdf ttail ittail cnormal inormal rand snormal seed colmad colmse colrange colmode kurtosis skewness randperm ranseed unifm0v1 unirnd normrnd exprnd gamrnd cauchyrnd gumbelrnd laplacernd lognrnd wblrnd binornd poissrnd exppdf expcdf normpdf unifpdf unifcdf wblpdf wblcdf colcor colcov colmean colstd colmax rowmax colsum rowsum colnorm rownorm median colmedian colmead colvar corr conv conv2 sum cumsum prod cumprod Parent Chapters-> Omatrix6 statistics cumsum Search Tools-> contents reference index search

Running Cumulative Sum of Elements of a Matrix
 Syntax `cumsum(`x`)` `cumsum(`x`, `d`)` See Also sum , cumprod , colsum , rowsum , colrange

Description
Returns the cumulative sum of the elements of the matrix x as a matrix with the same type and dimension as x where x is an integer, real, double-precision or complex matrix.

Vectors
If x is a vector, the i-th element of the return value is ```      x  + x  + ... + x       1    2          i ```If you enter ```      x = [ 1, 2, 3 ]      cumsum(x) ``` O-Matrix will respond ```      [ 1 , 3 , 6 ] ``` If you enter ```      x = { 1, 2, 3 }      cumsum(x) ``` O-Matrix will respond ```      {      1      3      6      } ```
Matrices
If x is a matrix, the (i,j)-th element of the return value is ```      x    + x     + ... + x       1,j    2,j           i,j ```If you enter ```      x = { [ 1, 2, 3 ], [3, 4, 5] }      cumsum(x) ``` O-Matrix will respond ```      {      [ 1 , 2 , 3 ]      [ 4 , 6 , 8 ]      } ```
Dimension
If the argument d is present, it specifies which dimension the sum is taken with respect to. It must be an integer, real, or double-precision scalar equal to 1 or 2. If you enter ```      x = { [ 1, 2, 3 ], [3, 4, 5] }      cumsum(x, 2) ``` O-Matrix will respond ```      {      [ 1 , 3 , 6 ]      [ 3 , 7 , 12 ]      } ```