Project
Loading...
Searching...
No Matches
RectMatrix.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
14#include <TString.h>
16
17using namespace o2::fwdalign;
18
20
21//___________________________________________________________
23 : fNRows(0),
24 fNCols(0),
25 fRows(nullptr)
26{
27}
28
29//___________________________________________________________
30RectMatrix::RectMatrix(Int_t nrow, Int_t ncol)
31 : fNRows(nrow),
32 fNCols(ncol),
33 fRows(nullptr)
34{
35 fRows = new Double_t*[fNRows];
36 for (int i = fNRows; i--;) {
37 fRows[i] = new Double_t[fNCols];
38 memset(fRows[i], 0, fNCols * sizeof(Double_t));
39 }
40}
41
42//___________________________________________________________
44 : TObject(src),
45 fNRows(src.fNRows),
46 fNCols(src.fNCols),
47 fRows(nullptr)
48{
49 fRows = new Double_t*[fNRows];
50 for (int i = fNRows; i--;) {
51 fRows[i] = new Double_t[fNCols];
52 memcpy(fRows[i], src.fRows[i], fNCols * sizeof(Double_t));
53 }
54}
55
56//___________________________________________________________
58{
59 if (fNRows) {
60 for (int i = fNRows; i--;) {
61 delete[] fRows[i];
62 }
63 }
64 delete[] fRows;
65}
66
67//___________________________________________________________
69{
70 if (&src == this) {
71 return *this;
72 }
73 if (fNRows) {
74 for (int i = fNRows; i--;) {
75 delete[] fRows[i];
76 }
77 }
78 delete[] fRows;
80 fNCols = src.fNCols;
81 fRows = new Double_t*[fNRows];
82 for (int i = fNRows; i--;) {
83 fRows[i] = new Double_t[fNCols];
84 memcpy(fRows[i], src.fRows[i], fNCols * sizeof(Double_t));
85 }
86
87 return *this;
88}
89
90//___________________________________________________________
91void RectMatrix::Print(Option_t* option) const
92{
93 printf("Rectangular Matrix: %d rows %d columns\n", fNRows, fNCols);
94 TString opt = option;
95 opt.ToLower();
96 if (opt.IsNull()) {
97 return;
98 }
99 for (int i = 0; i < fNRows; i++) {
100 for (Int_t j = 0; j <= fNCols; j++) {
101 printf("%+.3e|", Query(i, j));
102 }
103 printf("\n");
104 }
105}
106
107//___________________________________________________________
109{
110 for (int i = fNRows; i--;) {
111 double* row = GetRow(i);
112 for (int j = fNCols; j--;) {
113 row[j] = 0.;
114 }
115 }
116}
int32_t i
uint32_t j
Definition RawData.h:0
ClassImp(RectMatrix)
Class for rectangular matrix used for millepede2 operation.
Class for rectangular matrix used for millepede2 operation.
Definition RectMatrix.h:31
void Reset() const
reset all
Int_t fNRows
Number of rows.
Definition RectMatrix.h:66
void Print(Option_t *option="") const override
print itself
Double_t Query(Int_t rown, Int_t coln) const
Definition RectMatrix.h:49
Double_t * GetRow(Int_t row) const
Definition RectMatrix.h:57
RectMatrix & operator=(const RectMatrix &src)
assignment op-r
Int_t fNCols
Number of columns.
Definition RectMatrix.h:67
Double_t ** fRows
pointers on rows
Definition RectMatrix.h:68
~RectMatrix() override
dest-tor
RectMatrix()
default c-tor
GLenum src
Definition glcorearb.h:1767
std::vector< int > row