# Cumulated sum of elements of each column of a matrix: cumSum

### 5.45.5 Cumulated sum of elements of each column of a matrix: cumSum

The cumSum command finds the cumulated sum of each column of a matrix (see also Section 5.40.27).

- cumSum takes one argument:
  A, a matrix.
- cumSum(A) returns the matrix whose columns are the cumulated sum of the elements of the corresponding column of the matrix A.

#### Example.

Input:

cumSum([[1,2],[3,4],[5,6]])

Output:

⎡
⎢
⎢
⎣

1 | 2
4 | 6
9 | 12

⎤
⎥
⎥
⎦

since the cumulated sums of the first column are: 1, 1+3=4, 1+3+5=9 and the accumulated sums of the second column are: 2, 2+4=6, 2+4+6=12.