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 for (int i=fNRows;i--;) {
31 fRows[i] = new Double_t[fNCols];
32 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
36 //___________________________________________________________
37 AliRectMatrix::~AliRectMatrix()
39 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
43 //___________________________________________________________
44 AliRectMatrix& AliRectMatrix::operator=(const AliRectMatrix& src)
47 if (&src == this) return *this;
48 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
52 fRows = new Double_t*[fNRows];
53 for (int i=fNRows;i--;) {
54 fRows[i] = new Double_t[fNCols];
55 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
61 //___________________________________________________________
62 void AliRectMatrix::Print(Option_t* option) const
64 printf("Rectangular Matrix: %d rows %d columns\n",fNRows,fNCols);
65 TString opt = option; opt.ToLower();
66 if (opt.IsNull()) return;
67 for (int i=0;i<fNRows;i++) {
68 for (Int_t j=0;j<=fNCols;j++) printf("%+.3e|",Query(i,j));
74 //___________________________________________________________
75 void AliRectMatrix::Reset()
77 for (int i=fNRows;i--;) {
78 double *row = GetRow(i);
79 for (int j=fNCols;j--;) row[j] = 0.;