00001
00009
00010
00011
00012
00013
00014
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;
00048
00049 UInt_t fIterations;
00050 UInt_t fMaxIterations;
00051 Double_t fMeanIterations;
00052
00053 Double_t fStopPrecision;
00054 Double_t fPrecision;
00055 Double_t fMeanPrecision;
00056
00057 UInt_t fAccumulation;
00058
00059 Bool_t fUsingAStack;
00060
00061 void _push_means_();
00062 void _reset_means_();
00063
00064
00065
00066 TDSPVector* fB;
00067 TDSPMatrix* fA;
00068
00069 TDSPVector* fGuessX;
00070
00071
00072
00073
00074 UInt_t fIter_Serial_HD;
00075 UInt_t fIter_Parallel_HD;
00076
00077
00078
00079 TDSPVector Xtmp;
00080
00081 public:
00082
00083
00084
00085 TDSPLinearSolver(TDSPMatrix *a = NULL, TDSPVector *b=NULL,
00086 TDSPVector *y = NULL);
00087
00088 ~TDSPLinearSolver();
00089
00090 virtual void Print();
00091
00092
00093
00094 void SetMethod(eLinearSolveMethod e) { fMethod = e;};
00095
00096 void SetA(TDSPMatrix*a);
00097 void SetA(TDSPMatrix&a) { SetA(&a);};
00098 void SetB(TDSPVector*b) { fB = b;};
00099 void SetB(TDSPVector&b) { SetB(&b);};
00100 void Guess(TDSPVector*g) { fGuessX = g;};
00101 void Guess(TDSPVector&g) { Guess(&g);};
00102 void Set(TDSPMatrix*a, TDSPVector *b, TDSPVector *y) {
00103 SetA(a);SetB(b);SetY(y);};
00104
00105 void SetMaxIterations(UInt_t m) { fMaxIterations=m;};
00106 void SetStopPrecision(Double_t e) { fStopPrecision = e;};
00107
00108 void SetSerialHD(UInt_t start) { fIter_Serial_HD = start; }
00109 void SetParalleHD(UInt_t start) { fIter_Parallel_HD = start; }
00110
00111 eLinearSolveMethod GetMethod() const { return fMethod;};
00112 eLinearSolveMethod Method() const { return fMethod;};
00113
00114 TDSPVector* B() const { return fB; };
00115 TDSPVector* GetB() const { return fB; };
00116 TDSPMatrix* A() const { return fA; };
00117 TDSPMatrix* GetA() const { return fA; };
00118
00119 UInt_t GetMaxIterations() const { return fMaxIterations;};
00120 UInt_t GetIterations() const { return fIterations;};
00121 Double_t GetMeanIterations() const { return fMeanIterations;};
00122
00123 Double_t GetStopPrecision() const { return fStopPrecision;};
00124 Double_t GetPrecision() const { return fPrecision;};
00125 Double_t GetMeanPrecision() const { return fMeanPrecision;};
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