1 #include "AliRectMatrix.h"
5 ClassImp(AliRectMatrix)
8 //___________________________________________________________
9 AliRectMatrix::AliRectMatrix()
10 : fNRows(0),fNCols(0),fRows(0)
13 //___________________________________________________________
14 AliRectMatrix::AliRectMatrix(Int_t nrow,Int_t ncol)
15 : fNRows(nrow),fNCols(ncol),fRows(0)
18 fRows = new Double_t*[fNRows];
19 for (int i=fNRows;i--;) {
20 fRows[i] = new Double_t[fNCols];
21 memset(fRows[i],0,fNCols*sizeof(Double_t));
26 //___________________________________________________________
27 AliRectMatrix::AliRectMatrix(const AliRectMatrix &src)
28 : TObject(src),fNRows(src.fNRows), fNCols(src.fNCols), fRows(0)
30 fRows = new Double_t*[fNRows];
31 for (int i=fNRows;i--;) {
32 fRows[i] = new Double_t[fNCols];
33 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
37 //___________________________________________________________
38 AliRectMatrix::~AliRectMatrix()
40 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
44 //___________________________________________________________
45 AliRectMatrix& AliRectMatrix::operator=(const AliRectMatrix& src)
48 if (&src == this) return *this;
49 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
53 fRows = new Double_t*[fNRows];
54 for (int i=fNRows;i--;) {
55 fRows[i] = new Double_t[fNCols];
56 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
62 //___________________________________________________________
63 void AliRectMatrix::Print(Option_t* option) const
65 printf("Rectangular Matrix: %d rows %d columns\n",fNRows,fNCols);
66 TString opt = option; opt.ToLower();
67 if (opt.IsNull()) return;
68 for (int i=0;i<fNRows;i++) {
69 for (Int_t j=0;j<=fNCols;j++) printf("%+.3e|",Query(i,j));
75 //___________________________________________________________
76 void AliRectMatrix::Reset()
78 for (int i=fNRows;i--;) {
79 double *row = GetRow(i);
80 for (int j=fNCols;j--;) row[j] = 0.;