Logo ROOT   6.21/01
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 "Rtypes.h"
25 
26 #include "TMatrixD.h"
27 #include "TMatrixDUtils.h"
28 #include "TObject.h"
29 #include "TVectorD.h"
30 
31 #include <limits>
32 
33 class TDecompBase : public TObject
34 {
35 protected :
36  Double_t fTol; // sqrt(epsilon); epsilon is smallest number number so that 1+epsilon > 1
37  Double_t fDet1; // determinant mantissa
38  Double_t fDet2; // determinant exponent for powers of 2
39  Double_t fCondition; // matrix condition number
40  Int_t fRowLwb; // Row lower bound of decomposed matrix
41  Int_t fColLwb; // Column lower bound of decomposed matrix
42 
43  void ResetStatus() { for (Int_t i = 14; i < 22; i++) ResetBit(BIT(i)); }
44  Int_t Hager (Double_t& est,Int_t iter=5);
45  static void DiagProd (const TVectorD &diag,Double_t tol,Double_t &d1,Double_t &d2);
46 
47  virtual const TMatrixDBase &GetDecompMatrix() const = 0;
48 
50  kInit = BIT(14),
52  kValuesSet = BIT(16),
53  kMatrixSet = BIT(17),
56  kCondition = BIT(20),
57  kSingular = BIT(21)
58  };
59 
60  enum {kWorkMax = 100}; // size of work array's in several routines
61 
62 public :
63  TDecompBase();
64  TDecompBase(const TDecompBase &another);
65  virtual ~TDecompBase() {};
66 
67  inline Double_t GetTol () const { return fTol; }
68  inline Double_t GetDet1 () const { return fDet1; }
69  inline Double_t GetDet2 () const { return fDet2; }
70  inline Double_t GetCondition () const { return fCondition; }
71  virtual Int_t GetNrows () const = 0;
72  virtual Int_t GetNcols () const = 0;
73  Int_t GetRowLwb () const { return fRowLwb; }
74  Int_t GetColLwb () const { return fColLwb; }
75  inline Double_t SetTol (Double_t tol);
76 
77  virtual Double_t Condition ();
78  virtual void Det (Double_t &d1,Double_t &d2);
79  virtual Bool_t Decompose () = 0;
80  virtual Bool_t Solve ( TVectorD &b) = 0;
81  virtual TVectorD Solve (const TVectorD& b,Bool_t &ok) = 0;
82  virtual Bool_t Solve ( TMatrixDColumn& b) = 0;
83  virtual Bool_t TransSolve ( TVectorD &b) = 0;
84  virtual TVectorD TransSolve (const TVectorD &b,Bool_t &ok) = 0;
85  virtual Bool_t TransSolve ( TMatrixDColumn& b) = 0;
86 
87  virtual Bool_t MultiSolve (TMatrixD &B);
88 
89  void Print(Option_t *opt="") const;
90 
91  TDecompBase &operator= (const TDecompBase &source);
92 
93  ClassDef(TDecompBase,2) // Matrix Decomposition Base
94 };
95 
97 {
98  const Double_t oldTol = fTol;
99  if (newTol >= 0.0)
100  fTol = newTol;
101  return oldTol;
102 }
103 
104 Bool_t DefHouseHolder (const TVectorD &vc,Int_t lp,Int_t l,Double_t &up,Double_t &b,Double_t tol=0.0);
107 void ApplyHouseHolder(const TVectorD &vc,Double_t up,Double_t b,Int_t lp,Int_t l,TVectorD &cv);
111 
112 #endif
static double B[]
virtual Bool_t MultiSolve(TMatrixD &B)
Solve set of equations with RHS in columns of B.
virtual Bool_t TransSolve(TVectorD &b)=0
Int_t Hager(Double_t &est, Int_t iter=5)
Double_t fCondition
Definition: TDecompBase.h:39
Int_t GetRowLwb() const
Definition: TDecompBase.h:73
Int_t fRowLwb
Definition: TDecompBase.h:40
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:83
virtual Bool_t Decompose()=0
TVectorT.
Definition: TMatrixTBase.h:79
Decomposition Base class.
Definition: TDecompBase.h:33
TDecompBase()
Default constructor.
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 .
TMatrixT.
Definition: TMatrixDfwd.h:22
Double_t fTol
Definition: TDecompBase.h:36
Double_t SetTol(Double_t tol)
Definition: TDecompBase.h:96
#define ClassDef(name, id)
Definition: Rtypes.h:326
TDecompBase & operator=(const TDecompBase &source)
Assignment operator.
Double_t GetDet2() const
Definition: TDecompBase.h:69
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 components v1 and v2 ...
Int_t fColLwb
Definition: TDecompBase.h:41
static constexpr double s
static void DiagProd(const TVectorD &diag, Double_t tol, Double_t &d1, Double_t &d2)
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:65
virtual Bool_t Solve(TVectorD &b)=0
void Print(Option_t *opt="") const
Print class members.
void ResetStatus()
Definition: TDecompBase.h:43
virtual Int_t GetNrows() const =0
Linear Algebra Package.
Double_t fDet2
Definition: TDecompBase.h:38
Double_t fDet1
Definition: TDecompBase.h:37
double Double_t
Definition: RtypesCore.h:55
virtual void Det(Double_t &d1, Double_t &d2)
Matrix determinant det = d1*TMath::Power(2.,d2)
Double_t GetDet1() const
Definition: TDecompBase.h:68
Mother of all ROOT objects.
Definition: TObject.h:37
Double_t GetTol() const
Definition: TDecompBase.h:67
auto * l
Definition: textangle.C:4
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.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define c(i)
Definition: RSha256.hxx:101
void ResetBit(UInt_t f)
Definition: TObject.h:171
Int_t GetColLwb() const
Definition: TDecompBase.h:74
Double_t GetCondition() const
Definition: TDecompBase.h:70