2.1.17.2.7.3 ocmath_reducexy_fixing_increbin


Description

Reduce XY data by By X Increment

Syntax

Origin 2021 and later versions
int ocmath_reducexy_fixing_increbin(const double * px, const double * pData, const UINT nSize, const int iOption, double * pMerged, double dInc,
                                     const double dStart = 0.0, const double dEnd = 0.0, UINT *pnMergedIndex = NULL, DWORD dwCntrl = 0)
Origin 2019 and later versions
int ocmath_reducexy_fixing_increbin(const double * px, const double * pData, const UINT nSize, const int iOption, double * pMerged, double dInc,
                                     const double dStart = 0.0, const double dEnd = 0.0, UINT *pnMergedIndex = NULL)
Origin 2017 and later versions
int ocmath_reducexy_fixing_increbin(const double * px, const double * pData, const UINT nSize, const int iOption, double * pMerged, double dInc,
                                     const double dStart = 0.0, const double dEnd = 0.0)
Origin 2016
int ocmath_reducexy_fixing_increbin(const double * px, const double * pData, const UINT nSize, const double nStart, const double nEnd, 
                                     const int iOption, double * pMerged, double dInc);
Origin 2015 and older versions
int ocmath_reducexy_fixing_increbin(const double * px, const double * pData, const UINT nSize, const int iOption, double * pMerged, double dInc);

Parameters

px
[input] pointer to x coordinates of the data
pData
[input] pointer to y coordinates of the data
nSize
[input] the number of the data points
iOption
[input] the way to pick the data value of the output data point, into which a group of data points are merged.
pMerged
[output] pointer to buffer to store the reduced data
dInc
[input] the X Increment to make bins as to create groups
dStart
[input] the start of x coordinates of the data(for subgroup using)
dEnd
[input] the end of x coordinates of the data(for subgroup using)
pnMergedIndex
[output] pointer to buffer to store the index of reduced data in source data
dwCntrl
[input] additional control, can be
REDUCE_XY_CNTRL_EXCLUDE_MISSING_VALUE

Return

Return the number of points in pMerged, return minus value on failure.

Examples

EX1

//Before run this sample code, please import "\\Samples\Mathematics\Circle.dat" into active worksheet, and set the number of rows as 27.

//Funtion prototype has been modified in Origin 2017 SR0. 
//If you want to execute the following function in Origin 2016 and older versions, 
//please replace ocmath_reducexy_fixing_increbin with its corresponding prototype.
void ocmath_reducexy_fixing_increbin_ex1()
{
	Worksheet wks = Project.ActiveLayer();
	if ( !wks )
		return;
	Column colX(wks, 0);
	Column colY(wks, 1);
	if ( colX && colY )
	{
    	vectorbase& vbInterX = colX.GetDataObject();
		vectorbase& vbInterY = colY.GetDataObject();
		vector vX = vbInterX; //should not pass vectorbase& as double pointer, need to temp it
		vector vY = vbInterY;
 
		vector vReduced(vY.GetSize());
		int nOption = REDUCE_XY_STATS_MEAN; //can change to other option in REDUCE_XY_STATS_...
		double dInc = 0.2; //increment of X to create bins
		int nNewSize = ocmath_reducexy_fixing_increbin(vX, vY, vY.GetSize(), nOption, vReduced, dInc);
 
		int iReduced = wks.AddCol("Reduced");
		Column colReduced(wks, iReduced);
		vectorbase& vbReduced = colReduced.GetDataObject();
		vbReduced = vReduced; //put result in new column;
	}
	return;
}

//Funtion prototype has been modified in Origin 2017 SR0. 
//If you want to execute the following function in Origin 2016 and older versions, 
//please replace ocmath_reducexy_fixing_increbin with its corresponding prototype.
void ocmath_reducexy_fixing_increbin_ex2()
{
	Worksheet wks = Project.ActiveLayer();
	if ( !wks )
		return;
	Column colX(wks, 0);
	Column colY(wks, 1);
	if ( colX && colY )
	{
    	vectorbase& vbInterX = colX.GetDataObject();
		vectorbase& vbInterY = colY.GetDataObject();
		vector vX = vbInterX; //should not pass vectorbase& as double pointer, need to temp it
		vector vY = vbInterY;
 
		vector vReduced(vY.GetSize());
		int nOption = REDUCE_XY_STATS_SUBGROUP_BEGIN; //can change to other option REDUCE_XY_STATS_SUBGROUP_CENTER and REDUCE_XY_STATS_SUBGROUP_END
		double dInc = 0.2; //increment of X to create bins
		double dStart = 0.2;
		double dEnd = 0.8;
		int nNewSize = ocmath_reducexy_fixing_increbin(vX, vY, vY.GetSize(), nOption, vReduced, dInc, dStart, dEnd);
 
		int iReduced = wks.AddCol("Reduced");
		Column colReduced(wks, iReduced);
		vectorbase& vbReduced = colReduced.GetDataObject();
		vbReduced = vReduced; //put result in new column;
	}
	return;
}

//Funtion prototype has been modified in Origin 2019. 
//If you want to execute the following function in Origin 2018 and older versions, 
//please replace ocmath_reducexy_fixing_increbin with its corresponding prototype.
void ocmath_reducexy_fixing_increbin_ex3()
{
	Worksheet wks = Project.ActiveLayer();
	if ( !wks )
		return;
	Column colX(wks, 0);
	Column colY(wks, 1);
	if ( colX && colY )
	{
    	vectorbase& vbInterX = colX.GetDataObject();
		vectorbase& vbInterY = colY.GetDataObject();
		vector vX = vbInterX; //should not pass vectorbase& as double pointer, need to temp it
		vector vY = vbInterY;
 
		vector vReduced(vY.GetSize());
        vector<UINT> vnReducedIndex(vY.GetSize());
		int nOption = REDUCE_XY_STATS_SUBGROUP_BEGIN; //can change to other option REDUCE_XY_STATS_SUBGROUP_CENTER and REDUCE_XY_STATS_SUBGROUP_END
		double dInc = 0.2; //increment of X to create bins
		double dStart = 0.2;
		double dEnd = 0.8;
		int nNewSize = ocmath_reducexy_fixing_increbin(vX, vY, vY.GetSize(), nOption, vReduced, dInc, dStart, dEnd, vnReducedIndex);
 
		int iReduced = wks.AddCol("Reduced");
		Column colReduced(wks, iReduced);
		vectorbase& vbReduced = colReduced.GetDataObject();
		vbReduced = vReduced; //put result in new column;
	}
	return;
}

Remark

Function prototype was modified at Origin 2019.

See Also

Header to Included

origin.h

Reference