MathTL
numerics/preconditioner.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_PRECONDITIONER_H
00011 #define _MATHTL_PRECONDITIONER_H
00012 
00013 #include <algebra/vector.h>
00014 
00015 namespace MathTL
00016 {
00033   template <class VECTOR>
00034   class Preconditioner
00035   {
00036   public:
00040     typedef typename VECTOR::size_type size_type;
00041 
00045     virtual ~Preconditioner() = 0;
00046     
00050     virtual const size_type row_dimension() const = 0;
00051 
00055     const size_type column_dimension() const { return row_dimension(); }
00056 
00060     virtual void apply(const VECTOR& x, VECTOR& Px) const = 0;
00061 
00065     virtual void apply_preconditioner(const VECTOR& Px, VECTOR& x) const = 0;
00066   };
00067 
00071   template <class MATRIX, class VECTOR>
00072   class IdentityPreconditioner
00073     : public Preconditioner<VECTOR>
00074   {
00075   public:
00079     typedef typename VECTOR::size_type size_type;
00080 
00084     IdentityPreconditioner(const MATRIX& A);
00085 
00089     const size_type row_dimension() const { return A.row_dimension(); }
00090 
00094     void apply(const VECTOR& x, VECTOR& Px) const;
00095 
00099     void apply_preconditioner(const VECTOR& Px, VECTOR& x) const;
00100 
00101   protected:
00105     const MATRIX& A;
00106   };
00107 
00111   template <class MATRIX, class VECTOR>
00112   class JacobiPreconditioner
00113     : public Preconditioner<VECTOR>
00114   {
00115   public:
00119     typedef typename VECTOR::size_type size_type;
00120 
00124     JacobiPreconditioner(const MATRIX& A);
00125 
00129     const size_type row_dimension() const { return A.row_dimension(); }
00130 
00134     void apply(const VECTOR& x, VECTOR& Px) const;
00135 
00139     void apply_preconditioner(const VECTOR& Px, VECTOR& x) const;
00140 
00141   protected:
00145     const MATRIX& A;
00146   };
00147 }
00148 
00149 #include <numerics/preconditioner.cpp>
00150 
00151 #endif
 All Classes Functions Variables Typedefs Enumerations