MathTL
numerics/ortho_poly.h
00001 // -*- c++ -*-
00002 
00003 // +--------------------------------------------------------------------+
00004 // | This file is part of MathTL - the Mathematical Template Library    |
00005 // |                                                                    |
00006 // | Copyright (c) 2002-2009                                            |
00007 // | Thorsten Raasch, Manuel Werner                                     |
00008 // +--------------------------------------------------------------------+
00009 
00010 #ifndef _MATHTL_ORTHO_POLY_H
00011 #define _MATHTL_ORTHO_POLY_H
00012 
00013 #include <cmath>
00014 #include <utils/array1d.h>
00015 #include <algebra/vector.h>
00016 #include <algebra/polynomial.h>
00017 
00018 namespace MathTL
00019 {
00020   // some tools for polynomials that fulfill a three-term recurrence
00021   // relation (such as orthogonal polynomials, but also the monomials)
00022   //
00023   // reference: Deuflhard/Bornemann, Numerische Mathematik 1
00024 
00039   class OrthogonalPolynomial
00040   {
00041   public:
00043     virtual ~OrthogonalPolynomial() {}
00044 
00048     virtual double a(const unsigned int k) const = 0;
00049 
00053     virtual double b(const unsigned int k) const = 0;
00054 
00058     double operator () (const unsigned int n, const double x) const;
00059 
00063     Polynomial<double> assemble(const unsigned int n) const;
00064 
00069     double forwardSummation(const Vector<double>& coeffs, const double x) const;
00070 
00079     double adjointSummation(const Vector<double>& coeffs, const double x) const;
00080   };
00081 
00085   class Monomial : public OrthogonalPolynomial
00086   {
00087   public:
00088     double a(const unsigned int k) const;
00089     double b(const unsigned int k) const;
00090   };
00091 
00096   class ChebyshevPolynomial : public OrthogonalPolynomial
00097   {
00098   public:
00099     double a(const unsigned int k) const;
00100     double b(const unsigned int k) const;
00101   };
00102 
00107   class LegendrePolynomial : public OrthogonalPolynomial
00108   {
00109   public:
00110     double a(const unsigned int k) const;
00111     double b(const unsigned int k) const;
00112   };
00113 
00132   class GenMomentsPolynomial : public OrthogonalPolynomial
00133   {
00134   public:
00141     GenMomentsPolynomial(const Array1D<double>& moments,
00142                          const double a, const double b,
00143                          const unsigned int N);
00144     
00148     GenMomentsPolynomial(const Array1D<double>& moments,
00149                          const OrthogonalPolynomial& T,
00150                          const double a, const double b,
00151                          const unsigned int N);
00152 
00153     virtual ~GenMomentsPolynomial() {}
00154 
00155     double a(const unsigned int k) const;
00156     double b(const unsigned int k) const;
00157     
00158   private:
00162     Array1D<double> ak_, bk_;
00163   };
00164 }
00165 
00166 // include implementation of inline functions
00167 #include <numerics/ortho_poly.cpp>
00168 
00169 #endif
 All Classes Functions Variables Typedefs Enumerations