ocmath_us_cumulative_sum

 

Contents

Description

Calculate the cumulative sum of the data.

Syntax

uint ocmath_us_cumulative_sum( const USHORT * pData, uint i1, uint i2, USHORT * pCumSum, const USHORT * 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] pointer to missing value

Return

number of missing value

Examples

EX1

void ocmath_us_cumulative_sum_ex1()
{
    vector<ushort> vecData = {1,2,3,4,5,6,7,9,10,0};
    uint i1 = 0;
    uint i2 = vecData.GetSize();
    vector<ushort> vecCumSum;
    vecCumSum.SetSize(i2-i1);
    uint numMissing = ocmath_us_cumulative_sum(vecData,i1,i2,vecCumSum);
    printf("%d", numMissing);
}

Remark

Calculate the cumulative sum data of pData from i1 to i2-1,

and record every step's result in pCumSum.

Data type is ushort. 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_i_cumulative_sum, ocmath_b_cumulative_sum

header to Include

origin.h

Reference