#include <polynomial.h>
Public Member Functions | |
Polynomial () | |
Polynomial (const Polynomial< C > &p) | |
Polynomial (const Vector< C > &coeffs) | |
Polynomial (const C c) | |
virtual | ~Polynomial () |
unsigned int | degree () const |
C | get_coefficient (const unsigned int k) const |
void | get_coefficients (Vector< C > &coeffs) const |
void | set_coefficient (const unsigned int k, const C coeff) |
void | set_coefficients (const Vector< C > &coeffs) |
C | value (const C x) const |
C | value (const C x, const unsigned int derivative) const |
C | value (const Point< 1 > &p, const unsigned int component=0) const |
void | vector_value (const Point< 1 > &p, Vector< C > &values) const |
void | scale (const C s) |
void | shift (const C s) |
void | chain (const Polynomial< C > &p) |
Polynomial< C > | substitute_into (const Polynomial< C > &p) const |
Polynomial< C > & | operator= (const Polynomial< C > &p) |
Polynomial< C > & | operator= (const C c) |
void | add (const Polynomial< C > &p) |
void | add (const C s, const Polynomial< C > &p) |
void | sadd (const C s, const Polynomial< C > &p) |
Polynomial< C > & | operator+= (const Polynomial< C > &p) |
Polynomial< C > | operator+ (const Polynomial< C > &p) const |
void | subtract (const Polynomial< C > &p) |
Polynomial< C > & | operator-= (const Polynomial< C > &p) |
Polynomial< C > | operator- () const |
Polynomial< C > | operator- (const Polynomial< C > &p) const |
Polynomial< C > & | operator*= (const C c) |
Polynomial< C > | operator* (const C c) const |
void | multiply (const Polynomial< C > &p) |
Polynomial< C > & | operator*= (const Polynomial< C > &p) |
Polynomial< C > | operator* (const Polynomial< C > &p) |
Polynomial< C > | power (const unsigned int k) const |
void | divide (const Polynomial< C > &q, Polynomial< C > &p) const |
void | divide (const Polynomial< C > &q, Polynomial< C > &p, Polynomial< C > &r) const |
Polynomial | differentiate () const |
Polynomial | integrate () const |
double | integrate (const double a, const double b, const bool quadrature=false) const |
double | inner_product (Polynomial< C > p2, double a, double b) |
Protected Member Functions | |
void | trim () |
A template class for univariate polynomials of the form p(x)={k=0}^n a_k*x^k with coefficients from a class C.
You can perform
We derive Polynomial<C> from the class Function<1>, as it is indeed one. Since polynomials are completely determined by their coefficients, we derive the class also from Vector<C>, but protected to hide the Vector signature.
MathTL::Polynomial< C >::Polynomial | ( | ) |
default constructor: yields the zero polynomial of degree zero
MathTL::Polynomial< C >::Polynomial | ( | const Polynomial< C > & | p | ) |
copy constructor
MathTL::Polynomial< C >::Polynomial | ( | const Vector< C > & | coeffs | ) |
constructor from a coefficient vector
MathTL::Polynomial< C >::Polynomial | ( | const C | c | ) | [explicit] |
constructor from a constant
MathTL::Polynomial< C >::~Polynomial | ( | ) | [virtual] |
virtual destructor
void MathTL::Polynomial< C >::add | ( | const Polynomial< C > & | p | ) |
pointwise sum of two polynomials *this += p
void MathTL::Polynomial< C >::add | ( | const C | s, |
const Polynomial< C > & | p | ||
) |
pointwise weighted sum of two polynomials *this += s*p
void MathTL::Polynomial< C >::chain | ( | const Polynomial< C > & | p | ) |
substitute another polynomial into this one *this <- *this p
unsigned int MathTL::Polynomial< C >::degree | ( | ) | const [inline] |
degree of the polynomial
Polynomial< C > MathTL::Polynomial< C >::differentiate | ( | ) | const |
(symbolic) differentiation
void MathTL::Polynomial< C >::divide | ( | const Polynomial< C > & | q, |
Polynomial< C > & | p | ||
) | const |
divide the polynomial by another one with remainder: *this = p * q + r
void MathTL::Polynomial< C >::divide | ( | const Polynomial< C > & | q, |
Polynomial< C > & | p, | ||
Polynomial< C > & | r | ||
) | const |
divide the polynomial by another one with remainder: *this = p * q + r
C MathTL::Polynomial< C >::get_coefficient | ( | const unsigned int | k | ) | const [inline] |
read-only access to single coefficients
void MathTL::Polynomial< C >::get_coefficients | ( | Vector< C > & | coeffs | ) | const [inline] |
get all coefficients at once
double MathTL::Polynomial< C >::inner_product | ( | Polynomial< C > | p2, |
double | a, | ||
double | b | ||
) |
inner product
Polynomial< C > MathTL::Polynomial< C >::integrate | ( | ) | const |
(symbolic) integration
double MathTL::Polynomial< C >::integrate | ( | const double | a, |
const double | b, | ||
const bool | quadrature = false |
||
) | const |
integration over [a,b], optional use of (Gauss) quadrature formulae
void MathTL::Polynomial< C >::multiply | ( | const Polynomial< C > & | p | ) |
pointwise multiplication with another polynomial *this *= p
Polynomial< C > MathTL::Polynomial< C >::operator* | ( | const C | c | ) | const [inline] |
multiplication with a real number (don't use this extensively, since one copy has to be made!)
Polynomial< C > MathTL::Polynomial< C >::operator* | ( | const Polynomial< C > & | p | ) | [inline] |
pointwise multiplication with another polynomial (don't use this extensively, since one copy has to be made!)
Polynomial< C > & MathTL::Polynomial< C >::operator*= | ( | const C | c | ) |
multiplication with a real number
Reimplemented from MathTL::Vector< C >.
Polynomial< C > & MathTL::Polynomial< C >::operator*= | ( | const Polynomial< C > & | p | ) | [inline] |
pointwise multiplication with another polynomial
Polynomial< C > MathTL::Polynomial< C >::operator+ | ( | const Polynomial< C > & | p | ) | const [inline] |
pointwise sum of two polynomials (don't use this extensively, since one copy has to be made!)
Polynomial< C > & MathTL::Polynomial< C >::operator+= | ( | const Polynomial< C > & | p | ) | [inline] |
pointwise sum of two polynomials
Polynomial< C > MathTL::Polynomial< C >::operator- | ( | ) | const [inline] |
sign (makes a copy of *this)
Polynomial< C > MathTL::Polynomial< C >::operator- | ( | const Polynomial< C > & | p | ) | const [inline] |
pointwise difference of two polynomials (don't use this extensively, since one copy has to be made!)
Polynomial< C > & MathTL::Polynomial< C >::operator-= | ( | const Polynomial< C > & | p | ) | [inline] |
pointwise difference of two polynomials
Polynomial< C > & MathTL::Polynomial< C >::operator= | ( | const Polynomial< C > & | p | ) |
assignment of another polynomial
Polynomial< C > & MathTL::Polynomial< C >::operator= | ( | const C | c | ) |
assignment of a constant polynomial (implicit conversion)
Reimplemented from MathTL::Vector< C >.
Polynomial< C > MathTL::Polynomial< C >::power | ( | const unsigned int | k | ) | const |
raise the polynomial to some power
void MathTL::Polynomial< C >::sadd | ( | const C | s, |
const Polynomial< C > & | p | ||
) |
pointwise weighted sum of two polynomials *this = s*(*this) + v
void MathTL::Polynomial< C >::scale | ( | const C | s | ) |
in place scaling p(x) -> p(s*x)
Reimplemented from MathTL::Vector< C >.
void MathTL::Polynomial< C >::set_coefficient | ( | const unsigned int | k, |
const C | coeff | ||
) |
write access to single coefficients
void MathTL::Polynomial< C >::set_coefficients | ( | const Vector< C > & | coeffs | ) |
set all coefficients at once
void MathTL::Polynomial< C >::shift | ( | const C | s | ) |
in place shift p(x) -> p(x+s)
Polynomial< C > MathTL::Polynomial< C >::substitute_into | ( | const Polynomial< C > & | p | ) | const |
substitute another polynomial into this one without changing this object ( return *this p )
void MathTL::Polynomial< C >::subtract | ( | const Polynomial< C > & | p | ) |
pointwise difference of two polynomials *this -= p
void MathTL::Polynomial< C >::trim | ( | ) | [protected] |
trim leading zero coefficients in the polynomial
C MathTL::Polynomial< C >::value | ( | const C | x | ) | const |
evaluate the polynomial (Horner scheme)
C MathTL::Polynomial< C >::value | ( | const C | x, |
const unsigned int | derivative | ||
) | const |
evaluate n-th derivative of the polynomial (full Horner scheme)
C MathTL::Polynomial< C >::value | ( | const Point< 1 > & | p, |
const unsigned int | component = 0 |
||
) | const [inline] |
evaluate the polynomial (Horner scheme) (calls the above value(const C))
void MathTL::Polynomial< C >::vector_value | ( | const Point< 1 > & | p, |
Vector< C > & | values | ||
) | const [inline] |
evaluate the polynomial (Horner scheme) (calls the above value(const C))