ROOT  6.06/09
Reference Guide
TDecompLU.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_TDecompLU
13 #define ROOT_TDecompLU
14 
15 ///////////////////////////////////////////////////////////////////////////
16 // //
17 // LU Decomposition class //
18 // //
19 ///////////////////////////////////////////////////////////////////////////
20 
21 #ifndef ROOT_TDecompBase
22 #include "TDecompBase.h"
23 #endif
24 
25 class TDecompLU : public TDecompBase
26 {
27 protected :
28 
29  Int_t fImplicitPivot; // control to determine implicit row scale before
30  // deciding on the pivot (Crout method)
31  Int_t fNIndex; // size of row permutation index
32  Int_t *fIndex; //[fNIndex] row permutation index
33  Double_t fSign; // = +/- 1 reflecting even/odd row permutations, resp.
34  TMatrixD fLU; // decomposed matrix so that a = l u where
35  // l is stored lower left and u upper right side
36 
37  static Bool_t DecomposeLUCrout(TMatrixD &lu,Int_t *index,Double_t &sign,Double_t tol,Int_t &nrZeros);
38  static Bool_t DecomposeLUGauss(TMatrixD &lu,Int_t *index,Double_t &sign,Double_t tol,Int_t &nrZeros);
39 
40  virtual const TMatrixDBase &GetDecompMatrix() const { return fLU; }
41 
42 public :
43 
44  TDecompLU();
45  explicit TDecompLU(Int_t nrows);
46  TDecompLU(Int_t row_lwb,Int_t row_upb);
47  TDecompLU(const TMatrixD &m,Double_t tol = 0.0,Int_t implicit = 1);
48  TDecompLU(const TDecompLU &another);
49  virtual ~TDecompLU() {if (fIndex) delete [] fIndex; fIndex = 0; }
50 
51  const TMatrixD GetMatrix ();
52  virtual Int_t GetNrows () const { return fLU.GetNrows(); }
53  virtual Int_t GetNcols () const { return fLU.GetNcols(); }
54  const TMatrixD &GetLU () { if ( !TestBit(kDecomposed) ) Decompose();
55  return fLU; }
56 
57  virtual void SetMatrix (const TMatrixD &a);
58 
59  virtual Bool_t Decompose ();
60  virtual Bool_t Solve ( TVectorD &b);
61  virtual TVectorD Solve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = Solve(x); return x; }
62  virtual Bool_t Solve ( TMatrixDColumn &b);
63  virtual Bool_t TransSolve ( TVectorD &b);
64  virtual TVectorD TransSolve (const TVectorD& b,Bool_t &ok) { TVectorD x = b; ok = TransSolve(x); return x; }
65  virtual Bool_t TransSolve ( TMatrixDColumn &b);
66  virtual void Det (Double_t &d1,Double_t &d2);
67 
68  static Bool_t InvertLU (TMatrixD &a,Double_t tol,Double_t *det=0);
71  TMatrixD Invert () { Bool_t status; return Invert(status); }
72 
73  void Print(Option_t *opt ="") const; // *MENU*
74 
75  TDecompLU &operator= (const TDecompLU &source);
76 
77  ClassDef(TDecompLU,1) // Matrix Decompositition LU
78 };
79 
80 #endif
const TMatrixD & GetLU()
Definition: TDecompLU.h:54
virtual Int_t GetNrows() const
Definition: TDecompLU.h:52
Double_t fSign
Definition: TDecompLU.h:33
const char Option_t
Definition: RtypesCore.h:62
Int_t fImplicitPivot
Definition: TDecompLU.h:29
virtual Bool_t Decompose()
Matrix A is decomposed in components U and L so that P * A = U * L If the decomposition succeeds...
Definition: TDecompLU.cxx:126
virtual const TMatrixDBase & GetDecompMatrix() const
Definition: TDecompLU.h:40
virtual TVectorD Solve(const TVectorD &b, Bool_t &ok)
Definition: TDecompLU.h:61
double inv(double x)
For comparisons.
Definition: inv.h:58
static Bool_t InvertLU(TMatrixD &a, Double_t tol, Double_t *det=0)
Calculate matrix inversion through in place forward/backward substitution.
Definition: TDecompLU.cxx:775
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
Int_t * fIndex
Definition: TDecompLU.h:32
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
virtual void Det(Double_t &d1, Double_t &d2)
Calculate determinant det = d1*TMath::Power(2.,d2)
Definition: TDecompLU.cxx:509
static Bool_t DecomposeLUCrout(TMatrixD &lu, Int_t *index, Double_t &sign, Double_t tol, Int_t &nrZeros)
Crout/Doolittle algorithm of LU decomposing a square matrix, with implicit partial pivoting...
Definition: TDecompLU.cxx:599
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual ~TDecompLU()
Definition: TDecompLU.h:49
TDecompLU & operator=(const TDecompLU &source)
assignement operator
Definition: TDecompLU.cxx:573
Int_t GetNrows() const
Definition: TMatrixTBase.h:134
Int_t fNIndex
Definition: TDecompLU.h:31
const double tol
virtual Int_t GetNcols() const
Definition: TDecompLU.h:53
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
TMarker * m
Definition: textangle.C:8
virtual TVectorD TransSolve(const TVectorD &b, Bool_t &ok)
Definition: TDecompLU.h:64
TMatrixD fLU
Definition: TDecompLU.h:34
const TMatrixD GetMatrix()
Reconstruct the original matrix using the decomposition parts.
Definition: TDecompLU.cxx:151
double Double_t
Definition: RtypesCore.h:55
Int_t GetNcols() const
Definition: TMatrixTBase.h:137
virtual void SetMatrix(const TMatrixD &a)
Set matrix to be decomposed.
Definition: TDecompLU.cxx:202
TMatrixD Invert()
Definition: TDecompLU.h:71
virtual Bool_t Solve(TVectorD &b)
Solve Ax=b assuming the LU form of A is stored in fLU, but assume b has not been transformed.
Definition: TDecompLU.cxx:233
Int_t sign(Double_t x)
Definition: CsgOps.cxx:89
virtual Bool_t TransSolve(TVectorD &b)
Solve A^T x=b assuming the LU form of A^T is stored in fLU, but assume b has not been transformed...
Definition: TDecompLU.cxx:371
void Print(Option_t *opt="") const
Print internals of this object.
Definition: TDecompLU.cxx:559
static Bool_t DecomposeLUGauss(TMatrixD &lu, Int_t *index, Double_t &sign, Double_t tol, Int_t &nrZeros)
LU decomposition using Gaussain Elimination with partial pivoting (See Golub & Van Loan...
Definition: TDecompLU.cxx:708