ocmath_fit_linear_multi_regions

 

Description

Split the curve to segments and then perform linear fit on them

Syntax

int ocmath_fit_linear_multi_regions( UINT nSize, const double * px, const double * py, UINT nSegs, const int * pBegs, const int * pEnds, LRresults * pResults )

Parameters

nSize
[input] size of the curve data
px
[input] pointer to x coordinates of the curve
py
[input] pointer to y coordinates of the curve
nSegs
[input] number of segments to split
pBegs
[input] pointer to begin indices of each segment
pEnds
[input] pointer to end indices of each segment
pResults
[output] output the fitting results

Return

Return number of linear segments.

Examples

EX1

void ocmath_fit_linear_multi_regions_ex1()
{
    vector vx = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector vy = {8.15988E-4,
                0.01832,
                0.16901,
                0.64118,
                1,
                0.64118,
                0.16901,
                0.01832,
                8.15988E-4,
                1.49453E-5}
    vector<int> vBeg = {0, 1, 4, 7};
    vector<int> vEnd = {1, 4, 7, 9};
    LRresults res[4];
    ocmath_fit_linear_multi_regions(10, vx, vy, 4, vBeg, vEnd, res);
}

Remark

See Also

header to Include

origin.h

Reference