ocmath_check_order_multiple_curves

 

Description

Check all curves's X value's monotonic and consistent state.

Syntax

int ocmath_check_order_multiple_curves( UINT nSize, const OneCurveData * pCurves, int nSegments = 3, double * pMeanInc = NULL, double * pSDInc = NULL, int * pSegSize = NULL, double dProb = 0.8 )

Parameters

nSize
[input] number of curves and should > 1.
pCurves
[input] pointer to structures that must be filled with pointers to input curves data.
nSegments
[input] number of parts that the curve should be divided when call ocmath_check_order_curve.
it can equal to 1 and its default value is 3.
pMeanInc
[output] if not NULL, pointer to all curves each part's mean increment, its
size should be equal to nSegments * nSize and the jth part's
mean increment of ith curve is pMeanInc[(i - 1) * nSegments + j -1].
Its default value is NULL.
pSDInc
[output] if not NULL, pointer to all curves each part's standard deviation
of increment array, its size should be equal to nSegments * nSize. and
the jth part's standard deviation f increment array of ith curve
is pSDInc[(i - 1) * nSegments + j - 1]. Its default value is NULL.
pSegSize
[output] if not NULL, pointer to all curves each part's size, its size should
be equal to nSegments * nSize. and the jth part's size of ith
curve is pSegSize[(i - 1) * nSegments + j - 1]. Its default value is NULL.
dProb
[input] detail info please check ocmath_check_order_curve, its default value is 0.8.

Return

if succeed, return MCO_MONO_CONSISTENT if monotonic and consistent,

return MCO_MONO_NOT_CONSISTENT if not monotonic but consistent,

return MCO_NOT_CONSISTENT if curves are not consistent;

orthewise, negetive error code is returned.

Examples

EX1

//This example assume the active window is a graph with at least two curves.
void ocmath_check_order_multi_curves_ex1()
{
    GraphLayer gl = Project.ActiveLayer();
    if (!gl)
    {
        return;
    }
    
    int nPlots = gl.DataPlots.Count();
    int ii;
    int nAveSize = 0;
    
    OneCurveData* multiCurveData = (OneCurveData*) malloc(sizeof(OneCurveData)*nPlots);
    
    double* xx;
    double* yy;
    
    for(ii = 0; ii < nPlots; ii++)
    {
        DataPlot dp = gl.DataPlots(ii);        
        DataRange dr;
        vector vDatax, vDatay;
        if(dp.GetDataRange(dr))
        {
            DWORD dwPlotID;
            if(dr.GetData(DRR_GET_DEPENDENT | DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vDatay, &vDatax) < 0)
            {
                printf("get_plot_data failed GetData");
                return;
            }
        }
        nAveSize = vDatay.GetSize();
    
        xx = (double*) malloc (sizeof(double) * nAveSize);
        yy = (double*) malloc (sizeof(double) * nAveSize);
    
        memcpy(xx, vDatax, sizeof(double)*nAveSize);
        memcpy(yy, vDatay, sizeof(double)*nAveSize);
        
        multiCurveData[ii].nSize = nAveSize;
        multiCurveData[ii].pX = xx;
        multiCurveData[ii].pY = yy;
    }
    
    int nSegments = 3;
    vector vSDInc(nPlots * nSegments);
    vector<int> vSegSize(nPlots * nSegments);
    int nRet = ocmath_check_order_multiple_curves(nPlots, multiCurveData, nSegments, vSDInc, NULL, vSegSize);
        
    switch(nRet)
    {
    case MCO_MONO_CONSISTENT:
        printf("monotonic and consistent");
        break;
    case MCO_MONO_NOT_CONSISTENT:
        printf("not monotonic but consistent");
        break;
    case MCO_NOT_CONSISTENT:
        printf("not consistent");
        break;
    default:
        printf("failed: error code is %d", nRet);
        break;
    }
    return; 
}

Remark

This function checks all curves's X value are monotonic and consistent, not monotonic

but consistent or not consistent by check each curve use ocmath_check_order_curve.

Number of curves should more than 1. If only one curve, please use ocmath_check_order_curve.

It can handle that the curve has some outliers.

See Also

ocmath_check_order_curve, ocmath_check_order

header to Include

origin.h

Reference