Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - Português


cumsum

somas cumulativas parciais dos elementos de uma matriz

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)
y = cumsum(x, orientation)
y = cumsum(.., outtype)

Parâmetros

x

vetor ou matriz de booleanos, inteiros, números reais ou complexos, polinômios ou frações racionais. Hipermatrizes ou matrizes booleanas ou numéricas esparsas também são suportadas.

"r", "c", 1, 2,.. orientation

This argument can be

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

  • positive integer 1 ≤ orientation ≤ ndims(x): the index of the dimension along which the partial cumulative sums must be computed. 1 and "r", and 2 and "c", are equivalent.

outtype

Word "native" or "double".

y

Array de tamanho igual ao de x.

Descrição

y = cumsum(x) calcula e fornece o parcial somas cumulativas y(i) = sum(x(1:i)) :

y(i) = ∑u=1→i x(u)

y = cumsum(x, orientation) retorna retorna o parcial somas cumulativas de x ao longo da dimensão dada pela orientation :

  • Se orientation for igual a 1 ou "r", então

    y(i,j) = ∑u=1→i x(u,j), ou para uma matriz N-Dimensional :

    y(i,j,k,…) = ∑u=1→i x(u,j,k,…)

  • Se orientation for igual a 2 ou "c", então

    y(i,j) = ∑u=1→j x(i,u), ou para uma matriz N-Dimensional :

    y(i,j,k,…) = ∑u=1→j x(i,u,k,…)

  • Se orientation for igual a n, então

    y(i₁,…,iₙ₋₁, iₙ,iₙ₊₁,…) = ∑u=1…iₙ  x(i₁,…,iₙ₋₁, u,iₙ₊₁,…)

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

  • y = cumsum(x,"m") is equivalent to y = cumsum(x, orientation) where orientation is the index of the first dimension of x that is greater than 1. This option is used for Matlab compatibility.

The outtype argument rules the way the summations are 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".

When the input x is sparse, please keep in mind that the density of the result y will be almost always close to 100%.

Exemplos

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)

Ver Também

  • sum — soma (soma linha, soma coluna) de entradas de um vetor ou matriz
  • cumprod — produto cumulativo
Report an issue
<< cumprod Matrix operations kron .*. >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:16:51 CEST 2024