Logo ROOT  
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),
51  kPatternSet = BIT(15),
52  kValuesSet = BIT(16),
53  kMatrixSet = BIT(17),
54  kDecomposed = BIT(18),
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 :
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
c
#define c(i)
Definition: RSha256.hxx:119
TDecompBase::MultiSolve
virtual Bool_t MultiSolve(TMatrixD &B)
Solve set of equations with RHS in columns of B.
Definition: TDecompBase.cxx:280
l
auto * l
Definition: textangle.C:4
TDecompBase::Decompose
virtual Bool_t Decompose()=0
TDecompBase::GetRowLwb
Int_t GetRowLwb() const
Definition: TDecompBase.h:79
TDecompBase
Definition: TDecompBase.h:33
TDecompBase::kCondition
@ kCondition
Definition: TDecompBase.h:62
TVectorD.h
TMatrixDUtils.h
TDecompBase::Hager
Int_t Hager(Double_t &est, Int_t iter=5)
Definition: TDecompBase.cxx:150
TDecompBase::SetTol
Double_t SetTol(Double_t tol)
Definition: TDecompBase.h:96
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TDecompBase::TransSolve
virtual Bool_t TransSolve(TVectorD &b)=0
Int_t
int Int_t
Definition: RtypesCore.h:45
TDecompBase::fCondition
Double_t fCondition
Definition: TDecompBase.h:45
TDecompBase::fTol
Double_t fTol
Definition: TDecompBase.h:42
TDecompBase::fColLwb
Int_t fColLwb
Definition: TDecompBase.h:47
TDecompBase::kInit
@ kInit
Definition: TDecompBase.h:56
TDecompBase::DiagProd
static void DiagProd(const TVectorD &diag, Double_t tol, Double_t &d1, Double_t &d2)
Definition: TDecompBase.cxx:209
DefHouseHolder
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 .
Definition: TDecompBase.cxx:354
TMatrixT
Definition: TMatrixDfwd.h:22
TDecompBase::TDecompBase
TDecompBase()
Default constructor.
Definition: TDecompBase.cxx:130
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TDecompBase::GetDecompMatrix
virtual const TMatrixDBase & GetDecompMatrix() const =0
b
#define b(i)
Definition: RSha256.hxx:118
bool
DefGivens
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.
Definition: TDecompBase.cxx:476
TDecompBase::GetDet2
Double_t GetDet2() const
Definition: TDecompBase.h:75
TDecompBase::ResetStatus
void ResetStatus()
Definition: TDecompBase.h:49
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:171
TDecompBase::kPatternSet
@ kPatternSet
Definition: TDecompBase.h:57
TDecompBase::operator=
TDecompBase & operator=(const TDecompBase &source)
Assignment operator.
Definition: TDecompBase.cxx:337
TDecompBase::~TDecompBase
virtual ~TDecompBase()
Definition: TDecompBase.h:71
TDecompBase::Print
void Print(Option_t *opt="") const
Print class members.
Definition: TDecompBase.cxx:324
TMatrixTBase
Definition: TMatrixDBasefwd.h:25
TDecompBase::kSingular
@ kSingular
Definition: TDecompBase.h:63
DefAplGivens
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.
Definition: TDecompBase.cxx:505
ApplyGivens
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 .
Definition: TDecompBase.cxx:537
TDecompBase::GetNrows
virtual Int_t GetNrows() const =0
BIT
#define BIT(n)
Definition: Rtypes.h:85
TDecompBase::fDet2
Double_t fDet2
Definition: TDecompBase.h:44
ApplyHouseHolder
void ApplyHouseHolder(const TVectorD &vc, Double_t up, Double_t b, Int_t lp, Int_t l, TMatrixDRow &cr)
Apply Householder-transformation.
Definition: TDecompBase.cxx:389
TDecompBase::Det
virtual void Det(Double_t &d1, Double_t &d2)
Matrix determinant det = d1*TMath::Power(2.,d2)
Definition: TDecompBase.cxx:299
TMatrixTColumn
Definition: TMatrixDUtilsfwd.h:44
TDecompBase::kValuesSet
@ kValuesSet
Definition: TDecompBase.h:58
TDecompBase::GetNcols
virtual Int_t GetNcols() const =0
TVectorT
Definition: TMatrixTBase.h:78
TDecompBase::fDet1
Double_t fDet1
Definition: TDecompBase.h:43
TDecompBase::GetDet1
Double_t GetDet1() const
Definition: TDecompBase.h:74
TDecompBase::kMatrixSet
@ kMatrixSet
Definition: TDecompBase.h:59
v1
@ v1
Definition: rootcling_impl.cxx:3637
Double_t
double Double_t
Definition: RtypesCore.h:59
TDecompBase::Solve
virtual Bool_t Solve(TVectorD &b)=0
TObject.h
TDecompBase::EMatrixDecompStat
EMatrixDecompStat
Definition: TDecompBase.h:55
v2
@ v2
Definition: rootcling_impl.cxx:3638
TObject
Definition: TObject.h:37
TDecompBase::GetColLwb
Int_t GetColLwb() const
Definition: TDecompBase.h:80
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TDecompBase::kWorkMax
@ kWorkMax
Definition: TDecompBase.h:66
TDecompBase::GetCondition
Double_t GetCondition() const
Definition: TDecompBase.h:76
TDecompBase::kDetermined
@ kDetermined
Definition: TDecompBase.h:61
TDecompBase::GetTol
Double_t GetTol() const
Definition: TDecompBase.h:73
TMatrixTRow
Definition: TMatrixDUtilsfwd.h:43
ROOT::Math::Cephes::B
static double B[]
Definition: SpecFuncCephes.cxx:178
TMatrixD.h
Rtypes.h
TDecompBase::fRowLwb
Int_t fRowLwb
Definition: TDecompBase.h:46
int
TDecompBase::Condition
virtual Double_t Condition()
Matrix condition number.
Definition: TDecompBase.cxx:257
TDecompBase::kDecomposed
@ kDecomposed
Definition: TDecompBase.h:60