2.1.24.4.32 ocmath_i_cumulative_sum


Description

Computes the cummulative sum of the data.

Syntax

uint ocmath_i_cumulative_sum( const int * pData, uint i1, uint i2, int * pCumSum, const int * pMissing = NULL )

Parameters

pData
[input] pointer to data array
i1
[input] start data index
i2
[input] end data index
pCumSum
[output] contains every step's cummulative sum result of pData from i1 to i2-1
pMissing
[input] missing value, only for type BYTE and float, the missing values of type int and double are defined in function body.

Return

number of missing value, missing value is -999

Examples

EX1

void ocmath_i_cumulative_sum_ex1()
{
    vector<int> vecData = {1,2,3,4,5,6,7,9,10,0};
    uint i1 = 0;
    uint i2 = vecData.GetSize();
    vector<int> vecCumSum;
    vecCumSum.SetSize(i2-i1);
    uint numMissing = ocmath_i_cumulative_sum(vecData,i1,i2,vecCumSum);
}

Remark

compute the cummulative sum data of pData from i1 to i2-1,

and record every step's result in pCumSum.

Data type is int. pCumSum[0] = pData[0],

If pData[ii] = pMissing, pSumCum[ii] = pSumCum[ii-1],

else pSumCum[ii] = pSumCum[ii-1]+pData[ii].

Data types supported:

double: ocmath_d_cumulative_sum
float: ocmath_f_cumulative_sum
unsigned short: ocmath_us_cumulative_sum
unsigned int: ocmath_i_cumulative_sum
unsigned char: ocmath_b_cumulative_sum

See Also

ocmath_d_cumulative_sum, ocmath_f_cumulative_sum, ocmath_us_cumulative_sum, ocmath_b_cumulative_sum

Header to Include

origin.h

Reference