MathTL
 All Classes Functions Variables Typedefs Enumerations
Public Member Functions | Protected Member Functions
MathTL::Polynomial< C > Class Template Reference

#include <polynomial.h>

Inheritance diagram for MathTL::Polynomial< C >:
MathTL::Vector< C > MathTL::Function< 1, C > MathTL::FunctionTime

List of all members.

Public Member Functions

 Polynomial ()
 Polynomial (const Polynomial< C > &p)
 Polynomial (const Vector< C > &coeffs)
 Polynomial (const C c)
virtual ~Polynomial ()
unsigned int degree () const
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)
value (const C x) const
value (const C x, const unsigned int derivative) const
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 ()

Detailed Description

template<class C>
class MathTL::Polynomial< C >

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.


Constructor & Destructor Documentation

template<class C >
MathTL::Polynomial< C >::Polynomial ( )

default constructor: yields the zero polynomial of degree zero

template<class C >
MathTL::Polynomial< C >::Polynomial ( const Polynomial< C > &  p)

copy constructor

template<class C >
MathTL::Polynomial< C >::Polynomial ( const Vector< C > &  coeffs)

constructor from a coefficient vector

template<class C >
MathTL::Polynomial< C >::Polynomial ( const C  c) [explicit]

constructor from a constant

template<class C >
MathTL::Polynomial< C >::~Polynomial ( ) [virtual]

virtual destructor


Member Function Documentation

template<class C >
void MathTL::Polynomial< C >::add ( const Polynomial< C > &  p)

pointwise sum of two polynomials *this += p

template<class C >
void MathTL::Polynomial< C >::add ( const C  s,
const Polynomial< C > &  p 
)

pointwise weighted sum of two polynomials *this += s*p

template<class C >
void MathTL::Polynomial< C >::chain ( const Polynomial< C > &  p)

substitute another polynomial into this one *this <- *this p

template<class C >
unsigned int MathTL::Polynomial< C >::degree ( ) const [inline]

degree of the polynomial

template<class C >
Polynomial< C > MathTL::Polynomial< C >::differentiate ( ) const

(symbolic) differentiation

template<class C >
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

template<class C >
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

template<class C >
C MathTL::Polynomial< C >::get_coefficient ( const unsigned int  k) const [inline]

read-only access to single coefficients

template<class C >
void MathTL::Polynomial< C >::get_coefficients ( Vector< C > &  coeffs) const [inline]

get all coefficients at once

template<class C >
double MathTL::Polynomial< C >::inner_product ( Polynomial< C >  p2,
double  a,
double  b 
)

inner product

template<class C >
Polynomial< C > MathTL::Polynomial< C >::integrate ( ) const

(symbolic) integration

template<class C >
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

template<class C >
void MathTL::Polynomial< C >::multiply ( const Polynomial< C > &  p)

pointwise multiplication with another polynomial *this *= p

template<class C >
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!)

template<class C >
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!)

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator*= ( const C  c)

multiplication with a real number

Reimplemented from MathTL::Vector< C >.

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator*= ( const Polynomial< C > &  p) [inline]

pointwise multiplication with another polynomial

template<class C >
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!)

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator+= ( const Polynomial< C > &  p) [inline]

pointwise sum of two polynomials

template<class C >
Polynomial< C > MathTL::Polynomial< C >::operator- ( ) const [inline]

sign (makes a copy of *this)

template<class C >
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!)

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator-= ( const Polynomial< C > &  p) [inline]

pointwise difference of two polynomials

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator= ( const Polynomial< C > &  p)

assignment of another polynomial

template<class C >
Polynomial< C > & MathTL::Polynomial< C >::operator= ( const C  c)

assignment of a constant polynomial (implicit conversion)

Reimplemented from MathTL::Vector< C >.

template<class C >
Polynomial< C > MathTL::Polynomial< C >::power ( const unsigned int  k) const

raise the polynomial to some power

template<class C >
void MathTL::Polynomial< C >::sadd ( const C  s,
const Polynomial< C > &  p 
)

pointwise weighted sum of two polynomials *this = s*(*this) + v

template<class C >
void MathTL::Polynomial< C >::scale ( const C  s)

in place scaling p(x) -> p(s*x)

Reimplemented from MathTL::Vector< C >.

template<class C >
void MathTL::Polynomial< C >::set_coefficient ( const unsigned int  k,
const C  coeff 
)

write access to single coefficients

template<class C >
void MathTL::Polynomial< C >::set_coefficients ( const Vector< C > &  coeffs)

set all coefficients at once

template<class C >
void MathTL::Polynomial< C >::shift ( const C  s)

in place shift p(x) -> p(x+s)

template<class C >
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 )

template<class C >
void MathTL::Polynomial< C >::subtract ( const Polynomial< C > &  p)

pointwise difference of two polynomials *this -= p

template<class C >
void MathTL::Polynomial< C >::trim ( ) [protected]

trim leading zero coefficients in the polynomial

template<class C >
C MathTL::Polynomial< C >::value ( const C  x) const

evaluate the polynomial (Horner scheme)

template<class C >
C MathTL::Polynomial< C >::value ( const C  x,
const unsigned int  derivative 
) const

evaluate n-th derivative of the polynomial (full Horner scheme)

template<class C >
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))

template<class 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))


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations