Logo ROOT  
Reference Guide
TDecompQRH.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_TDecompQRH
13 #define ROOT_TDecompQRH
14 
15 ///////////////////////////////////////////////////////////////////////////
16 // //
17 // QR Decomposition class //
18 // //
19 ///////////////////////////////////////////////////////////////////////////
20 
21 #include "TDecompBase.h"
22 
23 #include "Rtypes.h"
24 
25 class TDecompQRH : public TDecompBase
26 {
27 protected :
28 
29  // A = fQ fR H (m x n) matrix
30  TMatrixD fQ; // (m x n) - orthogonal matrix
31  TMatrixD fR; // (n x n) - upper triangular matrix
32  TVectorD fUp; // (n) - vector with Householder up's
33  TVectorD fW; // (n) - vector with Householder beta's
34 
35  static Bool_t QRH(TMatrixD &q,TVectorD &diagR,TVectorD &up,TVectorD &w,Double_t tol);
36 
37  virtual const TMatrixDBase &GetDecompMatrix() const { return fR; }
38 
39 public :
40 
41  enum {kWorkMax = 100}; // size of work array
42 
44  TDecompQRH(Int_t nrows,Int_t ncols);
45  TDecompQRH(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
46  TDecompQRH(const TMatrixD &m,Double_t tol = 0.0); // be careful for slicing in operator=
47  TDecompQRH(const TDecompQRH &another);
48  virtual ~TDecompQRH() {}
49 
50  virtual Int_t GetNrows () const { return fQ.GetNrows(); }
51  virtual Int_t GetNcols () const { return fQ.GetNcols(); }
52  virtual const TMatrixD &GetQ () { if ( !TestBit(kDecomposed) ) Decompose();
53  return fQ; }
54  virtual const TMatrixD &GetR () { if ( !TestBit(kDecomposed) ) Decompose();
55  return fR; }
56  virtual const TVectorD &GetUp () { if ( !TestBit(kDecomposed) ) Decompose();
57  return fUp; }
58  virtual const TVectorD &GetW () { if ( !TestBit(kDecomposed) ) Decompose();
59  return fW; }
60 
62  const TMatrixD &GetTriangularMatrix() const { return fR; }
63 
64  virtual void SetMatrix(const TMatrixD &a);
65 
66  virtual Bool_t Decompose ();
67  virtual Bool_t Solve ( TVectorD &b);
68  virtual TVectorD Solve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = Solve(x); return x; }
69  virtual Bool_t Solve ( TMatrixDColumn &b);
70  virtual Bool_t TransSolve ( TVectorD &b);
71  virtual TVectorD TransSolve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = TransSolve(x); return x; }
72  virtual Bool_t TransSolve ( TMatrixDColumn &b);
73  virtual void Det (Double_t &d1,Double_t &d2);
74 
76  TMatrixD Invert (Bool_t &status);
77  TMatrixD Invert () { Bool_t status; return Invert(status); }
78 
79  void Print(Option_t *opt ="") const; // *MENU*
80 
81  TDecompQRH &operator= (const TDecompQRH &source);
82 
83  ClassDef(TDecompQRH,1) // Matrix Decompositition QRH
84 };
85 
86 #endif
TDecompBase.h
TDecompQRH::QRH
static Bool_t QRH(TMatrixD &q, TVectorD &diagR, TVectorD &up, TVectorD &w, Double_t tol)
Decomposition function .
Definition: TDecompQRH.cxx:189
m
auto * m
Definition: textangle.C:8
TDecompQRH::GetTriangularMatrix
const TMatrixD & GetTriangularMatrix() const
Definition: TDecompQRH.h:62
TDecompQRH::GetUp
virtual const TVectorD & GetUp()
Definition: TDecompQRH.h:56
TDecompQRH::~TDecompQRH
virtual ~TDecompQRH()
Definition: TDecompQRH.h:48
TDecompBase
Decomposition Base class.
Definition: TDecompBase.h:34
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TDecompQRH::Det
virtual void Det(Double_t &d1, Double_t &d2)
This routine calculates the absolute (!) value of the determinant |det| = d1*TMath::Power(2....
Definition: TDecompQRH.cxx:493
Option_t
const char Option_t
Definition: RtypesCore.h:66
TDecompQRH::Solve
virtual Bool_t Solve(TVectorD &b)
Solve Ax=b assuming the QR form of A is stored in fR,fQ and fW, but assume b has not been transformed...
Definition: TDecompQRH.cxx:256
inv
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)
Definition: rsaaux.cxx:949
TDecompQRH::kWorkMax
@ kWorkMax
Definition: TDecompQRH.h:41
TDecompQRH::TransSolve
virtual TVectorD TransSolve(const TVectorD &b, Bool_t &ok)
Definition: TDecompQRH.h:71
Int_t
int Int_t
Definition: RtypesCore.h:45
TDecompQRH::TransSolve
virtual Bool_t TransSolve(TVectorD &b)
Solve A^T x=b assuming the QR form of A is stored in fR,fQ and fW, but assume b has not been transfor...
Definition: TDecompQRH.cxx:370
x
Double_t x[n]
Definition: legend1.C:17
TMatrixT< Double_t >
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TDecompQRH::GetNcols
virtual Int_t GetNcols() const
Definition: TDecompQRH.h:51
b
#define b(i)
Definition: RSha256.hxx:100
bool
TDecompQRH::GetR
virtual const TMatrixD & GetR()
Definition: TDecompQRH.h:54
q
float * q
Definition: THbookFile.cxx:89
TDecompQRH::SetMatrix
virtual void SetMatrix(const TMatrixD &a)
Set matrix to be decomposed.
Definition: TDecompQRH.cxx:222
TDecompQRH::GetDecompMatrix
virtual const TMatrixDBase & GetDecompMatrix() const
Definition: TDecompQRH.h:37
TDecompQRH::Solve
virtual TVectorD Solve(const TVectorD &b, Bool_t &ok)
Definition: TDecompQRH.h:68
TDecompQRH::fUp
TVectorD fUp
Definition: TDecompQRH.h:32
a
auto * a
Definition: textangle.C:12
TMatrixTBase
TMatrixTBase.
Definition: TMatrixTBase.h:84
TDecompQRH::GetOrthogonalMatrix
TMatrixD GetOrthogonalMatrix() const
For a matrix A(m,n), return the OtrhogonalMatrix Q such as A = Q * R.
Definition: TDecompQRH.cxx:516
TMatrixTColumn
Definition: TMatrixTUtils.h:253
TDecompQRH::fQ
TMatrixD fQ
Definition: TDecompQRH.h:30
TDecompQRH::fR
TMatrixD fR
Definition: TDecompQRH.h:31
TVectorT< Double_t >
Double_t
double Double_t
Definition: RtypesCore.h:59
TDecompQRH::Print
void Print(Option_t *opt="") const
Print the class members.
Definition: TDecompQRH.cxx:581
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TDecompQRH
QR Decomposition class.
Definition: TDecompQRH.h:26
TDecompQRH::TDecompQRH
TDecompQRH()
Definition: TDecompQRH.h:43
TDecompQRH::Decompose
virtual Bool_t Decompose()
QR decomposition of matrix a by Householder transformations, see Golub & Loan first edition p41 & Sec...
Definition: TDecompQRH.cxx:150
TDecompQRH::operator=
TDecompQRH & operator=(const TDecompQRH &source)
Assignment operator.
Definition: TDecompQRH.cxx:593
TDecompQRH::GetQ
virtual const TMatrixD & GetQ()
Definition: TDecompQRH.h:52
Rtypes.h
TDecompQRH::GetW
virtual const TVectorD & GetW()
Definition: TDecompQRH.h:58
TDecompQRH::GetNrows
virtual Int_t GetNrows() const
Definition: TDecompQRH.h:50
TDecompQRH::fW
TVectorD fW
Definition: TDecompQRH.h:33
int
TDecompQRH::Invert
TMatrixD Invert()
Definition: TDecompQRH.h:77
TDecompBase::kDecomposed
@ kDecomposed
Definition: TDecompBase.h:54