ocmath_ui_sum

 

Description

Calculate the vector's sum, minimum and maximum.

Syntax

double ocmath_ui_sum( uint * pData, uint nSize, uint * pmin = NULL, uint * pmax = NULL, uint * pnmin = NULL, uint * pnmax = 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

Return

Sum of all the elements of pData

Examples

EX1

void ocmath_ui_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_us_sum, ocmath_b_sum

header to Include

origin.h

Reference