Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure Interpolate(Y: TVec; intX: TVec; IntY: TVec; IntType: TInterpolationType; IntXSorted: Boolean); | Performs interpolation assuming X=[0,1,..]. |
| 2 | procedure Interpolate(X: TVec; Y: TVec; intX: TVec; IntY: TVec; IntType: TInterpolationType; IntXSorted: Boolean); | Perform linear or cubic interpolation. |
Overload 1: procedure Interpolate(Y: TVec; intX: TVec; IntY: TVec; IntType: TInterpolationType; IntXSorted: Boolean);
Performs interpolation assuming X=[0,1,..].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Y | TVec | source TVec |
| 2 | intX | TVec | source TVec |
| 3 | IntY | TVec | source TVec |
| 4 | IntType | TInterpolationType | |
| 5 | IntXSorted | Boolean |
Result: stored in self (calling object)
Performs interpolation assuming X=[0,1,..] and assumes that Y is evaluated at [0,1,2,...] -> X values are [0,1,2,...].
Overload 2: procedure Interpolate(X: TVec; Y: TVec; intX: TVec; IntY: TVec; IntType: TInterpolationType; IntXSorted: Boolean);
Perform linear or cubic interpolation.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TVec | source TVec |
| 2 | Y | TVec | source TVec |
| 3 | intX | TVec | source TVec |
| 4 | IntY | TVec | source TVec |
| 5 | IntType | TInterpolationType | |
| 6 | IntXSorted | Boolean |
Result: stored in self (calling object)
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.
uses MtxExpr, Math387, MtxVec, MtxVecEdit, MtxVecTee, Polynoms;
procedure TForm1.Button1Click(Sender: TObject);
var X,Y : Vector;
pX,pY : Vector;
i : Integer;
begin
X.Size(100);
Y.Size(100);
Randomize;
// generate function - note that X values are monotonical
X.Ramp;
y[0] := 100;
for i:=1 to X.Length-1 do
begin
y[i]:=y[i-1] +250 - random(500);
end;
// 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,intCubic,true);
// PY returns the interpolated points, calculated at PX
DrawIt(Y,'Original');
DrawIt(PY,'Interpolated');
end;