ocmath_f_cumulative_sum

 

Description

Computes the cummulative sum of the data.

Syntax

uint ocmath_f_cumulative_sum( const float * pData, uint i1, uint i2, float * pCumSum, const float * 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_f_cumulative_sum_ex1()
{
    vector<float> vecData = {1.1,2,3,4,5,6,7,9,10,0};
    uint i1 = 0;
    uint i2 = vecData.GetSize();
    vector<float> vecCumSum;
    vecCumSum.SetSize(i2-i1);
    uint numMissing = ocmath_f_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 float. pCumSum[0] = pData[0],

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

else pCumSum[ii] = pCumSum[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_us_cumulative_sum, ocmath_b_cumulative_sum

header to Include

origin.h

Reference