Polynoms.Spline1D Method

Overload List

#SignatureDescription
1procedure Spline1D(Y: TVec; PiecePoly: TPiecePoly; Knots: Boolean);Interpolates cubic splines between consecutive Y points.
2procedure Spline1D(X: TVec; Y: TVec; PiecePoly: TPiecePoly);Cubic spline interpolation.

Overload 1: procedure Spline1D(Y: TVec; PiecePoly: TPiecePoly; Knots: Boolean);

Interpolates cubic splines between consecutive Y points.

#NameTypeDescription
1YTVecsource TVec
2PiecePolyTPiecePoly
3KnotsBoolean

Result: stored in self (calling object)

Remarks:

Interpolates cubic splines between consecutive Y points. The assumption is that Y is evaluated at [0,1,2,...] -> X values are [0,1,2,...]. If the Knot parameter is true then the first and the last Y value will be used for the end conditions. In this case Y.Length = X.Length + 2.

See Also: Polynoms.Interpolate, Polynoms.Linear1D, Polynoms.PolyFit, TPiecePoly

Overload 2: procedure Spline1D(X: TVec; Y: TVec; PiecePoly: TPiecePoly);

Cubic spline interpolation.

#NameTypeDescription
1XTVecsource TVec
2YTVecsource TVec
3PiecePolyTPiecePoly

Result: stored in self (calling object)

Remarks:

The procedure interpolates cubic splines between consequtive (X,Y) pairs. The rotine does not return interpolated points. It constructs piece-wise polynomial, which in term can be used for evaluating (by using the TPiecePoly.Evaluate method) cubic splines. To directly obtain interpolated values, use the Polynoms.Interpolate routine.

Note
If X.Length=Y.Length, then the "not-a-knot" end conditions are used. If Y.Length = X.Length +2 then the "knot" end conditions are used. X values must be monotonic or the result will not be valid.

Examples
uses MtxExpr, Math387, MtxVec, MtxVecEdit, MtxVecTee,Polynoms;

procedure TForm1.Button1Click(Sender: TObject);
var   X,Y,Y2: Vector;
PP    : TPiecePoly;
i     : Integer;
YVal  : double;
begin
    PP := TPiecePoly.Create;
    try
        // generate function - note that X values are monotonical
        X := Ramp(100,0,1);
        Y := RandUniform(100,0,50) + Ramp(100,100,0.25);

        //   construct cubic splines, but do not evaluate them

        Spline1D(X,Y,PP);

        X := Ramp(800,0,0.125); //get interpolation points
        PP.Evaluate(X,Y2); // evaluate

        DrawIt(Y,'Original');
        DrawIt(Y2,'Interpolated');

    finally
        PP.Free;
    end;
end;