ROOT 6.13/01 Reference Guide |
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 TMatrixD & | GetLU () |
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 () |
TDecompLU & | operator= (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... | |
TDecompBase & | operator= (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 TMatrixDBase & | GetDecompMatrix () 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>
TDecompLU::TDecompLU | ( | ) |
Default constructor.
Definition at line 45 of file TDecompLU.cxx.
|
explicit |
Constructor for (nrows x nrows) matrix.
Definition at line 56 of file TDecompLU.cxx.
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::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::TDecompLU | ( | const TDecompLU & | another | ) |
Copy constructor.
Definition at line 115 of file TDecompLU.cxx.
|
inlinevirtual |
Definition at line 47 of file TDecompLU.h.
|
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.
|
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.
|
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.
|
virtual |
Calculate determinant det = d1*TMath::Power(2.,d2)
Reimplemented from TDecompBase.
Definition at line 509 of file TDecompLU.cxx.
|
inlineprotectedvirtual |
Implements TDecompBase.
Definition at line 38 of file TDecompLU.h.
|
inline |
Definition at line 52 of file TDecompLU.h.
const TMatrixD TDecompLU::GetMatrix | ( | ) |
Reconstruct the original matrix using the decomposition parts.
Definition at line 151 of file TDecompLU.cxx.
|
inlinevirtual |
Implements TDecompBase.
Definition at line 51 of file TDecompLU.h.
|
inlinevirtual |
Implements TDecompBase.
Definition at line 50 of file TDecompLU.h.
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.
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.
|
inline |
Definition at line 69 of file TDecompLU.h.
|
static |
Calculate matrix inversion through in place forward/backward substitution.
Definition at line 775 of file TDecompLU.cxx.
assignment operator
Definition at line 573 of file TDecompLU.cxx.
void TDecompLU::Print | ( | Option_t * | opt = "" | ) | const |
Print internals of this object.
Definition at line 559 of file TDecompLU.cxx.
|
virtual |
Set matrix to be decomposed.
Definition at line 202 of file TDecompLU.cxx.
|
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.
Implements TDecompBase.
Definition at line 59 of file TDecompLU.h.
|
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.
|
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.
Implements TDecompBase.
Definition at line 62 of file TDecompLU.h.
|
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.
|
protected |
Definition at line 27 of file TDecompLU.h.
|
protected |
Definition at line 30 of file TDecompLU.h.
|
protected |
Definition at line 32 of file TDecompLU.h.
|
protected |
Definition at line 29 of file TDecompLU.h.
|
protected |
Definition at line 31 of file TDecompLU.h.