Logo ROOT   6.13/01
Reference Guide
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
TDecompLU Class Reference

LU Decomposition class.

Decompose a general n x n matrix A into P A = L U

where P is a permutation matrix, L is unit lower triangular and U is upper triangular. L is stored in the strict lower triangular part of the matrix fLU. The diagonal elements of L are unity and are not stored. U is stored in the diagonal and upper triangular part of the matrix fU. P is stored in the index array fIndex : j = fIndex[i] indicates that row j and row i should be swapped .

fSign gives the sign of the permutation, (-1)^n, where n is the number of interchanges in the permutation.

fLU has the same indexing range as matrix A .

The decomposition fails if a diagonal element of abs(fLU) is == 0, The matrix fUL is made invalid .

Definition at line 23 of file TDecompLU.h.

Public Member Functions

 TDecompLU ()
 Default constructor. More...
 
 TDecompLU (Int_t nrows)
 Constructor for (nrows x nrows) matrix. More...
 
 TDecompLU (Int_t row_lwb, Int_t row_upb)
 Constructor for ([row_lwb..row_upb] x [row_lwb..row_upb]) matrix. More...
 
 TDecompLU (const TMatrixD &m, Double_t tol=0.0, Int_t implicit=1)
 Constructor for matrix a. More...
 
 TDecompLU (const TDecompLU &another)
 Copy constructor. More...
 
virtual ~TDecompLU ()
 
virtual Bool_t Decompose ()
 Matrix A is decomposed in components U and L so that P * A = U * L If the decomposition succeeds, bit kDecomposed is set , otherwise kSingular. More...
 
virtual void Det (Double_t &d1, Double_t &d2)
 Calculate determinant det = d1*TMath::Power(2.,d2) More...
 
const TMatrixDGetLU ()
 
const TMatrixD GetMatrix ()
 Reconstruct the original matrix using the decomposition parts. More...
 
virtual Int_t GetNcols () const
 
virtual Int_t GetNrows () const
 
Bool_t Invert (TMatrixD &inv)
 For a matrix A(m,m), its inverse A_inv is defined as A * A_inv = A_inv * A = unit (m x m) Ainv is returned . More...
 
TMatrixD Invert (Bool_t &status)
 For a matrix A(m,n), its inverse A_inv is defined as A * A_inv = A_inv * A = unit (n x m) Ainv is returned . More...
 
TMatrixD Invert ()
 
TDecompLUoperator= (const TDecompLU &source)
 assignment operator More...
 
void Print (Option_t *opt="") const
 Print internals of this object. More...
 
virtual void SetMatrix (const TMatrixD &a)
 Set matrix to be decomposed. More...
 
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. More...
 
virtual TVectorD Solve (const TVectorD &b, Bool_t &ok)
 
virtual Bool_t Solve (TMatrixDColumn &b)
 Solve Ax=b assuming the LU form of A is stored in fLU, but assume b has not been transformed. More...
 
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. More...
 
virtual TVectorD TransSolve (const TVectorD &b, Bool_t &ok)
 
virtual Bool_t TransSolve (TMatrixDColumn &b)
 Solve A^T x=b assuming the LU form of A^T is stored in fLU, but assume b has not been transformed. More...
 
- Public Member Functions inherited from TDecompBase
 TDecompBase ()
 Default constructor. More...
 
 TDecompBase (const TDecompBase &another)
 Copy constructor. More...
 
virtual ~TDecompBase ()
 
virtual Double_t Condition ()
 Matrix condition number. More...
 
Int_t GetColLwb () const
 
Double_t GetCondition () const
 
Double_t GetDet1 () const
 
Double_t GetDet2 () const
 
Int_t GetRowLwb () const
 
Double_t GetTol () const
 
virtual Bool_t MultiSolve (TMatrixD &B)
 Solve set of equations with RHS in columns of B. More...
 
TDecompBaseoperator= (const TDecompBase &source)
 Assignment operator. More...
 
void Print (Option_t *opt="") const
 Print class members. More...
 
Double_t SetTol (Double_t tol)
 

Static Public Member Functions

static Bool_t InvertLU (TMatrixD &a, Double_t tol, Double_t *det=0)
 Calculate matrix inversion through in place forward/backward substitution. More...
 

Protected Member Functions

virtual const TMatrixDBaseGetDecompMatrix () const
 
- Protected Member Functions inherited from TDecompBase
Int_t Hager (Double_t &est, Int_t iter=5)
 
void ResetStatus ()
 

Static Protected Member Functions

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. More...
 
static Bool_t DecomposeLUGauss (TMatrixD &lu, Int_t *index, Double_t &sign, Double_t tol, Int_t &nrZeros)
 LU decomposition using Gaussian Elimination with partial pivoting (See Golub & Van Loan, Matrix Computations, Algorithm 3.4.1) of a square matrix . More...
 
