cginfo.h

Go to the documentation of this file.
00001 #ifndef __cginfo_h
00002 #define __cginfo_h
00003 
00004 #include  <string>
00005 
00006 /*************************************************************/
00007 
00008 namespace Gascoigne
00009 {
00010 class StatisticData
00011 {
00012   double  _lastrate, _rate;
00013   int     _totaliter;
00014 
00015  public:
00016 
00017   double  rate     () const { return _rate; }
00018   double& rate     ()       { return _rate; }
00019   double& lastrate ()       { return _lastrate; }
00020   double  lastrate () const { return _lastrate; }
00021   int&    totaliter()       { return _totaliter; }
00022   int     totaliter() const { return _totaliter; }
00023 
00024   void reset();
00025 
00026   friend std::ostream& operator<<(std::ostream &s, const StatisticData& A);
00027 };
00028 
00029 /*************************************************************/
00030 
00031 class ControlData
00032 {
00033   std::string _status;
00034   int    _iteration;
00035   double _firstresidual, _residual, _aimedresidual;
00036   double _previousresidual;
00037   double _correction, _previouscorrection;
00038 
00039  public:
00040 
00041   ControlData();
00042 
00043   const std::string& status()     const { return _status;}
00044         std::string& status()           { return _status;}
00045   
00046   double& firstresidual()          { return _firstresidual;}
00047   double  firstresidual()    const { return _firstresidual;}
00048   double& residual     ()          { return _residual;}
00049   double  residual     ()    const { return _residual;}
00050   double& aimedresidual()          { return _aimedresidual;}
00051   double  aimedresidual()    const { return _aimedresidual;}
00052   double& previousresidual()       { return _previousresidual;}
00053   double  previousresidual() const { return _previousresidual;}
00054   int     iteration()        const { return _iteration;}
00055   int&    iteration()              { return _iteration;}
00056   double& correction     ()          { return _correction;}
00057   double  correction     ()    const { return _correction;}
00058   double& previouscorrection()       { return _previouscorrection;}
00059   double  previouscorrection() const { return _previouscorrection;}
00060 
00061   void reset();
00062 
00063   friend std::ostream& operator<<(std::ostream &s, const ControlData& A);
00064 };
00065 
00066 /*************************************************************/
00067 
00068 class UserData
00069 {
00070   std::string  _text;
00071   double _tol, _globaltol, _breaktol;
00072   int    _miniter,_maxiter, _printstep;
00073 
00074  public:
00075 
00076   double  tol()       const { return _tol;}
00077   double& tol()             { return _tol;}
00078   double  globaltol() const { return _globaltol;}
00079   double& globaltol()       { return _globaltol;}
00080   double  breaktol()  const { return _breaktol;}
00081   double& breaktol()        { return _breaktol;}
00082   int     miniter()   const { return _miniter;}
00083   int&    miniter()         { return _miniter;}
00084   int     maxiter()   const { return _maxiter;}
00085   int&    maxiter()         { return _maxiter;}
00086   int     printstep() const { return _printstep;}
00087   int&    printstep()       { return _printstep;}
00088 
00089   const std::string& text() const { return _text; }
00090         std::string& text()       { return _text; }
00091 
00092   friend std::ostream& operator<<(std::ostream &s, const UserData& A);
00093 };
00094 
00095 /*************************************************************/
00096 
00097 class CGInfo
00098 {
00099  protected:
00100 
00101   StatisticData SD;
00102   ControlData   CD;
00103   UserData      UD;
00104   
00105   void compute_reduction_rate();
00106   
00107  public:
00108   
00109   CGInfo(const std::string& txt);
00110   CGInfo(double f = 1.e-6, double r=1.e-14, int p = 10, 
00111          int m = 100, const std::string& txt = "It: ");
00112 
00113   friend std::ostream& operator<<(std::ostream &s, const CGInfo& A);
00114   
00115   const StatisticData& statistics() const { return SD; }
00116         StatisticData& statistics()       { return SD; }
00117   const ControlData&   control()    const { return CD; }
00118         ControlData&   control()          { return CD; }
00119   const UserData&      user()       const { return UD; }
00120         UserData&      user()             { return UD; }
00121   
00122   bool check(double res, double corr=0.);
00123   void reset();
00124 };
00125 }
00126 
00127 /*************************************************************/
00128 
00129 #endif

Generated on Thu Sep 14 10:34:34 2006 for Gascoigne by  doxygen 1.4.7