#include <BernsteinMulti.h>
Public Member Functions | |
BernsteinMulti () | |
Default constructor. | |
BernsteinMulti (int m, int n, const std::vector< double > &coefs) | |
Constructor. | |
template<typename ForwardIterator> | |
BernsteinMulti (int m, int n, ForwardIterator begin, ForwardIterator end) | |
Constructor. | |
BernsteinMulti (double coef) | |
Constructs a constant polynomial. | |
int | degreeU () const |
Get the degree in the first parameter direction. | |
int | degreeV () const |
Get the degree in the second parameter direction. | |
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 u, double v) const |
Evaluation operator, based on the de Casteljau algorithm. | |
double | operator() (const Vector2D &pt) const |
Evaluation operator - as above, but taking the arguments in a Vector2D. | |
double | operator() (const std::vector< double > &pt) const |
Evaluation operator - as above, but taking the arguments in a std::vector. | |
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 polynomial is strictly positive. | |
bool | isStrictlyNegative (const double eps=0.0) const |
Check if polynomial is strictly negative. | |
bool | isNonNegative (const double eps=0.0) const |
Check if polynomial is non-negative. | |
double | norm () const |
Calculates the norm of the polynomial, defined as the sum of 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. | |
double | mean () const |
Calculates the mean value of the coefficients. | |
BernsteinMulti | deriv (int der1, int der2) const |
Finds the derivative of the polynomial in terms of a new BernsteinMulti. | |
BernsteinMulti | detHess () const |
Calculates the determinant of the Hessian as a BernsteinMulti Describes Gaussian curvature of the graph of the polynomial. | |
BernsteinMulti | traceHess () const |
Calculates the trace of the Hessian as a BernsteinMUlti Describes mean curvature (modulo a factor 2) of the graph of the polynomial. | |
double | blossom (const std::vector< double > &uvec, const std::vector< double > &vvec) const |
Evaluates the blossom of the polynomial. | |
BernsteinMulti | pickDomain (double u0, double u1, double v0, double v1) const |
Finds a new BernsteinMulti representing the original on some rectangular domain. | |
BernsteinPoly | pickLine (Array< double, 2 > a, Array< double, 2 > b) const |
Routine that picks out the line with endpoints a and b as a new BernsteinPoly. | |
void | degreeElevate (int du, int dv) |
Degree elevation. | |
BernsteinMulti & | operator *= (const BernsteinMulti &multi) |
Multiplication with another polynomial. | |
BernsteinMulti & | operator *= (double c) |
Multiplication with a scalar. | |
BernsteinMulti & | operator+= (const BernsteinMulti &multi) |
Addition with another polynomial. | |
BernsteinMulti & | operator+= (double c) |
Addition with a scalar. | |
BernsteinMulti & | operator-= (const BernsteinMulti &multi) |
Subtraction with another polynomial. | |
BernsteinMulti & | operator-= (double c) |
Subtraction with a scalar. | |
BernsteinMulti & | operator/= (double c) |
Division with a scalar. | |
BernsteinPoly | bindU (double u) const |
Function that "binds" the u-parameter. | |
BernsteinPoly | bindV (double v) const |
Function that "binds" the v-parameter. | |
void | read (std::istream &is) |
Read from an input stream. | |
void | write (std::ostream &os) const |
Write to an output stream. |
The formula for a degree (m,n) polynomial is
where the basis functions in the first parameter direction are defined by
The coefficients are stored in the following order: .
Definition at line 67 of file BernsteinMulti.h.
Go::BernsteinMulti::BernsteinMulti | ( | int | m, | |
int | n, | |||
const std::vector< double > & | coefs | |||
) | [inline] |
Constructor.
m | degree in the first parameter direction | |
n | degree in the second parameter direction | |
coefs | vector of Bernstein coefficients |
Definition at line 75 of file BernsteinMulti.h.
Go::BernsteinMulti::BernsteinMulti | ( | int | m, | |
int | n, | |||
ForwardIterator | begin, | |||
ForwardIterator | end | |||
) | [inline] |
Constructor.
m | degree in the first parameter direction | |
n | degree in the second parameter direction | |
begin | iterator to start of container with Bernstein coefficients | |
end | iterator to end of container |
Definition at line 89 of file BernsteinMulti.h.
Go::BernsteinMulti::BernsteinMulti | ( | double | coef | ) | [inline, explicit] |
Constructs a constant polynomial.
coef | the constant value of the polynomial |
Definition at line 94 of file BernsteinMulti.h.
int Go::BernsteinMulti::degreeU | ( | ) | const [inline] |
Get the degree in the first parameter direction.
Definition at line 99 of file BernsteinMulti.h.
int Go::BernsteinMulti::degreeV | ( | ) | const [inline] |
Get the degree in the second parameter direction.
Definition at line 103 of file BernsteinMulti.h.
double Go::BernsteinMulti::operator() | ( | double | u, | |
double | v | |||
) | const |
Evaluation operator, based on the de Casteljau algorithm.
u | first parameter | |
v | second parameter |
double Go::BernsteinMulti::operator() | ( | const Vector2D & | pt | ) | const [inline] |
Evaluation operator - as above, but taking the arguments in a Vector2D.
pt | parameter point |
Definition at line 134 of file BernsteinMulti.h.
double Go::BernsteinMulti::operator() | ( | const std::vector< double > & | pt | ) | const [inline] |
Evaluation operator - as above, but taking the arguments in a std::vector.
pt | parameter point |
Definition at line 140 of file BernsteinMulti.h.
bool Go::BernsteinMulti::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::BernsteinMulti::isStrictlyPositive | ( | const double | eps = 0.0 |
) | const |
Check if polynomial is strictly positive.
eps | the threshold value with which every coefficient is compared |
bool Go::BernsteinMulti::isStrictlyNegative | ( | const double | eps = 0.0 |
) | const |
Check if polynomial is strictly negative.
eps | the threshold value with which every coefficient is compared |
bool Go::BernsteinMulti::isNonNegative | ( | const double | eps = 0.0 |
) | const |
Check if polynomial is non-negative.
eps | the threshold value with which every coefficient is compared |
double Go::BernsteinMulti::norm | ( | ) | const |
Calculates the norm of the polynomial, defined as the sum of 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 domain [0,1]x[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::BernsteinMulti::normalize | ( | ) |
BernsteinMulti Go::BernsteinMulti::deriv | ( | int | der1, | |
int | der2 | |||
) | const |
Finds the derivative of the polynomial in terms of a new BernsteinMulti.
der1 | the order of derivatives requested in the first parameter direction | |
der2 | the order of derivatives requested in the second parameter direction |
double Go::BernsteinMulti::blossom | ( | const std::vector< double > & | uvec, | |
const std::vector< double > & | vvec | |||
) | const |
Evaluates the blossom of the polynomial.
The blossom of the polynomial of degree (m,n) is a multi-affine (m+n)-variate function that satisfies
and is symmetric in the first m and last n arguments separately.
uvec | the vector of values at which the blossom is evaluated in the first parameter direction | |
vvec | the vector of values at which the blossom is evaluated in the second parameter direction |
BernsteinMulti Go::BernsteinMulti::pickDomain | ( | double | u0, | |
double | u1, | |||
double | v0, | |||
double | v1 | |||
) | const |
Finds a new BernsteinMulti representing the original on some rectangular domain.
The new polynomial is defined on [0,1]x[0,1]. If p is the old polynomial and q is the new one, q is defined by
The function is implemented by blossoming.
u0 | the start of the interval in the first parameter direction | |
u1 | the end of the interval in the first parameter direction | |
v0 | the start of the interval in the second parameter direction | |
v1 | the end of the interval in the second parameter direction |
BernsteinPoly Go::BernsteinMulti::pickLine | ( | Array< double, 2 > | a, | |
Array< double, 2 > | b | |||
) | const |
Routine that picks out the line with endpoints a and b as a new BernsteinPoly.
The new polynomial is defined on [0,1]. If p is the old bivariate polynomial and q is the new one, q is defined by
The function is implemented by blossoming.
void Go::BernsteinMulti::degreeElevate | ( | int | du, | |
int | dv | |||
) |
Degree elevation.
du | the polynomial degree in which you want to represent this polynomial in the first parameter direction | |
dv | the polynomial degree in which you want to represent this polynomial in the second parameter direction |
BernsteinPoly Go::BernsteinMulti::bindU | ( | double | u | ) | const |
Function that "binds" the u-parameter.
BernsteinPoly Go::BernsteinMulti::bindV | ( | double | v | ) | const |
Function that "binds" the v-parameter.