//*-- Author : M.Sanchez (11/06/2001) //*-- Modified : using namespace std; #include "hludecomposer.h" #include #include #include #include "TMath.h" //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////// // HLuDecomposer // // Implements LU decomposition of a HRtMatrix and backsubsitution //to invert the matrix or solve linear problems // // Both functions alter the data passed as arguments ////////////////////////////////////////////////////////////// HLuDecomposer::HLuDecomposer(void) { fPermutationParity = 0; fA = 0; //Processed matrix } HLuDecomposer::~HLuDecomposer(void) { fA = 0; } void HLuDecomposer::decompose(HRtMatrix &a) { // Decomposes matrix a into a L and U matrixes. Decomposition is done //in place, i.e. "a" is overwritten. Int_t n = a.getCols(); Int_t i,imax=-1,j,k; Float_t big,dum,sum,temp; assert(a.getCols() == a.getRows()); HRtVector vv(n); fA = &a; fPermutations.Set(n); fPermutationParity = 1; for (i=0;i big) big = temp; if (big == 0.) { Error("decompose","Input matrix is singular"); return; } vv(i) = 1./big; } for (j=0;j= big) { big = dum; imax = i; } } if (j != imax) { for (k=0;k=0;i--) { sum = b(i); for (j=i+1; j=0;i--) { sum = b(i,col); for (j=i+1; j