<< cumprod Matrix operations kron .*. >>

Scilab Help >> Elementary Functions > Matrix operations > cumsum

cumsum

cumulative sum of array elements

Syntax

y=cumsum(x)
y=cumsum(x,orientation)
y=cumsum(x,outtype)
y=cumsum(x,orientation,outtype)

Arguments

x

an array of reals, complex, booleans, polynomials or rational fractions.

orientation

This argument can be

  • either a string with possible values "*", "r", "c" or "m"

  • or a number with positive integer value

outtype

a string with possible values "native" or "double".

y

scalar or array

Description

Returns the cumulative sum of array elements. For an array x, y=cumsum(x) a matrix y of the same size as x. The value y(i) is the sum of all elements of x(1:i) i.e.:

y=cumsum(x,orientation) returns in y the cumulative sum of x along the dimension given by orientation:

The outtype argument rules the way the summation is done:

This function applies, with identical rules to sparse matrices.

Examples

A=[1,2;3,4];
cumsum(A)
cumsum(A,1)

I=uint8([2 95 103;254 9 0])
cumsum(I) //native evaluation
cumsum(I,"double")
cumsum(I,2,"double")

s=poly(0,"s");
P=[s,%i+s;s^2,1];
cumsum(P),
cumsum(P,2)

B=[%t %t %f %f];
cumsum(B) //evaluation in float
cumsum(B,"native") //similar to or(B)

See also


Report an issue
<< cumprod Matrix operations kron .*. >>