ROOT  6.06/09
Reference Guide
TDecompBase.h
Go to the documentation of this file.
1 // @(#)root/matrix:$Id$
2 // Authors: Fons Rademakers, Eddy Offermann Dec 2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TDecompBase
13 #define ROOT_TDecompBase
14 
15 ///////////////////////////////////////////////////////////////////////////
16 // //
17 // Decomposition Base class //
18 // //
19 // This class forms the base for all the decompositions methods in the //
20 // linear algebra package . //
21 // //
22 ///////////////////////////////////////////////////////////////////////////
23 
24 #include <limits>
25 
26 #ifndef ROOT_TMatrixD
27 #include "TMatrixD.h"
28 #endif
29 #ifndef ROOT_TMatrixDUtils
30 #include "TMatrixDUtils.h"
31 #endif
32 #ifndef ROOT_TVectorD
33 #include "TVectorD.h"
34 #endif
35 
36 class TDecompBase : public TObject
37 {
38 protected :
39  Double_t fTol; // sqrt(epsilon); epsilon is smallest number number so that 1+epsilon > 1
40  Double_t fDet1; // determinant mantissa
41  Double_t fDet2; // determinant exponent for powers of 2
42  Double_t fCondition; // matrix condition number
43  Int_t fRowLwb; // Row lower bound of decomposed matrix
44  Int_t fColLwb; // Column lower bound of decomposed matrix
45 
46  void ResetStatus() { for (Int_t i = 14; i < 22; i++) ResetBit(BIT(i)); }
47  Int_t Hager (Double_t& est,Int_t iter=5);
48  static void DiagProd (const TVectorD &diag,Double_t tol,Double_t &d1,Double_t &d2);
49 
50  virtual const TMatrixDBase &GetDecompMatrix() const = 0;
51 
53  kInit = BIT(14),
55  kValuesSet = BIT(16),
56  kMatrixSet = BIT(17),
59  kCondition = BIT(20),
60  kSingular = BIT(21)
61  };
62 
63  enum {kWorkMax = 100}; // size of work array's in several routines
64 
65 public :
66  TDecompBase();
67  TDecompBase(const TDecompBase &another);
68  virtual ~TDecompBase() {};
69 
70  inline Double_t GetTol () const { return fTol; }
71  inline Double_t GetDet1 () const { return fDet1; }
72  inline Double_t GetDet2 () const { return fDet2; }
73  inline Double_t GetCondition () const { return fCondition; }
74  virtual Int_t GetNrows () const = 0;
75  virtual Int_t GetNcols () const = 0;
76  Int_t GetRowLwb () const { return fRowLwb; }
77  Int_t GetColLwb () const { return fColLwb; }
78  inline Double_t SetTol (Double_t tol);
79 
80  virtual Double_t Condition ();
81  virtual void Det (Double_t &d1,Double_t &d2);
82  virtual Bool_t Decompose () = 0;
83  virtual Bool_t Solve ( TVectorD &b) = 0;
84  virtual TVectorD Solve (const TVectorD& b,Bool_t &ok) = 0;
85  virtual Bool_t Solve ( TMatrixDColumn& b) = 0;
86  virtual Bool_t TransSolve ( TVectorD &b) = 0;
87  virtual TVectorD TransSolve (const TVectorD &b,Bool_t &ok) = 0;
88  virtual Bool_t TransSolve ( TMatrixDColumn& b) = 0;
89 
90  virtual Bool_t MultiSolve (TMatrixD &B);
91 
92  void Print(Option_t *opt="") const;
93 
94  TDecompBase &operator= (const TDecompBase &source);
95 
96  ClassDef(TDecompBase,2) // Matrix Decomposition Base
97 };
98 
100 {
101  const Double_t oldTol = fTol;
102  if (newTol >= 0.0)
103  fTol = newTol;
104  return oldTol;
105 }
106 
108 void ApplyHouseHolder(const TVectorD &vc,Double_t up,Double_t b,Int_t lp,Int_t l,TMatrixDRow &cr);
110 void ApplyHouseHolder(const TVectorD &vc,Double_t up,Double_t b,Int_t lp,Int_t l,TVectorD &cv);
113 void ApplyGivens ( Double_t &z1,Double_t &z2,Double_t c,Double_t s);
114 
115 #endif
Double_t GetTol() const
Definition: TDecompBase.h:70
static double B[]
virtual Bool_t MultiSolve(TMatrixD &B)
Solve set of equations with RHS in columns of B.
const Double_t * v1
Definition: TArcBall.cxx:33
virtual Bool_t TransSolve(TVectorD &b)=0
Int_t Hager(Double_t &est, Int_t iter=5)
Double_t fCondition
Definition: TDecompBase.h:42
Int_t fRowLwb
Definition: TDecompBase.h:43
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:120
virtual Bool_t Decompose()=0
void Print(Option_t *opt="") const
Print class members.
virtual const TMatrixDBase & GetDecompMatrix() const =0
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t DefHouseHolder(const TVectorD &vc, Int_t lp, Int_t l, Double_t &up, Double_t &b, Double_t tol=0.0)
Define a Householder-transformation through the parameters up and b .
Double_t fTol
Definition: TDecompBase.h:39
Double_t SetTol(Double_t tol)
Definition: TDecompBase.h:99
#define ClassDef(name, id)
Definition: Rtypes.h:254
TDecompBase & operator=(const TDecompBase &source)
Assignment operator.
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
void ApplyGivens(Double_t &z1, Double_t &z2, Double_t c, Double_t s)
Apply a Givens transformation as defined by c and s to the vector compenents v1 and v2 ...
Int_t GetColLwb() const
Definition: TDecompBase.h:77
Int_t fColLwb
Definition: TDecompBase.h:44
static void DiagProd(const TVectorD &diag, Double_t tol, Double_t &d1, Double_t &d2)
Double_t GetCondition() const
Definition: TDecompBase.h:73
const double tol
void ApplyHouseHolder(const TVectorD &vc, Double_t up, Double_t b, Int_t lp, Int_t l, TMatrixDRow &cr)
Apply Householder-transformation.
virtual Int_t GetNcols() const =0
void DefGivens(Double_t v1, Double_t v2, Double_t &c, Double_t &s)
Defines a Givens-rotation by calculating 2 rotation parameters c and s.
virtual ~TDecompBase()
Definition: TDecompBase.h:68
virtual Bool_t Solve(TVectorD &b)=0
TLine * l
Definition: textangle.C:4
void ResetStatus()
Definition: TDecompBase.h:46
Double_t GetDet2() const
Definition: TDecompBase.h:72
virtual Int_t GetNrows() const =0
Double_t fDet2
Definition: TDecompBase.h:41
Double_t fDet1
Definition: TDecompBase.h:40
Int_t GetRowLwb() const
Definition: TDecompBase.h:76
double Double_t
Definition: RtypesCore.h:55
virtual void Det(Double_t &d1, Double_t &d2)
Matrix determinant det = d1*TMath::Power(2.,d2)
Mother of all ROOT objects.
Definition: TObject.h:58
void DefAplGivens(Double_t &v1, Double_t &v2, Double_t &c, Double_t &s)
Define and apply a Givens-rotation by calculating 2 rotation parameters c and s.
virtual Double_t Condition()
Matrix condition number.
void ResetBit(UInt_t f)
Definition: TObject.h:172
Double_t GetDet1() const
Definition: TDecompBase.h:71