cumsum soma cumulativa

## Seqüência de Chamamento

    y=cumsum(x)
                y=cumsum(x,'r') or y=cumsum(x,1)
                y=cumsum(x,'c') or y=cumsum(x,2)

## Parâmetros

x

  vetor ou matrix (de reais ou complexos)

y

  vetor ou matrix (de reais ou complexos)

## Descrição

Para um vetor ou uma matriz

x
, `y=cumsum(x)` retorna em
y
a soma cumulativa de todas as entradas de
x
tomadas coluna a coluna.

y(i) = \sum_{k=1}^i x(k)

`y=cumsum(x,'r')` (ou, equivalentemente, `y=cumsum(x,1)`) retorna em `y` a soma cumulativa das linhas de

x
: `y(:,i)=cumsum(x(:,i))`

y(\mathbf{l},j) = \sum_{\mathbf{i}=1}^l x(\mathbf{i},j)

or

y(\mathbf{l},j,k,\ldots) = \sum_{\mathbf{i}=1}^l x(\mathbf{i},j,k,\ldots)

`y=cumsum(x,'c')` (ou, equivalentemente, `y=cumsum(x,2)`) retorna em

y
a soma cumulativa das colunas de
x
: `y(i,:)=cumsum(x(i,:))`

y(i,\mathbf{l}) = \sum_{\mathbf{j}=1}^l x(i,{\mathbf{j})

or

y(i,\mathbf{l},k,\ldots) = \sum_{\mathbf{j}=1}^l x(i,\mathbf{j},k,\ldots)

if

orientation
is equal to n then:

y(i_1,\ldots,i_{n-1},\mathbf{l},i_{n+1},\ldots) = \sum_{\mathbf{i_n}=1}^l x(i_1,\ldots,i_{n-1},\mathbf{i_n},i_{n+1},\ldots)

`y=cumsum(x,"*")` is equivalent to `y=cumsum(x)`

`y=cumsum(x,'m')` é a soma cumulativa ao longo da primeira dimensão "não-singleton" de

x
(para compatibilidade com o Matlab).

The

outtype
argument rules the way the summation is done:

- For arrays of floats, of polynomials, of rational fractions, the evaluation is always done using floating points computations. The `"double"` or `"native"` options are equivalent.

- For arrays of integers,

  if `outtype="native"` the evaluation is done using integer computations (modulo 2^b, where b is the number of bits used),

  if `outtype="double"` the evaluation is done using floating point computations.

  The default value is `outtype="native"`.

- For arrays of booleans,

  if `outtype="native"` the evaluation is done using boolean computations ( + is replaced by |),

  if `outtype="double"` the evaluation is done using floating point computations (%t values are replaced by 1 and %f values by 0).

  The default value is `outtype="double"`.

This function applies, with identical rules to sparse matrices.

## Exemplos

    A=[1,2;3,4];
    cumsum(A)
    cumsum(A,'r')
    cumsum(A,'c')
    a=rand(3,4)+%i;
    [m,n]=size(a);
    w=zeros(a);
    w(1,:)=a(1,:);
    for k=2:m;w(k,:)=w(k-1,:)+a(k,:);end;w-cumsum(a,'r')

## Ver Também

- cumprod
- sum