Polynoms::Interpolate Function

Overload List

#SignatureDescription
1void Interpolate(TVec *X, TVec *Y, TVec *intX, TVec *IntY, TInterpolationType IntType = TInterpolationType::IntCubic, bool IntXSorted = true);Perform linear or cubic interpolation.
2void Interpolate(TVec *Y, TVec *intX, TVec *IntY, TInterpolationType IntType = TInterpolationType::IntCubic, bool IntXSorted = true);Performs interpolation assuming X=[0,1,..].

Overload 1: void Interpolate(TVec *X, TVec *Y, TVec *intX, TVec *IntY, TInterpolationType IntType = TInterpolationType::IntCubic, bool IntXSorted = true);

Perform linear or cubic interpolation.

#NameTypeDescription
1XTVec *
2YTVec *
3intXTVec *
4IntYTVec *
5IntType = TInterpolationType::IntCubicTInterpolationType
6IntXSorted = truebool
Remarks:

The routine interpolates IntY at IntX to the underlying function values, stored in Y. X.Length and Y.length properties must match or an exception will be raised. The IntType parameter defines the type of interpolation (linear, cubic). The intXSorted parameter defines whether intX values are sorted. If intX values are sorted the interpolation is much faster.

Vector X stores the positions, where the function is evaluated. X values must be monotonic. The Length and Complex properties of the IntY vector are adjusted automatically.

Examples
#include "MtxExpr.h"
#include "Units.Polynoms.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Polynoms;

void Example()
{
    Vector X, Y;
    Vector PX, PY;
    int i;
    X.Size(100);
    Y.Size(100);
    Randomize();
    // generate function - note that X values are monotonical
    X.Ramp();
    Y[0] = 100;
    for (i = 1; i <= X.Length - 1; i++)
    {
        Y[i] = Y[i - 1] + 250 - Random(500);
    }

    // now setup the points at which you want to interpolate
    PX.Size(1000);
    PX.Ramp();
    PX.Scale(0.1);

    // calculate piecewise poly for the range of points -
    //   note that PX values are sorted
    Interpolate(X, Y, PX, PY, TInterpolationType::IntCubic, true);
    // PY returns the interpolated points, calculated at PX
}
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler

Overload 2: void Interpolate(TVec *Y, TVec *intX, TVec *IntY, TInterpolationType IntType = TInterpolationType::IntCubic, bool IntXSorted = true);

Performs interpolation assuming X=[0,1,..].

#NameTypeDescription
1YTVec *
2intXTVec *
3IntYTVec *
4IntType = TInterpolationType::IntCubicTInterpolationType
5IntXSorted = truebool
Remarks:

Performs interpolation assuming X=[0,1,..] and assumes that Y is evaluated at [0,1,2,...] -> X values are [0,1,2,...].

Examples
#include "MtxExpr.h"
#include "Units.Polynoms.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units;

void Example()
{
    Vector X(0);
    Vector Y(0);
    Vector PX(0);
    Vector PY(0);

    // generate function - note that X values are monotonical
    X.Size(100);
    Y.Size(100);
    X.Ramp();
    Y.Values(0) = 100.0;
    for (int i = 1; i < X.Length; i++)
        Y.Values(i) = Y.Values(i - 1) + 250 - Random(500);

    // now setup the points at which you want to interpolate
    PX.Size(1000);
    PX.Ramp();
    PX.Scale(0.1);

    // calculate piecewise poly for the range of points -
    //   note that PX values are sorted
    Polynoms::Interpolate(X, Y, PX, PY, TInterpolationType::IntCubic, true);
    // PY returns the interpolated points, calculated at PX
}
See Also: Polynoms::Spline1D, Polynoms::Linear1D, Polynoms::PolyFit, TPiecePoly
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler