cumsum.md (1275B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function cumsum 4 5 Compute the cumulative sum of a matrix or a list with values. 6 In case of a (multi dimensional) array or matrix, the cumulative sums 7 along a specified dimension (defaulting to the first) will be calculated. 8 9 10 ## Syntax 11 12 ```js 13 math.cumsum(a, b, c, ...) 14 math.cumsum(A) 15 ``` 16 17 ### Parameters 18 19 Parameter | Type | Description 20 --------- | ---- | ----------- 21 `args` | ... * | A single matrix or or multiple scalar values 22 23 ### Returns 24 25 Type | Description 26 ---- | ----------- 27 * | The cumulative sum of all values 28 29 30 ### Throws 31 32 Type | Description 33 ---- | ----------- 34 35 36 ## Examples 37 38 ```js 39 math.cumsum(2, 1, 4, 3) // returns [2, 3, 7, 10] 40 math.cumsum([2, 1, 4, 3]) // returns [2, 3, 7, 10] 41 math.cumsum([[1, 2], [3, 4]]) // returns [[1, 2], [4, 6]] 42 math.cumsum([[1, 2], [3, 4]], 0) // returns [[1, 2], [4, 6]] 43 math.cumsum([[1, 2], [3, 4]], 1) // returns [[1, 3], [3, 7]] 44 math.cumsum([[2, 5], [4, 3], [1, 7]]) // returns [[2, 5], [6, 8], [7, 15]] 45 ``` 46 47 48 ## See also 49 50 [mean](mean.md), 51 [median](median.md), 52 [min](min.md), 53 [max](max.md), 54 [prod](prod.md), 55 [std](std.md), 56 [variance](variance.md), 57 [sum](sum.md)