Polynoms::Linear1D Function

Overload List

#SignatureDescription
1void Linear1D(TVec *X, TVec *Y, TPiecePoly *PiecePoly);Linear interpolation.
2void Linear1D(TVec *Y, TPiecePoly *PiecePoly);Perform interpolation assuming that Y is evaluated at [0,1,2,...].

Overload 1: void Linear1D(TVec *X, TVec *Y, TPiecePoly *PiecePoly);

Linear interpolation.

#NameTypeDescription
1XTVec *
2YTVec *
3PiecePolyTPiecePoly *
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
#include "MtxExpr.h"
#include "Polynoms.h"
#include "Units.MtxExpr.h"
#include "Units.Polynoms.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Math::Units::Polynoms;

void Example()
{
    Vector X, Y, Y2;
    TPiecePoly* PP;
    int i;
    double YVal;
    PP = new TPiecePoly();
    // generate function - note that X values are monotonical
    X = Ramp(100, TMtxFloatPrecision::mvDouble, 0, 1);
    Y = RandUniform(100, TMtxFloatPrecision::mvDouble, 0, 50) + Ramp(100, TMtxFloatPrecision::mvDouble, 100, 0.25);

    //   construct cubic splines, but do not evaluate them

    Linear1D(X, Y, PP);

    X = Ramp(800, TMtxFloatPrecision::mvDouble, 0, 0.125); //get interpolation points
    PP->Evaluate(X, Y2); // evaluate

    delete PP;
}
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler

Overload 2: void Linear1D(TVec *Y, TPiecePoly *PiecePoly);

Perform interpolation assuming that Y is evaluated at [0,1,2,...].

#NameTypeDescription
1YTVec *
2PiecePolyTPiecePoly *
Examples
#include "MtxExpr.h"
#include "Polynoms.h"
#include "Units.Polynoms.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units;

void Example()
{
    Vector X(0);
    Vector Y(0);
    Vector Y2(0);
    TPiecePoly* PP = new TPiecePoly();
    int i;
    double YVal;

    // generate function - note that X values are monotonical
    X.Size(100);
    Y.Size(100);
    Y2.Size(100);

    X.Ramp(0, 1);
    Y.RandUniform(0, 50);
    Y2.Ramp(100, 0.25);
    Y = Y + Y2;

    //   construct cubic splines, but do not evaluate them

    Polynoms::Linear1D(X, Y, PP);

    X.Size(800);
    X.Ramp(0, 0.125); //get interpolation points
    PP->Evaluate(X, Y2); // evaluate
    delete PP;
}
See Also: Polynoms::Interpolate, Polynoms::Spline1D, Polynoms::PolyFit, TPiecePoly
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler