1 /*********************************************************************************/
3 /* Class for rectangular matrix used for */
4 /* millepede2 operation. */
5 /* May be sparse or dense. */
6 /* ----------------------- */
7 /* Author: ruben.shahoyan@cern.ch */
9 /*********************************************************************************/
11 #include "AliRectMatrix.h"
15 ClassImp(AliRectMatrix)
18 //___________________________________________________________
19 AliRectMatrix::AliRectMatrix()
20 : fNRows(0),fNCols(0),fRows(0)
23 //___________________________________________________________
24 AliRectMatrix::AliRectMatrix(Int_t nrow,Int_t ncol)
25 : fNRows(nrow),fNCols(ncol),fRows(0)
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));
36 //___________________________________________________________
37 AliRectMatrix::AliRectMatrix(const AliRectMatrix &src)
38 : TObject(src),fNRows(src.fNRows), fNCols(src.fNCols), fRows(0)
41 fRows = new Double_t*[fNRows];
42 for (int i=fNRows;i--;) {
43 fRows[i] = new Double_t[fNCols];
44 memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
48 //___________________________________________________________
49 AliRectMatrix::~AliRectMatrix()
52 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
56 //___________________________________________________________
57 AliRectMatrix& AliRectMatrix::operator=(const AliRectMatrix& src)
60 if (&src == this) return *this;
61 if (fNRows) for (int i=fNRows;i--;) delete[] fRows[i];
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));
74 //___________________________________________________________
75 void AliRectMatrix::Print(Option_t* option) const
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));
88 //___________________________________________________________
89 void AliRectMatrix::Reset() const
92 for (int i=fNRows;i--;) {
93 double *row = GetRow(i);
94 for (int j=fNCols;j--;) row[j] = 0.;