2.1.24.4.24 ocmath_d_sum


Description

calculate the vector's sum, minimum and maximum, also count the vector size without missing value.

Syntax

double ocmath_d_sum( double * pData, uint nSize, double * pmin = NULL, double * pmax = NULL, uint * pnmin = NULL, uint * pnmax = NULL, uint * pnCount = NULL )

Parameters

pData
[input] buffer containing data
nSize
[input] size of pData
pmin
[output] the minimum element of pData
pmax
[output] the maximum element of pData
pnmin
[output] index of pmin
pnmax
[output] index of pmax
pnCount
[output] the number of elements which are not MissingValue

Return

Sum of all the elements of pData

Examples

EX1

void ocmath_d_sum_ex1()
{
    vector v={1,2,3,4,5,2,3,4,54,3,3,4,3,3};
    uint nSize=14;
    double dMin, dMax;
    uint nMin,nMax,nCount;
    v[7]=NANUM;
    double dsum=ocmath_d_sum(v,nSize,&dMin,&dMax,&nMin,&nMax,&nCount);
    printf("%f %f %d %d %f %d", dMin, dMax, nMin, nMax, dsum, nCount);
    //dMin=1    dMax=54     nMin=0     nMax=8    dsum=90    nCount=13
}

Remark

calculate the vector's sum, minimum and maximum, ocmath_d_sum also count the vector size without missing value.

The function is overloaded to support type float, unsigned short, unsigned int and unsigned char.

Data types supported:

double: ocmath_d_sum
float: ocmath_f_sum
unsigned short: ocmath_us_sum
unsigned int: ocmath_ui_sum
unsigned char: ocmath_b_sum

See Also

ocmath_f_sum, ocmath_ui_sum, ocmath_us_sum, ocmath_b_sum

Header to Include

origin.h

Reference