The QwtSpline class is used for cubical spline interpolation. Two types of splines, natural and periodic, are supported.
#include<qwt_spline.h> #include<iostream.h> QwtSpline s; double x[30], y[30], xInter[300], yInter[300]; int i; for(i=0;i<30;i++) // fill up x[] and y[] cin >> x[i] >> y[i]; if (s.recalc(x,y,30,0) == 0) // build natural spline { for(i=0;i<300;i++) // interpolate { xInter[i] = x[0] + double(i) * (x[29] - x[0]) / 299.0; yInter[i] = s.value( xInter[i] ); } do_something(xInter, yInter, 300); } else cerr << "Uhhh...\n";
Definition at line 63 of file qwt_spline.h.
Public Member Functions | |
QwtSpline () | |
~QwtSpline () | |
double | value (double x) const |
int | recalc (double *x, double *y, int n, int periodic=0) |
int | recalc (const QwtArray< double > &x, const QwtArray< double > &y, int periodic=0) |
void | copyValues (int tf=1) |
|
CTOR.
Definition at line 31 of file qwt_spline.cpp. |
|
DTOR.
Definition at line 68 of file qwt_spline.cpp. |
|
Advise recalc() to buffer the tabulated function or switch off internal buffering. By default, QwtSpline maintains an internal copy of the tabulated function given as *x and *y arguments of QwtSpline::recalc(). If QwtSpline::copyValues() is called with zero argument, subsequent calls to QwtSpline::recalc() will not buffer these values anymore and just store the pointers instead. The QwtSpline::value() function will then silently assume that these pointers remained valid and that the contents of the arrays have not been changed since the last QwtSpline::recalc(). If called with no or nonzero argument, any following QwtSpline::recalc() calls will use the internal buffer.
Definition at line 61 of file qwt_spline.cpp. |
|
re-calculate the spline coefficients Depending on the value of periodic, this function will determine the coefficients for a natural or a periodic spline and store them internally. It also buffers the values of x and y, which are needed for the interpolation (See QwtSpline::value()).
Definition at line 206 of file qwt_spline.cpp. References recalc(). |
|
re-calculate the spline coefficients Depending on the value of periodic, this function will determine the coefficients for a natural or a periodic spline and store them internally. By default, it also buffers the values of x and y, which are needed for the interpolation (See QwtSpline::value()). In order to save memory, this last behaviour may be changed with the QwtSpline::copyValues() function.
Definition at line 127 of file qwt_spline.cpp. Referenced by QwtCurve::drawSpline(), and recalc(). |
|
Calculate the interpolated function value corresponding to a given argument x. Definition at line 18 of file qwt_spline.cpp. Referenced by QwtCurve::drawSpline(). |