npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
Inheritance diagram for npstat::Poly1D:
npstat::Functor1< long double, long double >

Public Member Functions

 Poly1D (const double *coeffs, unsigned degree)
 
 Poly1D (const long double *coeffs, unsigned degree)
 
 Poly1D (const std::vector< double > &c)
 
 Poly1D (const std::vector< long double > &c)
 
 Poly1D (const long double c0)
 
 Poly1D (unsigned degree, long double leadingCoeff)
 
void reserve (const unsigned degree)
 
void truncate (const unsigned maxDegree)
 
void truncateLeadingZeros ()
 
void setCoefficient (unsigned degree, long double value)
 
unsigned deg () const
 
long double operator[] (const unsigned degree) const
 
const std::vector< long double > & allCoefficients () const
 
long double leadingCoefficient () const
 
unsigned nRoots (long double a, long double b) const
 
virtual long double operator() (const long double &x) const
 
bool isClose (const Poly1D &r, long double eps) const
 
bool isNull () const
 
Poly1D derivative () const
 
Poly1D integral (long double c) const
 
Poly1D operator+ () const
 
Poly1D operator- () const
 
Poly1D operator* (const Poly1D &) const
 
Poly1D operator+ (const Poly1D &) const
 
Poly1D operator- (const Poly1D &) const
 
Poly1Doperator*= (const Poly1D &)
 
Poly1Doperator+= (const Poly1D &)
 
Poly1Doperator-= (const Poly1D &)
 
Poly1D operator/ (const Poly1D &) const
 
Poly1D operator% (const Poly1D &) const
 
bool operator== (const Poly1D &r) const
 
bool operator!= (const Poly1D &r) const
 

Static Public Member Functions

static Poly1D monicDeg0 ()
 
static Poly1D monicDeg1 (long double b)
 
static Poly1D monicDeg2 (long double b, long double c)
 

Additional Inherited Members

- Public Types inherited from npstat::Functor1< long double, long double >
typedef long double result_type
 
typedef long double first_argument_type
 

Constructor & Destructor Documentation

◆ Poly1D() [1/4]

npstat::Poly1D::Poly1D ( const double *  coeffs,
unsigned  degree 
)

The length of the array of coefficients should be at least degree+1. The highest degree coefficient is assumed to be the last one in the "coeffs" array (0th degree coefficient comes first).

◆ Poly1D() [2/4]

npstat::Poly1D::Poly1D ( const std::vector< double > &  c)
explicit

The length of the vector of coefficients should be degree+1. The highest degree coefficient is assumed to be the last one in the vector (0th degree coefficient comes first).

◆ Poly1D() [3/4]

npstat::Poly1D::Poly1D ( const long double  c0)
inline

Note that the constructor from a floating point number is not explicit. Implicit conversions from a floating point number into a Poly1D are useful, for example, with arithmetic operators.

◆ Poly1D() [4/4]

npstat::Poly1D::Poly1D ( unsigned  degree,
long double  leadingCoeff 
)

Construct a monomial of the given degree and with the leading coefficient provided

Member Function Documentation

◆ allCoefficients()

const std::vector<long double>& npstat::Poly1D::allCoefficients ( ) const
inline

Return all coefficients

◆ deg()

unsigned npstat::Poly1D::deg ( ) const
inline

The degree of the polynomial

◆ derivative()

Poly1D npstat::Poly1D::derivative ( ) const

Derivative polynomial

◆ integral()

Poly1D npstat::Poly1D::integral ( long double  c) const

Indefinite integral, with explicit additive constant

◆ isClose()

bool npstat::Poly1D::isClose ( const Poly1D r,
long double  eps 
) const

Check if all polynomial coefficients are within eps from those of another polynomial. eps must be non-negative.

◆ isNull()

bool npstat::Poly1D::isNull ( ) const
inline

Check if the polynomial value is identical zero

◆ leadingCoefficient()

long double npstat::Poly1D::leadingCoefficient ( ) const

The coefficient of the maximum degree monomial

◆ monicDeg0()

static Poly1D npstat::Poly1D::monicDeg0 ( )
inlinestatic

Monic polynomial of 0th degree (just 1.0)

◆ monicDeg1()

static Poly1D npstat::Poly1D::monicDeg1 ( long double  b)
static

Monic polynomial of degree 1, x + b

◆ monicDeg2()

static Poly1D npstat::Poly1D::monicDeg2 ( long double  b,
long double  c 
)
static

Monic polynomial of degree 2, x^2 + b x + c

◆ nRoots()

unsigned npstat::Poly1D::nRoots ( long double  a,
long double  b 
) const

Number of roots on the interval (a, b]

◆ operator%()

Poly1D npstat::Poly1D::operator% ( const Poly1D ) const

Euclidean division of polynomials – the remainder

◆ operator()()

virtual long double npstat::Poly1D::operator() ( const long double &  x) const
virtual

Polynomial value at x

Implements npstat::Functor1< long double, long double >.

◆ operator*()

Poly1D npstat::Poly1D::operator* ( const Poly1D ) const

Binary operator on two polynomials or on a polynomial and a floating point number

◆ operator+()

Poly1D npstat::Poly1D::operator+ ( ) const
inline

Unary operator

◆ operator/()

Poly1D npstat::Poly1D::operator/ ( const Poly1D ) const

Euclidean division of polynomials – the ratio

◆ operator[]()

long double npstat::Poly1D::operator[] ( const unsigned  degree) const
inline

Return the coefficient for the given degree

◆ reserve()

void npstat::Poly1D::reserve ( const unsigned  degree)
inline

At times it makes sense to reserve the space for the polynomial coefficients (in particular, with operator *=, when you use it more than once and have some idea about the expected degree of the result).

◆ setCoefficient()

void npstat::Poly1D::setCoefficient ( unsigned  degree,
long double  value 
)

Set coefficient for a particular degree

◆ truncate()

void npstat::Poly1D::truncate ( const unsigned  maxDegree)

Truncate the highest degree coefficients. The resulting polynomial will be of degree "maxDegree" (or less, if the new leading coefficient is 0).

◆ truncateLeadingZeros()

void npstat::Poly1D::truncateLeadingZeros ( )

Explicitly truncate leading coefficients that are zeros. Normally, the application code should not use this function, as tracking and removal of leading zeros happens automatically. It might still be useful in certain difficult to anticipate underflow scenarios.


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