Polynoms.Interpolate Method

Overload List

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

Overload 1: void Interpolate(TVec Y, TVec intX, TVec IntY, TInterpolationType IntType, Boolean IntXSorted)

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

#NameTypeDescription
1YTVecsource TVec
2intXTVecsource TVec
3IntYTVecsource TVec
4IntTypeTInterpolationType
5IntXSortedBoolean

Result: stored in self (calling object)

Remarks:

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

Examples
using Dew.Math;
using Dew.Math.Units;
using Dew.Math.Tee;

namespace Dew.Examples
{
    private void Example()
    {
        Vector X = new Vector(0);
        Vector Y = new Vector(0);
        Vector PX = new Vector(0);
        Vector PY = new Vector(0);

        // generate function - note that X values are monotonical
        Random r = new Random();
        X.Ramp();
        Y.Values[0] = 100.0;
        for (int i=1; i < X.Length; i++)
            Y.Values[i] = Y.Values[i-1] + 250 - r.Next(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

        MtxVecTee.DrawIt(Y,"Original",false);
        MtxVecTee.DrawIt(PY,"Interpolated",false);
    }
}
See Also: Polynoms.Spline1D, Polynoms.Linear1D, Polynoms.PolyFit, TPiecePoly

Overload 2: void Interpolate(TVec X, TVec Y, TVec intX, TVec IntY, TInterpolationType IntType, Boolean IntXSorted)

Perform linear or cubic interpolation.

#NameTypeDescription
1XTVecsource TVec
2YTVecsource TVec
3intXTVecsource TVec
4IntYTVecsource TVec
5IntTypeTInterpolationType
6IntXSortedBoolean

Result: stored in self (calling object)

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.