Polynoms::PolyEval Function

Overload List

#SignatureDescription
1void PolyEval(TVec *Val, TVec *Coeff, TMtx *R, int DegFreedom, double L2R, TVec *EvalResult, TVec *Delta);Evaluate a polynomial.
2void PolyEval(TVec *Val, TVec *Coeff, TVec *EvalResult);Evaluates a polynomial with coefficients Coeff at value Val and returns the results in EvalResult.
3double PolyEval(double Val, TVec *Coeff);Evaluates a polynomial with coefficients Coeff at real value Val and returns real result.
4TCplx PolyEval(TCplx Val, TVec *Coeff);Evaluates a polynomial with coefficients Coeff at complex value Val and returns complex results.

Overload 1: void PolyEval(TVec *Val, TVec *Coeff, TMtx *R, int DegFreedom, double L2R, TVec *EvalResult, TVec *Delta);

Evaluate a polynomial.

#NameTypeDescription
1ValTVec *Stores values doe which the polynomial will be evaluated (x values).
2CoeffTVec *Stores polynomial coefficients for which the polynomial will be evaaluted.
3RTMtx *Returns the Cholesky factor of the Vandermonde matrix.
4DegFreedomintReturns the residuals degree of freedom.
5L2RdoubleReturns the L2 norm of the residuals.
6EvalResultTVec *Returns the results P(x), evaluated at Val.
7DeltaTVec *Returns the error estimates for Results.
Remarks:

Evaluate a polynomial with coefficients Coeff at value Val. The order of polynomial (N) is determined as: N := Coeff.Length - 1. The algorithm employed uses Horners rule. The following formula is used to evaluate the polynomial:

P(x) = coeff[0]*x^n + coeff[1]*x^(n-1) + .. + coeff[n]

To estimate the error of polynomial interpolation after a call to Polynoms::PolyFit additional parameters have to be passed to the routine.

Examples
#include "MtxExpr.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, Coeff;
    X = Ramp(10, TMtxFloatPrecision::mvDouble, -5, 1); // X = [-5,-4,-3,-2,-1, 0, 1, 2, 3, 4]

    // construct a parabola

    Coeff.SetIt(false, DewArray<double>{2, -1, 3});
    PolyEval(X, Coeff, Y);

    // Y now holds the values of polynomial, evaluated at all X.Values
}
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler

Overload 2: void PolyEval(TVec *Val, TVec *Coeff, TVec *EvalResult);

Evaluates a polynomial with coefficients Coeff at value Val and returns the results in EvalResult.

#NameTypeDescription
1ValTVec *
2CoeffTVec *
3EvalResultTVec *
Remarks:

Evaluates a polynomial with coefficients Coeff at value Val and returns the results in EvalResult.

Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler

Overload 3: double PolyEval(double Val, TVec *Coeff);

Evaluates a polynomial with coefficients Coeff at real value Val and returns real result.

#NameTypeDescription
1Valdouble
2CoeffTVec *
Remarks:

Evaluates a polynomial with coefficients Coeff at real value Val and returns real result.

Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler

Overload 4: TCplx PolyEval(TCplx Val, TVec *Coeff);

Evaluates a polynomial with coefficients Coeff at complex value Val and returns complex results.

#NameTypeDescription
1ValTCplx
2CoeffTVec *
Remarks:

Evaluates a polynomial with coefficients Coeff at complex value Val and returns complex results.

Examples
#include "MtxExpr.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 Coeff(0);

    X.Size(10);
    X.Ramp(-5, 1); // X = [-5,-4,-3,-2,-1, 0, 1, 2, 3, 4]
    // construct a parabola
    Coeff.SetIt(false, DewArray<double>{2, -1, 3});
    Polynoms::PolyEval(X, Coeff, Y);

    // Y now holds the values of polynomial, evaluated at all X.Values
}
See Also: Polynoms::PolyFit, TPiecePoly
Declared in Dew::Math::Units::Polynoms · Dew.Math/Units.Polynoms.h · Cross-compiler