api / koma / cumsum

cumsum

fun cumsum(arr:Matrix<Double>):Matrix<Double>

Calculates the cumulative (ongoing) sum of a matrix's elements. For example, cumsum(mat[1,2,3]) would return mat[1,3,6].

@param arr The matrix to calculate the cumsum on. Sum will be computed in row-major order.

@return A 1x(arr.numRows*arr.numCols) vector storing the ongoing cumsum.