#include <BernsteinPoly.h>
Public Member Functions | |
BernsteinPoly () | |
Default constructor. | |
BernsteinPoly (const std::vector< double > &coefs) | |
Constructor. | |
template<typename ForwardIterator> | |
BernsteinPoly (ForwardIterator begin, ForwardIterator end) | |
Constructor. | |
BernsteinPoly (double coef) | |
Constructor for a constant polynomial. | |
int | degree () const |
Get the degree of the polynomial. | |
const double & | operator[] (int num) const |
Access function for coefficients. | |
double & | operator[] (int num) |
Access function for coefficients. | |
std::vector< double >::iterator | coefsBegin () |
Access function for coefficients. | |
std::vector< double >::const_iterator | coefsBegin () const |
Access function for coefficients. | |
std::vector< double >::iterator | coefsEnd () |
Access function for coefficients. | |
std::vector< double >::const_iterator | coefsEnd () const |
Access function for coefficients. | |
double | operator() (double t) const |
Evaluation operator, based on the de Casteljau algorithm. | |
bool | isZero (const double eps=0.0) const |
Check if the polynomial is the zero function. | |
bool | isStrictlyPositive (const double eps=0.0) const |
Check if the polynomial is strictly positive. | |
double | norm () const |
Calculates a norm, defined as the sum of the absolute values of the coefficients divided by the number of coefficients. | |
void | normalize () |
Normalizes the polynomial by dividing all coefficients with norm(), which is close to (but not identical to) the L1 norm of the polynomial. | |
BernsteinPoly | deriv (int der) const |
Calculates the derivative in terms of a new BernsteinPoly. | |
double | integral (double a=0.0, double b=1.0) const |
Calculates the integral of the polynomial over an interval. | |
double | blossom (const std::vector< double > &tvec) const |
Evaluates the blossom of the polynomial. | |
BernsteinPoly | pickInterval (double a, double b) const |
Finds a new BernsteinPoly representing the original on some interval. | |
void | degreeElevate (int d) |
Degree elevation. | |
BernsteinPoly & | operator *= (const BernsteinPoly &poly) |
Multiplication with another polynomial. | |
BernsteinPoly & | operator *= (double c) |
Multiplication with a scalar. | |
BernsteinPoly & | operator+= (const BernsteinPoly &poly) |
Addition with another polynomial. | |
BernsteinPoly & | operator+= (double c) |
Addition with a scalar. | |
BernsteinPoly & | operator-= (const BernsteinPoly &poly) |
Subtraction with another polynomial. | |
BernsteinPoly & | operator-= (double c) |
Subtraction with a scalar. | |
BernsteinPoly & | operator/= (double c) |
Division with a scalar. | |
void | read (std::istream &is) |
Read from input stream. | |
void | write (std::ostream &os) const |
Write to output stream. |
The formula for Bernstein polynomials is
The coefficients are stored in a vector of doubles.
Definition at line 54 of file BernsteinPoly.h.
Go::BernsteinPoly::BernsteinPoly | ( | const std::vector< double > & | coefs | ) | [inline, explicit] |
Constructor.
coefs | a vector of doubles containing the Bernstein coefficients |
Definition at line 61 of file BernsteinPoly.h.
Go::BernsteinPoly::BernsteinPoly | ( | ForwardIterator | begin, | |
ForwardIterator | end | |||
) | [inline] |
Constructor.
begin | iterator to start of container containing the Bernstein coefficients | |
end | iterator to end of same container |
Definition at line 68 of file BernsteinPoly.h.
Go::BernsteinPoly::BernsteinPoly | ( | double | coef | ) | [inline, explicit] |
Constructor for a constant polynomial.
coef | the constant value of the polynomial |
Definition at line 72 of file BernsteinPoly.h.
int Go::BernsteinPoly::degree | ( | ) | const [inline] |
Get the degree of the polynomial.
Definition at line 77 of file BernsteinPoly.h.
double Go::BernsteinPoly::operator() | ( | double | t | ) | const |
Evaluation operator, based on the de Casteljau algorithm.
t | the parameter value at which the polynomial is evaluated |
bool Go::BernsteinPoly::isZero | ( | const double | eps = 0.0 |
) | const |
Check if the polynomial is the zero function.
eps | the threshold value with which every coefficient is compared |
bool Go::BernsteinPoly::isStrictlyPositive | ( | const double | eps = 0.0 |
) | const |
Check if the polynomial is strictly positive.
NOTE: If the return value is 'true', then the polynomial is guaranteed to be strictly positive. If the return value is 'false', the situation is undetermined and the polynomial may still be strictly positive.
eps | the threshold value with which every coefficient is compared |
double Go::BernsteinPoly::norm | ( | ) | const |
Calculates a norm, defined as the sum of the absolute values of the coefficients divided by the number of coefficients.
This norm is not the same as the L1 norm of the polynomial (on the interval [0,1]), unless the polynomial does not change sign. In any case this norm is greater than or equal to the L1 norm of the polynomial.
void Go::BernsteinPoly::normalize | ( | ) |
BernsteinPoly Go::BernsteinPoly::deriv | ( | int | der | ) | const |
Calculates the derivative in terms of a new BernsteinPoly.
der | the order of derivatives requested |
double Go::BernsteinPoly::integral | ( | double | a = 0.0 , |
|
double | b = 1.0 | |||
) | const |
Calculates the integral of the polynomial over an interval.
The default interval is [0,1].
double Go::BernsteinPoly::blossom | ( | const std::vector< double > & | tvec | ) | const |
Evaluates the blossom of the polynomial.
The blossom of the polynomial of degree n is a multi-affine n-variate symmetric function that satisfies .
tvec | the vector of values at which the blossom is evaluated. |
BernsteinPoly Go::BernsteinPoly::pickInterval | ( | double | a, | |
double | b | |||
) | const |
Finds a new BernsteinPoly representing the original on some interval.
The new polynomial is defined on [0,1]. If p is the old polynomial and q is the new one, q is defined by
a | the start of the interval | |
b | the end of the interval |
void Go::BernsteinPoly::degreeElevate | ( | int | d | ) |
Degree elevation.
d | the polynomial degree in which you want to represent this polynomial. |