CMS 3D CMS Logo

matutil.cc
Go to the documentation of this file.
1 //
2 //
3 // File: src/matutil.cc
4 // Purpose: Define matrix types for the hitfit package, and supply a few
5 // additional operations.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // CMSSW File : src/matutil.cc
9 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
10 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
11 //
12 
37 #include <cassert>
38 
39 namespace hitfit {
40 
42  //
43  // Purpose: Constructor.
44  // Does not initialize the vector.
45  //
46  // Inputs:
47  // cols - The length of the vector.
48  //
49  : Matrix(1, cols) {}
50 
51  Row_Vector::Row_Vector(int cols, int /*init*/)
52  //
53  // Purpose: Constructor.
54  // Initializes the vector to 0.
55  //
56  // Inputs:
57  // cols - The length of the vector.
58  // init - Dummy. Should be 0.
59  //
60  : Matrix(1, cols, 0) {}
61 
63  //
64  // Purpose: Copy constructor.
65  // Raises an assertion if M does not have exactly one row.
66  //
67  // Inputs:
68  // m - The matrix to copy.
69  // Must have exactly one row.
70  //
71  : Matrix(m) {
72  assert(m.num_row() == 1);
73  }
74 
75  const double& Row_Vector::operator()(int col) const
76  //
77  // Purpose: Element access.
78  //
79  // Inputs:
80  // col - The column to access. Indexing starts with 1.
81  //
82  // Returns:
83  // Const reference to the selected element.
84  //
85  {
86  return HepMatrix::operator()(1, col);
87  }
88 
90  //
91  // Purpose: Element access.
92  //
93  // Inputs:
94  // col - The column to access. Indexing starts with 1.
95  //
96  // Returns:
97  // Reference to the selected element.
98  //
99  {
100  return HepMatrix::operator()(1, col);
101  }
102 
103  const double& Row_Vector::operator()(int row, int col) const
104  //
105  // Purpose: Element access.
106  //
107  // Inputs:
108  // row - The row to access. Indexing starts with 1.
109  // col - The column to access. Indexing starts with 1.
110  //
111  // Returns:
112  // Const reference to the selected element.
113  //
114  {
115  return HepMatrix::operator()(row, col);
116  }
117 
118  double& Row_Vector::operator()(int row, int col)
119  //
120  // Purpose: Element access.
121  //
122  // Inputs:
123  // row - The row to access. Indexing starts with 1.
124  // col - The column to access. Indexing starts with 1.
125  //
126  // Returns:
127  // Reference to the selected element.
128  //
129  {
130  return HepMatrix::operator()(row, col);
131  }
132 
134  //
135  // Purpose: Assignment operator.
136  // Raises an assertion if M does not have exactly one row.
137  //
138  // Inputs:
139  // m - The matrix to copy.
140  // Must have exactly one row.
141  //
142  // Returns:
143  // This object.
144  //
145  {
146  assert(m.num_row() == 1);
147  *((Matrix*)this) = m;
148  return *this;
149  }
150 
151  void clear(CLHEP::HepGenMatrix& m)
152  //
153  // Purpose: Reset the matrix M to zero.
154  //
155  // Inputs:
156  // m - The matrix to reset.
157  //
158  {
159  int nrow = m.num_row();
160  int ncol = m.num_col();
161  for (int i = 1; i <= nrow; i++)
162  for (int j = 1; j <= ncol; j++)
163  m(i, j) = 0;
164  }
165 
166  double scalar(const CLHEP::HepGenMatrix& m)
167  //
168  // Purpose: Return the 1x1 matrix M as a scalar.
169  // Raise an assertion if M is not 1x1.
170  //
171  // Inputs:
172  // m - The matrix to convert.
173  // Must be 1x1.
174  //
175  // Returns:
176  // m(1,1)
177  //
178  {
179  assert(m.num_row() == 1 && m.num_col() == 1);
180  return m(1, 1);
181  }
182 
183 } // namespace hitfit
mps_fire.i
i
Definition: mps_fire.py:428
hitfit
Definition: Base_Constrainer.h:43
hitfit::Row_Vector::Row_Vector
Row_Vector(int cols)
Constructor, instantiate an unitialized matrix.
Definition: matutil.cc:41
cuy.col
col
Definition: cuy.py:1009
cms::cuda::assert
assert(be >=bs)
hitfit::clear
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:151
matutil.h
Define matrix types for the HitFit package, and supply a few additional operations.
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
hitfit::scalar
double scalar(const CLHEP::HepGenMatrix &m)
Return the matrix as a scalar. Raise an assertion if the matris is not .
Definition: matutil.cc:166
hitfit::Row_Vector::operator()
const double & operator()(int col) const
Direct element access, indexing starts from 1.
Definition: matutil.cc:75
hitfit::Row_Vector::operator=
Row_Vector & operator=(const Matrix &m)
Assignment operator, will raise an assertion if m doesn't have exactly one row.
Definition: matutil.cc:133
hitfit::Matrix
CLHEP::HepMatrix Matrix
Definition: matutil.h:62
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hitfit::Row_Vector
Row-vector class. CLHEP doesn't have a row-vector class, so HitFit uses its own. This is only a simpl...
Definition: matutil.h:79