Perform arithmatic operation element-wised on two curves
int ocmath_simple_math( UINT nSize, double * pX, double * pY, UINT nSrcSize1, const double * pSrcX1, const double * pSrcY1, UINT nSrcSize2, const double * pSrcX2, const double * pSrcY2, int nOperator = MATHTOOL_OPT_ADD, int nRange = MATHTOOL_RNG_CUV, int nMethod = INTERP_TYPE_LINEAR, double dSmoothingFactor = 0 )
- [input] the size of result curve
- [output] pointer to the x coordinates of result curve
- [output] pointer to the y coordinates of result curve
- [input] the size of the first curve
- [input] pointer to the x coordinates of the first curve
- [input] pointer to the y coordinates of the first curve
- [input] the size of the second curve
- [input] pointer to the x coordinates of the second curve
- [input] pointer to the y coordinates of the second curve
- [input] the operation between the two input curve
- MATHTOOL_OPT_ADD add operation
- MATHTOOL_OPT_SUB subtract operation
- MATHTOOL_OPT_DIV divide operation
- MATHTOOL_OPT_MUL multiply operation
- MATHTOOL_OPT_EXP exponent operation
- [input] the range to perform the operation on
- MATHTOOL_RNG_CUV perform the operation on entire curves
- MATHTOOL_RNG_COM perform the operation on common x coordinates
- MATHTOOL_RNG_UD reserved for future
- [input] interpolating method, only available when use MATHTOOL_RNG_CUV.
- INTERP_TYPE_LINEAR(linear interpolation),
- INTERP_TYPE_SPLINE(cubic spline interpolation with not-a-knot boundary condition, and the not-a-knot boundary condition assume that the 3rd order derivative are continuous on the 2nd and last 2nd points),
- INTERP_TYPE_BSPLINE(B-Spline curve fitting using method by Dierckx.P)
- [input] This argument specifies the closeness to the original data, only available when nMethod = INTERP_TYPE_BSPLINE. dSmoothingFactor >= 0.
- By means of this parameter, the user can control the tradeoff between closeness of fit and smoothness of fit of the approximation.
- If dSmoothingFactor is too large, the spline will be too smooth and signal will be lost ; if it is too small the spline will pick up too much noise.
- In the extreme cases the program will return an interpolating spline if dSmoothingFactor=0 and the weighted least-squares polynomial of degree 3 if s is very large.
Return OE_NOERROR if succeed, otherwise, non-zero error code is returned.
//Assume there is a workbook named "Book1" in the current project
vector vA, vB, vC;
vA.Data(0.0, 6.0, 0.03);
int iCount = vA.GetSize();
for( int ii=0; ii<iCount; ii++ )
vB[ii] = sin(vA[ii]);
vC[ii] = cos(vA[ii]);
Dataset dsX(wks, 0);
Dataset dsY(wks, 1);
ocmath_simple_math(iCount, vx, vy, iCount, vA, vB, iCount, vA, vC, MATHTOOL_OPT_ADD);
dsX = vx;
dsY = vy;
header to Include