Warning: this documentation for the development version is under construction.

/home/vivien/public_html/.src_seldon/computation/solver/iterative/Iterative.hxx

00001 // Copyright (C) 2003-2009 Marc Duruflé
00002 //
00003 // This file is part of the linear-algebra library Seldon,
00004 // http://seldon.sourceforge.net/.
00005 //
00006 // Seldon is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the Free
00008 // Software Foundation; either version 2.1 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00018 
00019 
00020 #ifndef SELDON_FILE_ITERATIVE_HXX
00021 
00022 namespace Seldon
00023 {
00025   class Preconditioner_Base
00026   {
00027   public :
00028 
00029     Preconditioner_Base();
00030 
00031     // solving M z = r
00032     template<class Matrix1, class Vector1>
00033     void Solve(const Matrix1& A, const Vector1 & r, Vector1 & z);
00034 
00035     // solving M^t z = r
00036     template<class Matrix1, class Vector1>
00037     void TransSolve(const Matrix1& A, const Vector1& r, Vector1 & z);
00038 
00039   };
00040 
00041 
00043 
00047   template<class Titer>
00048   class Iteration
00049   {
00050   protected :
00051     Titer tolerance; 
00052     Titer facteur_reste; 
00053     int max_iter; 
00054     int nb_iter; 
00055     int error_code; 
00056     bool fail_convergence; 
00057 
00058 
00063     int print_level;
00064     bool init_guess_null; 
00065     int type_solver; 
00066     int parameter_restart; 
00067     int type_preconditioning; 
00068 
00069   public :
00070 
00071     Iteration();
00072     Iteration(int max_iteration, const Titer& tol);
00073     Iteration(const Iteration<Titer>& outer);
00074 
00075     int GetTypeSolver() const;
00076     int GetRestart() const;
00077     Titer GetFactor() const;
00078     Titer GetTolerance() const;
00079     int GetNumberIteration() const;
00080 
00081     void SetSolver(int type_resolution, int param_restart, int type_prec);
00082     void SetRestart(int m);
00083     void SetTolerance(Titer stopping_criterion);
00084     void SetMaxNumberIteration(int max_iteration);
00085     void SetNumberIteration(int nb);
00086 
00087     void ShowMessages();
00088     void ShowFullHistory();
00089     void HideMessages();
00090 
00091     template<class Vector1>
00092     int Init(const Vector1& r);
00093     bool First() const;
00094 
00095     bool IsInitGuess_Null() const;
00096     void SetInitGuess(bool type) { init_guess_null = type; }
00097 
00098     template<class Vector1>
00099     bool Finished(const Vector1& r) const;
00100     bool Finished(const Titer& r) const;
00101 
00102     void Fail(int i, const string& s);
00103 
00104     Iteration& operator ++ (void);
00105 
00106     int ErrorCode() const;
00107 
00108   };
00109 
00110 } // end namespace
00111 
00112 #define SELDON_FILE_ITERATIVE_HXX
00113 #endif