Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure Linear1D(Y: TVec; PiecePoly: TPiecePoly); | Perform interpolation assuming that Y is evaluated at [0,1,2,...]. |
| 2 | procedure Linear1D(X: TVec; Y: TVec; PiecePoly: TPiecePoly); | Linear interpolation. |
Overload 1: procedure Linear1D(Y: TVec; PiecePoly: TPiecePoly);
Perform interpolation assuming that Y is evaluated at [0,1,2,...].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Y | TVec | source TVec |
| 2 | PiecePoly | TPiecePoly |
Result: stored in self (calling object)
Overload 2: procedure Linear1D(X: TVec; Y: TVec; PiecePoly: TPiecePoly);
Linear interpolation.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TVec | source TVec |
| 2 | Y | TVec | source TVec |
| 3 | PiecePoly | TPiecePoly |
Result: stored in self (calling object)
Remarks:
The Linear1D procedure interpolates lines between consecutive (X,Y) pairs. Linear1D does not return interpolated points. It constructs piece-wise polynomial, which can be used to evaluate ( by using the PiecePoly.Evaluate method) the linear functions. To directly obtain interpolated values, use the Polynoms.Interpolate routine.
Note:
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
Linear1D(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;