- Static Protected Member Functions inherited from TDecompBase
static void DiagProd (const TVectorD &diag, Double_t tol, Double_t &d1, Double_t &d2)
 

Protected Attributes

Int_t fImplicitPivot
 
Int_t * fIndex
 
TMatrixD fLU
 
Int_t fNIndex
 
Double_t fSign
 
- Protected Attributes inherited from TDecompBase
Int_t fColLwb
 
Double_t fCondition
 
Double_t fDet1
 
Double_t fDet2
 
Int_t fRowLwb
 
Double_t fTol
 

Additional Inherited Members

- Protected Types inherited from TDecompBase
enum  { kWorkMax = 100 }
 
enum  EMatrixDecompStat {
  kInit = BIT(14), kPatternSet = BIT(15), kValuesSet = BIT(16), kMatrixSet = BIT(17),
  kDecomposed = BIT(18), kDetermined = BIT(19), kCondition = BIT(20), kSingular = BIT(21)
}
 

#include <TDecompLU.h>

Inheritance diagram for TDecompLU:
[legend]

Constructor & Destructor Documentation

◆ TDecompLU() [1/5]

TDecompLU::TDecompLU ( )

Default constructor.

Definition at line 45 of file TDecompLU.cxx.

◆ TDecompLU() [2/5]

TDecompLU::TDecompLU ( Int_t  nrows)
explicit

Constructor for (nrows x nrows) matrix.

Definition at line 56 of file TDecompLU.cxx.

◆ TDecompLU() [3/5]

TDecompLU::TDecompLU ( Int_t  row_lwb,
Int_t  row_upb 
)

Constructor for ([row_lwb..row_upb] x [row_lwb..row_upb]) matrix.

Definition at line 69 of file TDecompLU.cxx.

◆ TDecompLU() [4/5]

TDecompLU::TDecompLU ( const TMatrixD m,
Double_t  tol = 0.0,
Int_t  implicit = 1 
)

Constructor for matrix a.

Definition at line 85 of file TDecompLU.cxx.

◆ TDecompLU() [5/5]

TDecompLU::TDecompLU ( const TDecompLU another)

Copy constructor.

Definition at line 115 of file TDecompLU.cxx.

◆ ~TDecompLU()

virtual TDecompLU::~TDecompLU ( )
inlinevirtual

Definition at line 47 of file TDecompLU.h.

Member Function Documentation

◆ Decompose()

Bool_t TDecompLU::Decompose ( )
virtual

Matrix A is decomposed in components U and L so that P * A = U * L If the decomposition succeeds, bit kDecomposed is set , otherwise kSingular.

Implements TDecompBase.

Definition at line 126 of file TDecompLU.cxx.

◆ DecomposeLUCrout()

Bool_t TDecompLU::DecomposeLUCrout ( TMatrixD lu,
Int_t *  index,
Double_t &  sign,
Double_t  tol,
Int_t &  nrZeros 
)
staticprotected

Crout/Doolittle algorithm of LU decomposing a square matrix, with implicit partial pivoting.

The decomposition is stored in fLU: U is explicit in the upper triag and L is in multiplier form in the subdiagionals . Row permutations are mapped out in fIndex. fSign, used for calculating the determinant, is +/- 1 for even/odd row permutations. .

Definition at line 599 of file TDecompLU.cxx.

◆ DecomposeLUGauss()

Bool_t TDecompLU::DecomposeLUGauss ( TMatrixD lu,
Int_t *  index,
Double_t &  sign,
Double_t  tol,
Int_t &  nrZeros 
)
staticprotected

LU decomposition using Gaussian Elimination with partial pivoting (See Golub & Van Loan, Matrix Computations, Algorithm 3.4.1) of a square matrix .

The decomposition is stored in fLU: U is explicit in the upper triag and L is in multiplier form in the subdiagionals . Row permutations are mapped out in fIndex. fSign, used for calculating the determinant, is +/- 1 for even/odd row permutations. Since this algorithm uses partial pivoting without scaling like in Crout/Doolitle. it is somewhat faster but less precise .

Definition at line 708 of file TDecompLU.cxx.

◆ Det()

void TDecompLU::Det ( Double_t &  d1,
Double_t &  d2 
)
virtual

Calculate determinant det = d1*TMath::Power(2.,d2)

Reimplemented from TDecompBase.

Definition at line 509 of file TDecompLU.cxx.

◆ GetDecompMatrix()

virtual const TMatrixDBase& TDecompLU::GetDecompMatrix ( ) const
inlineprotectedvirtual

Implements TDecompBase.

Definition at line 38 of file TDecompLU.h.

