LAMA
/home/brandes/workspace/LAMA/src/lama/solver/GMRES.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_GMRES_HPP_
00034 #define LAMA_GMRES_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // base classes
00040 #include <lama/solver/IterativeSolver.hpp>
00041 
00042 // boost
00043 #include <boost/scoped_array.hpp>
00044 
00045 namespace lama
00046 {
00047 
00052 class LAMA_DLL_IMPORTEXPORT GMRES : public IterativeSolver
00053 {
00054 public:
00055 
00061     GMRES(const std::string& id);
00062 
00069     GMRES(const std::string& id, LoggerPtr logger);
00070 
00074     GMRES( const GMRES& other );
00075 
00076     virtual ~GMRES();
00077 
00078     virtual void initialize(const Matrix&  coefficients);
00079 
00080     void setKrylovDim( unsigned int krylovDim );
00081 
00088     virtual SolverPtr copy();
00089 
00090     struct GMRESRuntime : IterativeSolverRuntime
00091     {
00092         GMRESRuntime();
00093         virtual ~GMRESRuntime();
00094         
00095         // arrays to store rotations
00096         boost::scoped_array<double>         mCC;
00097         boost::scoped_array<double>         mSS;
00098 
00099         // array for Hessenberg equation
00100         // H*y=g
00101         boost::scoped_array<double>         mG;
00102         boost::scoped_array<double>         mY;
00103 
00104         // Hessenberg matrix
00105         // mH:  Upper triangular (columnwise)
00106         // mHd: diagonal band h(i+1,i)
00107         boost::scoped_array<double>         mH;
00108         boost::scoped_array<double>         mHd;
00109 
00110         // krylov space
00111         std::vector<Vector*>                *mV;
00112 
00113         // temp-arrays
00114         Vector                              *mW;
00115         Vector                              *mT;
00116 
00117         // remember starting solution
00118         // only needed if x is modified within krylov loop
00119         Vector                              *mX0;
00120     };
00121 
00125     virtual GMRESRuntime& getRuntime();
00126 
00130     virtual const GMRESRuntime& getConstRuntime() const;
00131 
00132 protected:
00133 
00134     virtual void iterate();
00135 
00136     GMRESRuntime mGMRESRuntime;
00137 
00138     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00139 
00140 private:
00141 
00142     void updateX( unsigned int i );
00143 
00144     // krylov dimension
00145     unsigned int                        mKrylovDim;
00146 };
00147 
00148 }  // namespace lama
00149 
00150 #endif // LAMA_GMRES_HPP_