Git commit 4cc356dfc00c1ca25e31622d4ba1c9f65cf1a168 by Stefan Gerlach. Committed on 30/04/2016 at 18:29. Pushed by sgerlach into branch 'analysis_interpolation'. added rational function interpolation M +56 -5 src/backend/worksheet/plots/cartesian/XYInterpolationCurve.c= pp M +1 -1 src/backend/worksheet/plots/cartesian/XYInterpolationCurve.h M +1 -0 src/backend/worksheet/plots/cartesian/XYInterpolationCurvePr= ivate.h M +1 -1 src/kdefrontend/dockwidgets/XYInterpolationCurveDock.cpp http://commits.kde.org/labplot/4cc356dfc00c1ca25e31622d4ba1c9f65cf1a168 diff --git a/src/backend/worksheet/plots/cartesian/XYInterpolationCurve.cpp= b/src/backend/worksheet/plots/cartesian/XYInterpolationCurve.cpp index 0c855b3..3567552 100644 --- a/src/backend/worksheet/plots/cartesian/XYInterpolationCurve.cpp +++ b/src/backend/worksheet/plots/cartesian/XYInterpolationCurve.cpp @@ -41,6 +41,7 @@ #include "backend/lib/commandtemplates.h" = #include // isnan +#include // DBL_MIN #include #include #include @@ -239,6 +240,53 @@ void XYInterpolationCurvePrivate::integ(double *x, dou= ble *y, unsigned n) { y[n-1]=3Dy[n-2]+vold; } = +// calculates rational interpolation of n points of xy-data at xn using Bu= rlisch-Stoer method. result in v (error dv) +void XYInterpolationCurvePrivate::ratint(double *x, double *y, int n, doub= le xn, double *v, double *dv) { + int i,j,a=3D0,b=3Dn-1; + while(b-a>1) { // find interval using bisection + j=3Dfloor((a+b)/2.); + if(x[j]>xn) + b=3Dj; + else + a=3Dj; + } + + int ns=3Da;// nearest index + if(fabs(xn-x[a])>fabs(xn-x[b])) + ns=3Db; + + if(xn=3D=3Dx[ns]) { // exact point + *v=3Dy[ns]; + *dv=3D0; + return; + } + + double *c =3D (double*)malloc(n*sizeof(double)); + double *d =3D (double*)malloc(n*sizeof(double)); + for(i=3D0;iaddItem(i18n("cosine")); uiGeneralTab.cbType->addItem(i18n("exponential")); - uiGeneralTab.cbType->addItem(i18n("rational functions")); uiGeneralTab.cbType->addItem(i18n("piecewise cubic Hermite (PCH)")); + uiGeneralTab.cbType->addItem(i18n("rational functions")); = uiGeneralTab.cbVariant->addItem(i18n("finite differences")); uiGeneralTab.cbVariant->addItem(i18n("Catmull-Rom"));