◆ GetLU()

const TMatrixD& TDecompLU::GetLU ( )
inline

Definition at line 52 of file TDecompLU.h.

◆ GetMatrix()

const TMatrixD TDecompLU::GetMatrix ( )

Reconstruct the original matrix using the decomposition parts.

Definition at line 151 of file TDecompLU.cxx.

◆ GetNcols()

virtual Int_t TDecompLU::GetNcols ( ) const
inlinevirtual

Implements TDecompBase.

Definition at line 51 of file TDecompLU.h.

◆ GetNrows()

virtual Int_t TDecompLU::GetNrows ( ) const
inlinevirtual

Implements TDecompBase.

Definition at line 50 of file TDecompLU.h.

◆ Invert() [1/3]

Bool_t TDecompLU::Invert ( TMatrixD inv)

For a matrix A(m,m), its inverse A_inv is defined as A * A_inv = A_inv * A = unit (m x m) Ainv is returned .

Definition at line 526 of file TDecompLU.cxx.

◆ Invert() [2/3]

TMatrixD TDecompLU::Invert ( Bool_t &  status)

For a matrix A(m,n), its inverse A_inv is defined as A * A_inv = A_inv * A = unit (n x m) Ainv is returned .

Definition at line 544 of file TDecompLU.cxx.

◆ Invert() [3/3]

TMatrixD TDecompLU::Invert ( )
inline

Definition at line 69 of file TDecompLU.h.

◆ InvertLU()

Bool_t TDecompLU::InvertLU ( TMatrixD a,
Double_t  tol,
Double_t *  det = 0 
)
static

Calculate matrix inversion through in place forward/backward substitution.

Definition at line 775 of file TDecompLU.cxx.

◆ operator=()

TDecompLU & TDecompLU::operator= ( const TDecompLU source)

assignment operator

Definition at line 573 of file TDecompLU.cxx.

◆ Print()

void TDecompLU::Print ( Option_t *  opt = "") const

Print internals of this object.

Definition at line 559 of file TDecompLU.cxx.

◆ SetMatrix()

void TDecompLU::SetMatrix ( const TMatrixD a)
virtual

Set matrix to be decomposed.

Definition at line 202 of file TDecompLU.cxx.

◆ Solve() [1/3]

Bool_t TDecompLU::Solve ( TVectorD b)
virtual

Solve Ax=b assuming the LU form of A is stored in fLU, but assume b has not been transformed.

Solution returned in b.

Implements TDecompBase.

Definition at line 233 of file TDecompLU.cxx.

◆ Solve() [2/3]

virtual TVectorD TDecompLU::Solve ( const TVectorD b,
Bool_t &  ok 
)
inlinevirtual

Implements TDecompBase.

Definition at line 59 of file TDecompLU.h.

◆ Solve() [3/3]

Bool_t TDecompLU::Solve ( TMatrixDColumn cb)
virtual

Solve Ax=b assuming the LU form of A is stored in fLU, but assume b has not been transformed.

Solution returned in b.

Implements TDecompBase.

Definition at line 299 of file TDecompLU.cxx.

◆ TransSolve() [1/3]

Bool_t TDecompLU::TransSolve ( TVectorD b)
virtual

Solve A^T x=b assuming the LU form of A^T is stored in fLU, but assume b has not been transformed.

Solution returned in b.

Implements TDecompBase.

Definition at line 371 of file TDecompLU.cxx.

◆ TransSolve() [2/3]

virtual TVectorD TDecompLU::TransSolve ( const TVectorD b,
Bool_t &  ok 
)
inlinevirtual

Implements TDecompBase.

Definition at line 62 of file TDecompLU.h.

◆ TransSolve() [3/3]

Bool_t TDecompLU::TransSolve ( TMatrixDColumn cb)
virtual

Solve A^T x=b assuming the LU form of A^T is stored in fLU, but assume b has not been transformed.

Solution returned in b.

Implements TDecompBase.

Definition at line 440 of file TDecompLU.cxx.

Member Data Documentation

◆ fImplicitPivot

Int_t TDecompLU::fImplicitPivot
protected

Definition at line 27 of file TDecompLU.h.

◆ fIndex

Int_t* TDecompLU::fIndex
protected

Definition at line 30 of file TDecompLU.h.

◆ fLU

TMatrixD TDecompLU::fLU
protected

Definition at line 32 of file TDecompLU.h.

◆ fNIndex

Int_t TDecompLU::fNIndex
protected

Definition at line 29 of file TDecompLU.h.

◆ fSign

Double_t TDecompLU::fSign
protected

Definition at line 31 of file TDecompLU.h.

Libraries for TDecompLU:
[legend]

The documentation for this class was generated from the following files: