]>
Commit | Line | Data |
---|---|---|
339fbe23 | 1 | /*********************************************************************************/ |
2 | /* */ | |
3 | /* Class for rectangular matrix used for */ | |
4 | /* millepede2 operation. */ | |
5 | /* May be sparse or dense. */ | |
6 | /* ----------------------- */ | |
7 | /* Author: ruben.shahoyan@cern.ch */ | |
8 | /* */ | |
9 | /*********************************************************************************/ | |
10 | ||
de34b538 | 11 | #include "AliRectMatrix.h" |
12 | #include <TString.h> | |
13 | // | |
14 | ||
15 | ClassImp(AliRectMatrix) | |
16 | ||
17 | ||
18 | //___________________________________________________________ | |
19 | AliRectMatrix::AliRectMatrix() | |
20 | : fNRows(0),fNCols(0),fRows(0) | |
21 | {} | |
22 | ||
23 | //___________________________________________________________ | |
24 | AliRectMatrix::AliRectMatrix(Int_t nrow,Int_t ncol) | |
25 | : fNRows(nrow),fNCols(ncol),fRows(0) | |
26 | { | |
339fbe23 | 27 | // c-tor |
de34b538 | 28 | fRows = new Double_t*[fNRows]; |
29 | for (int i=fNRows;i--;) { | |
30 | fRows[i] = new Double_t[fNCols]; | |
31 | memset(fRows[i],0,fNCols*sizeof(Double_t)); | |
32 | } | |
33 | // | |
34 | } | |
35 | ||
36 | //___________________________________________________________ | |
37 | AliRectMatrix::AliRectMatrix(const AliRectMatrix &src) | |
38 | : TObject(src),fNRows(src.fNRows), fNCols(src.fNCols), fRows(0) | |
39 | { | |
339fbe23 | 40 | // copy c-tor |
d97d27ff | 41 | fRows = new Double_t*[fNRows]; |
de34b538 | 42 | for (int i=fNRows;i--;) { |
43 | fRows[i] = new Double_t[fNCols]; | |
44 | memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t)); | |
45 | } | |
46 | } | |
47 | ||
48 | //___________________________________________________________ | |
49 | AliRectMatrix::~AliRectMatrix() | |
50 | { | |
339fbe23 | 51 | // dest-tor |
de34b538 | 52 | if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i]; |
53 | delete[] fRows; | |
54 | } | |
55 | ||
56 | //___________________________________________________________ | |
57 | AliRectMatrix& AliRectMatrix::operator=(const AliRectMatrix& src) | |
58 | { | |
339fbe23 | 59 | // assignment op-r |
de34b538 | 60 | if (&src == this) return *this; |
61 | if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i]; | |
62 | delete[] fRows; | |
63 | fNRows = src.fNRows; | |
64 | fNCols = src.fNCols; | |
65 | fRows = new Double_t*[fNRows]; | |
66 | for (int i=fNRows;i--;) { | |
67 | fRows[i] = new Double_t[fNCols]; | |
68 | memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t)); | |
69 | } | |
70 | // | |
71 | return *this; | |
72 | } | |
73 | ||
74 | //___________________________________________________________ | |
75 | void AliRectMatrix::Print(Option_t* option) const | |
76 | { | |
339fbe23 | 77 | // print itself |
de34b538 | 78 | printf("Rectangular Matrix: %d rows %d columns\n",fNRows,fNCols); |
79 | TString opt = option; opt.ToLower(); | |
80 | if (opt.IsNull()) return; | |
81 | for (int i=0;i<fNRows;i++) { | |
82 | for (Int_t j=0;j<=fNCols;j++) printf("%+.3e|",Query(i,j)); | |
83 | printf("\n"); | |
84 | } | |
85 | } | |
86 | ||
87 | ||
88 | //___________________________________________________________ | |
339fbe23 | 89 | void AliRectMatrix::Reset() const |
de34b538 | 90 | { |
339fbe23 | 91 | // reset all |
de34b538 | 92 | for (int i=fNRows;i--;) { |
93 | double *row = GetRow(i); | |
94 | for (int j=fNCols;j--;) row[j] = 0.; | |
95 | } | |
96 | } |