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,ji,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 ]
}