12 #ifndef ROOT_TDecompSVD
13 #define ROOT_TDecompSVD
23 class TDecompSVD :
public TDecompBase
32 static Bool_t Bidiagonalize(TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag);
33 static Bool_t Diagonalize (TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag);
34 static void Diag_1 (TMatrixD &v,TVectorD &sDiag,TVectorD &oDiag,Int_t k);
35 static void Diag_2 (TVectorD &sDiag,TVectorD &oDiag,Int_t k,Int_t l);
36 static void Diag_3 (TMatrixD &v,TMatrixD &u,TVectorD &sDiag,TVectorD &oDiag,Int_t k,Int_t l);
37 static void SortSingular (TMatrixD &v,TMatrixD &u,TVectorD &sDiag);
39 virtual const TMatrixDBase &GetDecompMatrix()
const {
return fU; }
43 enum {kWorkMax = 100};
45 TDecompSVD(): fU(), fV(), fSig() {}
46 TDecompSVD(Int_t nrows,Int_t ncols);
47 TDecompSVD(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
48 TDecompSVD(
const TMatrixD &m,Double_t tol = 0.0);
49 TDecompSVD(
const TDecompSVD &another);
50 virtual ~TDecompSVD() {}
52 const TMatrixD GetMatrix ();
53 virtual Int_t GetNrows ()
const;
54 virtual Int_t GetNcols ()
const;
55 const TMatrixD &GetU () {
if ( !TestBit(kDecomposed) ) Decompose();
57 const TMatrixD &GetV () {
if ( !TestBit(kDecomposed) ) Decompose();
59 const TVectorD &GetSig () {
if ( !TestBit(kDecomposed) ) Decompose();
62 virtual void SetMatrix (
const TMatrixD &a);
64 virtual Bool_t Decompose ();
65 virtual Bool_t Solve ( TVectorD &b);
66 virtual TVectorD Solve (
const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = Solve(x);
67 const Int_t rowLwb = GetRowLwb();
68 x.ResizeTo(rowLwb,rowLwb+GetNcols()-1);
70 virtual Bool_t Solve ( TMatrixDColumn &b);
71 virtual Bool_t TransSolve ( TVectorD &b);
72 virtual TVectorD TransSolve (
const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = TransSolve(x);
73 const Int_t rowLwb = GetRowLwb();
74 x.ResizeTo(rowLwb,rowLwb+GetNcols()-1);
76 virtual Bool_t TransSolve ( TMatrixDColumn &b);
77 virtual Double_t Condition ();
78 virtual void Det (Double_t &d1,Double_t &d2);
80 Bool_t Invert (TMatrixD &inv);
81 TMatrixD Invert (Bool_t &status);
82 TMatrixD Invert () {Bool_t status;
return Invert(status); }
84 void Print(Option_t *opt =
"")
const;
86 TDecompSVD &operator= (
const TDecompSVD &source);
88 ClassDef(TDecompSVD,1)