00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TDecompSVD
00013 #define ROOT_TDecompSVD
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ROOT_TDecompBase
00022 #include "TDecompBase.h"
00023 #endif
00024
00025 class TDecompSVD : public TDecompBase
00026 {
00027 protected :
00028
00029
00030 TMatrixD fU;
00031 TMatrixD fV;
00032 TVectorD fSig;
00033
00034 static Bool_t Bidiagonalize(TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag);
00035 static Bool_t Diagonalize (TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag);
00036 static void Diag_1 (TMatrixD &v,TVectorD &sDiag,TVectorD &oDiag,Int_t k);
00037 static void Diag_2 (TVectorD &sDiag,TVectorD &oDiag,Int_t k,Int_t l);
00038 static void Diag_3 (TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag,Int_t k,Int_t l);
00039 static void SortSingular (TMatrixD &v,TMatrixD &u,TVectorD &sDiag);
00040
00041 virtual const TMatrixDBase &GetDecompMatrix() const { return fU; }
00042
00043 public :
00044
00045 enum {kWorkMax = 100};
00046
00047 TDecompSVD(): fU(), fV(), fSig() {}
00048 TDecompSVD(Int_t nrows,Int_t ncols);
00049 TDecompSVD(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
00050 TDecompSVD(const TMatrixD &m,Double_t tol = 0.0);
00051 TDecompSVD(const TDecompSVD &another);
00052 virtual ~TDecompSVD() {}
00053
00054 const TMatrixD GetMatrix ();
00055 virtual Int_t GetNrows () const { return fU.GetNrows(); }
00056 virtual Int_t GetNcols () const { return fV.GetNcols(); }
00057 const TMatrixD &GetU () { if ( !TestBit(kDecomposed) ) Decompose();
00058 return fU; }
00059 const TMatrixD &GetV () { if ( !TestBit(kDecomposed) ) Decompose();
00060 return fV; }
00061 const TVectorD &GetSig () { if ( !TestBit(kDecomposed) ) Decompose();
00062 return fSig; }
00063
00064 virtual void SetMatrix (const TMatrixD &a);
00065
00066 virtual Bool_t Decompose ();
00067 virtual Bool_t Solve ( TVectorD &b);
00068 virtual TVectorD Solve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = Solve(x);
00069 const Int_t rowLwb = GetRowLwb();
00070 x.ResizeTo(rowLwb,rowLwb+GetNcols()-1);
00071 return x; }
00072 virtual Bool_t Solve ( TMatrixDColumn &b);
00073 virtual Bool_t TransSolve ( TVectorD &b);
00074 virtual TVectorD TransSolve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = TransSolve(x);
00075 const Int_t rowLwb = GetRowLwb();
00076 x.ResizeTo(rowLwb,rowLwb+GetNcols()-1);
00077 return x; }
00078 virtual Bool_t TransSolve ( TMatrixDColumn &b);
00079 virtual Double_t Condition ();
00080 virtual void Det (Double_t &d1,Double_t &d2);
00081
00082 Bool_t Invert (TMatrixD &inv);
00083 TMatrixD Invert (Bool_t &status);
00084 TMatrixD Invert () {Bool_t status; return Invert(status); }
00085
00086 void Print(Option_t *opt ="") const;
00087
00088 TDecompSVD &operator= (const TDecompSVD &source);
00089
00090 ClassDef(TDecompSVD,1)
00091 };
00092
00093 #endif