Unit
Polynoms
| See Also |
|---|
| Spline1D |
| Linear1D |
| PolyFit |
| TPiecePoly |
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;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project #include "Polynoms.hpp" #include "MtxVecTee.hpp" #include "MtxVecEdit.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { Vector X,Y, 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; 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,IntCubic,true); // PY returns the interpolated points, calculated at PX DrawIt(Y,"Original"); DrawIt(PY,"Interpolated"); }
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 TeeChart.DrawIt(Y,"Original",false); TeeChart.DrawIt(PY,"Interpolated",false); } }
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.
| Copyright 2008 Dew Research |