Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

TDSPLinearSolver.h

Go to the documentation of this file.
00001 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef TDSPLINEARSOLVER_H
00019 #define TDSPLINEARSOLVER_H
00020 
00021 #include <TList.h>
00022 #include <TDSPVector.h>
00023 #include <TDSPMatrix.h>
00024 #include <TDSPSolver.h>
00025 
00030 enum eLinearSolveMethod {
00031   kLinearSolveJacobi,
00032   kLinearSolveGaussSeidel,
00033   kLinearSolveCG,
00034   kLinearSolveGaussSeidelBinary,
00035   kLinearSolveML,
00036   kLinearSolveGaussSeidelQpsk,
00037   kLinearSolveNothing
00038 };
00039 
00040 class TDSPLinearSolver : public TDSPSolver  {
00041 
00042 
00043  protected:
00044 
00045   eLinearSolveMethod fMethod;
00046 
00047   TList       fAList; // List of Matrices
00048 
00049   UInt_t      fIterations; // The Number of Iterations of the last call
00050   UInt_t      fMaxIterations; // The maximal number of Iterations, after stopping calculations
00051   Double_t    fMeanIterations; // The mean number Iterations
00052 
00053   Double_t    fStopPrecision; // the Stop Precision of the iterations
00054   Double_t    fPrecision; // the last precision
00055   Double_t    fMeanPrecision; // The mean precision
00056 
00057   UInt_t      fAccumulation; // The accumulated number for making the averages
00058 
00059   Bool_t      fUsingAStack; 
00060 
00061   void        _push_means_();  // Help routine - which pushs a new values to the means
00062   void        _reset_means_(); // Help routine - which resets the mean-calculations
00063 
00064   // fY = fA * X + fB 
00065 
00066   TDSPVector* fB; 
00067   TDSPMatrix* fA; 
00068 
00069   TDSPVector* fGuessX; 
00070 
00071 
00072   // Hard Decisions
00073 
00074   UInt_t      fIter_Serial_HD;    // Do Serial Hard Decisions for fIterations>=fIter_Serial_HD (default=999999)
00075   UInt_t      fIter_Parallel_HD;  // Do Parallel Hard Decisions for fIterations>=fIter_Serial_HD (default=999999)
00076 
00077   // Some Helpers
00078 
00079   TDSPVector  Xtmp; // a temporary vector ...
00080 
00081  public: 
00082 
00083   // Constructor / Destructor
00084 
00085   TDSPLinearSolver(TDSPMatrix *a = NULL, TDSPVector *b=NULL,
00086            TDSPVector *y = NULL);
00087 
00088   ~TDSPLinearSolver();
00089 
00090   virtual void Print();
00091 
00092   // Get/Set Methods
00093 
00094   void SetMethod(eLinearSolveMethod e) { fMethod = e;}; // Set Method
00095 
00096   void SetA(TDSPMatrix*a);             // Set the Matrix a of the equation y=Ax+b
00097   void SetA(TDSPMatrix&a) { SetA(&a);}; // Set the Matrix a of the equation y=Ax+b
00098   void SetB(TDSPVector*b) { fB = b;};   // Set the Vector b of the equation y=Ax+b
00099   void SetB(TDSPVector&b) { SetB(&b);}; // Set the Vector b of the equation y=Ax+b
00100   void Guess(TDSPVector*g) { fGuessX = g;};   // Set the initial Guess of Vector x of the equation y=Ax+b
00101   void Guess(TDSPVector&g) { Guess(&g);}; // Set the initial Guess of Vector x of the equation y=Ax+b
00102   void Set(TDSPMatrix*a, TDSPVector *b, TDSPVector *y) { // Set Matrix a, Vector b , Vector y
00103     SetA(a);SetB(b);SetY(y);};
00104 
00105   void SetMaxIterations(UInt_t m) { fMaxIterations=m;};  // Set the maximal number of iterations
00106   void SetStopPrecision(Double_t e) { fStopPrecision = e;}; // Set the Stop Precision
00107  
00108   void SetSerialHD(UInt_t start) { fIter_Serial_HD = start; } // Use Serial Hard Decisions for Iterations>=start
00109   void SetParalleHD(UInt_t start) { fIter_Parallel_HD = start; } // Use Parallel Hard Decisions for Iterations>=start
00110 
00111   eLinearSolveMethod GetMethod() const { return fMethod;}; // Get Method
00112   eLinearSolveMethod Method() const { return fMethod;}; // Get Method
00113 
00114   TDSPVector* B() const    { return fB; }; // Get the Vector b of the equation y=Ax+b
00115   TDSPVector* GetB() const { return fB; }; // Get the Vector b of the equation y=Ax+b
00116   TDSPMatrix* A() const    { return fA; }; // Get the Matrix a of the equation y=Ax+b
00117   TDSPMatrix* GetA() const { return fA; }; // Get the Matrix a of the equation y=Ax+b
00118 
00119   UInt_t   GetMaxIterations() const { return fMaxIterations;};  // Get the maximal number of iterations
00120   UInt_t   GetIterations() const { return fIterations;};  // Get the last number of iterations
00121   Double_t GetMeanIterations() const { return fMeanIterations;}; // Get the mean number of iterations
00122 
00123   Double_t GetStopPrecision() const { return fStopPrecision;}; // Get the Stop Precision
00124   Double_t GetPrecision() const { return fPrecision;}; // Get the Last Precision
00125   Double_t GetMeanPrecision() const { return fMeanPrecision;}; // Get the Mean Precision
00126 
00127   UInt_t   GetSerialHD() const { return fIter_Serial_HD;};
00128   UInt_t   GetParallelHD() const { return fIter_Parallel_HD;};
00129   
00130   void     ResetMeans() { _reset_means_();};
00131 
00132   virtual Int_t GetNumInputs();
00133   virtual Int_t GetNumOutputs();
00134 
00135   Bool_t Solve();
00136 
00137   void StackA(TDSPMatrix*);
00138 
00139   ClassDef(TDSPLinearSolver,1)
00140 
00141 };
00142 
00143 
00144 inline Int_t TDSPLinearSolver::GetNumInputs() {
00145   if (fA) return fA->GetCols();
00146   Error("GetNumInputs","Requesting number of Inputs - but no Matrix set !");
00147   return 0;
00148 }                 
00149 
00150 inline Int_t TDSPLinearSolver::GetNumOutputs() {
00151   if (fA) return fA->GetRows();
00152   Error("GetNumOutputs","Requesting number of Outputs - but no Matrix set !");
00153   return 0;
00154 }                 
00155 
00156 inline void TDSPLinearSolver::_push_means_() {
00157   fMeanIterations  = (fAccumulation*fMeanIterations+fIterations);
00158   fMeanPrecision   = (fAccumulation*fMeanPrecision+fPrecision);
00159   fMeanIterations /= ++fAccumulation;
00160   fMeanPrecision  /= fAccumulation;
00161 }
00162 
00163 inline void TDSPLinearSolver::_reset_means_() {
00164   fAccumulation   = 0;
00165   fMeanIterations = 0;
00166   fMeanPrecision  = 0;
00167 }
00168 
00169 #endif

Generated on Fri Apr 23 16:23:43 2004 by doxygen 1.3.2