Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions
MathUtils::Polynomial Class Reference

Polynomial functor: f(x) = sum(a[i] * x^i). Coefficients are stored in order: a[0] + a[1]*x + a[2]*x^2 + ... More...

#include <MathUtils_FunctorScalar.hxx>

Public Member Functions

 Polynomial (std::initializer_list< double > theCoeffs)
 Constructor from initializer list.
 
 Polynomial (const math_Vector &theCoeffs)
 Constructor from math_Vector.
 
bool Value (double theX, double &theY) const
 Evaluates polynomial at theX using Horner's method.
 
bool Values (double theX, double &theY, double &theDY) const
 Evaluates polynomial and its derivative at theX.
 
int Degree () const
 Returns the degree of the polynomial.
 
double Coefficient (int theIndex) const
 Returns coefficient by index.
 

Detailed Description

Polynomial functor: f(x) = sum(a[i] * x^i). Coefficients are stored in order: a[0] + a[1]*x + a[2]*x^2 + ...

Usage:

// x^2 - 2 (find sqrt(2))
Polynomial aPoly({-2.0, 0.0, 1.0});
// x^3 - 6x^2 + 11x - 6 = (x-1)(x-2)(x-3)
Polynomial aCubic({-6.0, 11.0, -6.0, 1.0});
Polynomial functor: f(x) = sum(a[i] * x^i). Coefficients are stored in order: a[0] + a[1]*x + a[2]*x^...
Definition MathUtils_FunctorScalar.hxx:148
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142

Constructor & Destructor Documentation

◆ Polynomial() [1/2]

MathUtils::Polynomial::Polynomial ( std::initializer_list< double > theCoeffs)
inline

Constructor from initializer list.

Parameters
theCoeffscoefficients in ascending power order

◆ Polynomial() [2/2]

MathUtils::Polynomial::Polynomial ( const math_Vector & theCoeffs)
inlineexplicit

Constructor from math_Vector.

Parameters
theCoeffscoefficients in ascending power order

Member Function Documentation

◆ Coefficient()

double MathUtils::Polynomial::Coefficient ( int theIndex) const
inline

Returns coefficient by index.

Parameters
theIndexcoefficient index (0 = constant term)
Returns
coefficient value

◆ Degree()

int MathUtils::Polynomial::Degree ( ) const
inline

Returns the degree of the polynomial.

Returns
polynomial degree (number of coefficients - 1)

◆ Value()

bool MathUtils::Polynomial::Value ( double theX,
double & theY ) const
inline

Evaluates polynomial at theX using Horner's method.

Parameters
[in]theXinput value
[out]theYpolynomial value p(theX)
Returns
true (always succeeds for polynomials)

◆ Values()

bool MathUtils::Polynomial::Values ( double theX,
double & theY,
double & theDY ) const
inline

Evaluates polynomial and its derivative at theX.

Parameters
[in]theXinput value
[out]theYpolynomial value p(theX)
[out]theDYderivative value p'(theX)
Returns
true (always succeeds for polynomials)

The documentation for this class was generated from the following file: