/*********************************************************************************/ /* Symmetric Band Diagonal matrix with half band width W (+1 for diagonal) */ /* Only lower triangle is stored in the "profile" format */ /* */ /* */ /* Author: ruben.shahoyan@cern.ch */ /* */ /*********************************************************************************/ #include #include #include #include // #include "TClass.h" #include "TMath.h" #include "AliSymBDMatrix.h" // using namespace std; ClassImp(AliSymBDMatrix) //___________________________________________________________ AliSymBDMatrix::AliSymBDMatrix() : fElems(0) { // def. c-tor fSymmetric = kTRUE; } //___________________________________________________________ AliSymBDMatrix::AliSymBDMatrix(Int_t size, Int_t w) : AliMatrixSq(),fElems(0) { // c-tor for given size // fNcols = size; // number of rows if (w<0) w = 0; if (w>=size) w = size-1; fNrows = w; fRowLwb = w+1; fSymmetric = kTRUE; // // total number of stored elements fNelems = size*(w+1) - w*(w+1)/2; // fElems = new Double_t[fNcols*fRowLwb]; memset(fElems,0,fNcols*fRowLwb*sizeof(Double_t)); // } //___________________________________________________________ AliSymBDMatrix::AliSymBDMatrix(const AliSymBDMatrix &src) : AliMatrixSq(src),fElems(0) { // copy c-tor if (src.GetSize()<1) return; fNcols = src.GetSize(); fNrows = src.GetBandHWidth(); fRowLwb = fNrows+1; fNelems = src.GetNElemsStored(); fElems = new Double_t[fNcols*fRowLwb]; memcpy(fElems,src.fElems,fNcols*fRowLwb*sizeof(Double_t)); // } //___________________________________________________________ AliSymBDMatrix::~AliSymBDMatrix() { // d-tor Clear(); } //___________________________________________________________ AliSymBDMatrix& AliSymBDMatrix::operator=(const AliSymBDMatrix& src) { // assignment // if (this != &src) { TObject::operator=(src); if (fNcols!=src.fNcols) { // recreate the matrix if (fElems) delete[] fElems; fNcols = src.GetSize(); fNrows = src.GetBandHWidth(); fNelems = src.GetNElemsStored(); fRowLwb = src.fRowLwb; fElems = new Double_t[fNcols*fRowLwb]; } memcpy(fElems,src.fElems,fNcols*fRowLwb*sizeof(Double_t)); fSymmetric = kTRUE; } // return *this; // } //___________________________________________________________ void AliSymBDMatrix::Clear(Option_t*) { // clear dynamic part if (fElems) {delete[] fElems; fElems = 0;} // fNelems = fNcols = fNrows = fRowLwb = 0; // } //___________________________________________________________ Float_t AliSymBDMatrix::GetDensity() const { // get fraction of non-zero elements if (!fNelems) return 0; Int_t nel = 0; for (int i=fNelems;i--;) if (!IsZero(fElems[i])) nel++; return nel/fNelems; } //___________________________________________________________ void AliSymBDMatrix::Print(Option_t* option) const { // print data printf("Symmetric Band-Diagonal Matrix : Size = %d, half bandwidth = %d\n", GetSize(),GetBandHWidth()); TString opt = option; opt.ToLower(); if (opt.IsNull()) return; opt = "%"; opt += 1+int(TMath::Log10(double(GetSize()))); opt+="d|"; for (Int_t i=0;i::epsilon()*std::numeric_limits::epsilon(); // Double_t dtmp,gamma=0.0,xi=0.0; int iDiag; // // find max diag and number of non-0 diag.elements for (dtmp=0.0,iDiag=0;iDiag1 ? 1.0/TMath::Sqrt( GetSize()*GetSize() - 1.0) : 1.0; double beta = TMath::Sqrt(TMath::Max(eps,TMath::Max(gamma,xi*sn))); // for (int kr=1;kr