Update for MillePede2 and related classes
[u/mrichter/AliRoot.git] / STEER / AliRectMatrix.cxx
CommitLineData
de34b538 1#include "AliRectMatrix.h"
2#include <TString.h>
3//
4
5ClassImp(AliRectMatrix)
6
7
8//___________________________________________________________
9AliRectMatrix::AliRectMatrix()
10: fNRows(0),fNCols(0),fRows(0)
11{}
12
13//___________________________________________________________
14AliRectMatrix::AliRectMatrix(Int_t nrow,Int_t ncol)
15 : fNRows(nrow),fNCols(ncol),fRows(0)
16{
17 //
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));
22 }
23 //
24}
25
26//___________________________________________________________
27AliRectMatrix::AliRectMatrix(const AliRectMatrix &src)
28 : TObject(src),fNRows(src.fNRows), fNCols(src.fNCols), fRows(0)
29{
30 for (int i=fNRows;i--;) {
31 fRows[i] = new Double_t[fNCols];
32 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
33 }
34}
35
36//___________________________________________________________
37AliRectMatrix::~AliRectMatrix()
38{
39 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
40 delete[] fRows;
41}
42
43//___________________________________________________________
44AliRectMatrix& AliRectMatrix::operator=(const AliRectMatrix& src)
45{
46 //
47 if (&src == this) return *this;
48 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
49 delete[] fRows;
50 fNRows = src.fNRows;
51 fNCols = src.fNCols;
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));
56 }
57 //
58 return *this;
59}
60
61//___________________________________________________________
62void AliRectMatrix::Print(Option_t* option) const
63{
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));
69 printf("\n");
70 }
71}
72
73
74//___________________________________________________________
75void AliRectMatrix::Reset()
76{
77 for (int i=fNRows;i--;) {
78 double *row = GetRow(i);
79 for (int j=fNCols;j--;) row[j] = 0.;
80 }
81}