ocmath_d_cumulative_sum

 

Description

Computes the cummulative sum of the data.

Syntax

uint ocmath_d_cumulative_sum( const double * pData, uint i1, uint i2, double * pCumSum, const double * 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_d_cumulative_sum_ex1()
{
    vector<double> vecData = {1.1,2,3,4,5,6,7,9,10,0};
    uint i1 = 0;
    uint i2 = vecData.GetSize();
    vector<double> vecCumSum;
    vecCumSum.SetSize(i2-i1);
    uint numMissing = ocmath_d_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 double. 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_f_cumulative_sum, ocmath_us_cumulative_sum, ocmath_b_cumulative_sum

header to Include

origin.h

Reference