CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1MuGMTMatrix< T > Class Template Reference

#include <L1MuGMTMatrix.h>

Public Member Functions

int colAny (int c) const
 is any element in column c > 0 ? return index or -1 More...
 
bool isMax (int r, int c) const
 is the element (r,c) the max. entry in its row and column? More...
 
bool isMin (int r, int c) const
 is the element (r,c) the min. entry in its row and column? More...
 
 L1MuGMTMatrix (const L1MuGMTMatrix< T > &)
 copy constructor More...
 
 L1MuGMTMatrix (int r, int c, T v)
 constructor More...
 
 L1MuGMTMatrix (L1MuGMTMatrix< T > &&)=default
 
Toperator() (int r, int c)
 
const Toperator() (int r, int c) const
 
L1MuGMTMatrixoperator*= (const T &s)
 scalar multiplication More...
 
L1MuGMTMatrixoperator+= (const L1MuGMTMatrix &m)
 matrix addition More...
 
L1MuGMTMatrixoperator+= (const T &s)
 scalar addition More...
 
L1MuGMTMatrixoperator= (const L1MuGMTMatrix &m)
 assignment operator More...
 
void print () const
 print matrix More...
 
void reset (T v)
 reset all elements More...
 
int rowAny (int r) const
 is any element in row r > 0 ? return index or -1 More...
 
void set (int r, int c, T v)
 set matrix element More...
 
virtual ~L1MuGMTMatrix ()=default
 destructor More...
 

Private Member Functions

Tget (int r, int c)
 
T const & get (int r, int c) const
 

Private Attributes

int c_size
 
std::unique_ptr< T[]> p_
 
int r_size
 

Detailed Description

template<class T>
class L1MuGMTMatrix< T >

Matrix.

general matrix

Definition at line 45 of file L1MuGMTMatrix.h.

Constructor & Destructor Documentation

◆ L1MuGMTMatrix() [1/3]

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( int  r,
int  c,
T  v 
)

constructor

Definition at line 108 of file L1MuGMTMatrix.h.

108  : r_size(r), c_size(c), p_(new T[r * c]) {
109  for (int i = 0; i < r_size * c_size; ++i) {
110  p_[i] = v;
111  }
112 }

◆ L1MuGMTMatrix() [2/3]

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( const L1MuGMTMatrix< T > &  mat)

copy constructor

Definition at line 117 of file L1MuGMTMatrix.h.

118  : r_size(mat.r_size), c_size(mat.c_size), p_(new T[r_size * c_size]) {
119  for (int i = 0; i < r_size * c_size; ++i) {
120  p_[i] = mat.p_[i];
121  }
122 }

◆ L1MuGMTMatrix() [3/3]

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( L1MuGMTMatrix< T > &&  )
default

◆ ~L1MuGMTMatrix()

template<class T>
virtual L1MuGMTMatrix< T >::~L1MuGMTMatrix ( )
virtualdefault

destructor

Member Function Documentation

◆ colAny()

template<class T >
int L1MuGMTMatrix< T >::colAny ( int  c) const

is any element in column c > 0 ? return index or -1

Definition at line 262 of file L1MuGMTMatrix.h.

262  {
263  int stat = -1;
264  for (int i = 0; i < r_size; i++) {
265  if (this->get(i, c) > 0)
266  stat = i;
267  }
268 
269  return stat;
270 }

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

◆ get() [1/2]

template<class T>
T& L1MuGMTMatrix< T >::get ( int  r,
int  c 
)
inlineprivate

◆ get() [2/2]

template<class T>
T const& L1MuGMTMatrix< T >::get ( int  r,
int  c 
) const
inlineprivate

◆ isMax()

template<class T >
bool L1MuGMTMatrix< T >::isMax ( int  r,
int  c 
) const

is the element (r,c) the max. entry in its row and column?

Definition at line 222 of file L1MuGMTMatrix.h.

222  {
223  bool max = true;
224 
225  for (int i = 0; i < c; i++) {
226  max = max && (this->get(r, c) > this->get(r, i));
227  }
228  for (int i = c + 1; i < c_size; i++) {
229  max = max && (this->get(r, c) >= this->get(r, i));
230  }
231 
232  for (int j = 0; j < r; j++) {
233  max = max && (this->get(r, c) > this->get(j, c));
234  }
235  for (int j = r + 1; j < r_size; j++) {
236  max = max && (this->get(r, c) >= this->get(j, c));
237  }
238 
239  return max;
240 }

Referenced by L1MuGMTMatcher::match().

◆ isMin()

template<class T >
bool L1MuGMTMatrix< T >::isMin ( int  r,
int  c 
) const

is the element (r,c) the min. entry in its row and column?

Definition at line 246 of file L1MuGMTMatrix.h.

246  {
247  bool min = true;
248  for (int i = 0; i < c_size; i++) {
249  min = min && (this->get(r, c) <= this->get(r, i));
250  }
251  for (int j = 0; j < r_size; j++) {
252  min = min && (this->get(r, c) <= this->get(j, c));
253  }
254 
255  return min;
256 }

◆ operator()() [1/2]

template<class T >
T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
)

Definition at line 128 of file L1MuGMTMatrix.h.

128  {
129  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
130 
131  return get(r, c);
132 }

◆ operator()() [2/2]

template<class T >
const T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
) const

Definition at line 138 of file L1MuGMTMatrix.h.

138  {
139  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
140 
141  return get(r, c);
142 }

◆ operator*=()

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator*= ( const T s)

scalar multiplication

Definition at line 210 of file L1MuGMTMatrix.h.

210  {
211  for (int i = 0; i < r_size * c_size; ++i) {
212  p_[i] *= s;
213  }
214 
215  return *this;
216 }

◆ operator+=() [1/2]

template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const L1MuGMTMatrix< T > &  m)

matrix addition

Definition at line 184 of file L1MuGMTMatrix.h.

184  {
185  assert(m.c_size == c_size && m.r_size == r_size);
186 
187  for (int i = 0; i < r_size * c_size; ++i) {
188  p_[i] += m.p_[i];
189  }
190 
191  return *this;
192 }

◆ operator+=() [2/2]

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const T s)

scalar addition

Definition at line 198 of file L1MuGMTMatrix.h.

198  {
199  for (int i = 0; i < r_size * c_size; ++i) {
200  p_[i] += s;
201  }
202 
203  return *this;
204 }

◆ operator=()

template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator= ( const L1MuGMTMatrix< T > &  m)

assignment operator

Definition at line 168 of file L1MuGMTMatrix.h.

168  {
169  if (this != &m) {
170  assert(m.c_size == c_size && m.r_size == r_size);
171 
172  for (int i = 0; i < r_size * c_size; ++i) {
173  p_[i] = m.p_[i];
174  }
175  }
176 
177  return (*this);
178 }

◆ print()

template<class T >
void L1MuGMTMatrix< T >::print ( void  ) const

print matrix

Definition at line 290 of file L1MuGMTMatrix.h.

290  {
291  for (int r = 0; r < r_size; r++) {
292  std::stringstream output;
293  for (int c = 0; c < c_size; c++)
294  output << get(r, c) << "\t";
295  edm::LogVerbatim("GMTMatrix_print") << output.str();
296  }
297  edm::LogVerbatim("GMTMatrix_print");
298 }

Referenced by L1MuGMTMatcher::print().

◆ reset()

template<class T>
void L1MuGMTMatrix< T >::reset ( T  v)

reset all elements

Definition at line 148 of file L1MuGMTMatrix.h.

148  {
149  for (int i = 0; i < r_size * c_size; ++i) {
150  p_[i] = v;
151  }
152 }

Referenced by L1MuGMTInputEvent::reset(), L1MuGMTMatcher::reset(), and L1MuGMTPSB::reset().

◆ rowAny()

template<class T >
int L1MuGMTMatrix< T >::rowAny ( int  r) const

is any element in row r > 0 ? return index or -1

Definition at line 276 of file L1MuGMTMatrix.h.

276  {
277  int stat = -1;
278  for (int i = 0; i < c_size; i++) {
279  if (this->get(r, i) > 0)
280  stat = i;
281  }
282 
283  return stat;
284 }

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

◆ set()

template<class T>
void L1MuGMTMatrix< T >::set ( int  r,
int  c,
T  v 
)

set matrix element

Definition at line 158 of file L1MuGMTMatrix.h.

158  {
159  assert(r >= 0 && r < r_size && c >= 0 && c < c_size);
160 
161  get(r, c) = v;
162 }

Referenced by L1MuGMTPSB::getCalo().

Member Data Documentation

◆ c_size

template<class T>
int L1MuGMTMatrix< T >::c_size
private

◆ p_

template<class T>
std::unique_ptr<T[]> L1MuGMTMatrix< T >::p_
private

◆ r_size

template<class T>
int L1MuGMTMatrix< T >::r_size
private

Definition at line 102 of file L1MuGMTMatrix.h.

Referenced by L1MuGMTMatrix< bool >::L1MuGMTMatrix().

L1MuGMTMatrix::get
T & get(int r, int c)
Definition: L1MuGMTMatrix.h:98
mps_fire.i
i
Definition: mps_fire.py:428
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
min
T min(T a, T b)
Definition: MathUtil.h:58
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
alignCSCRings.s
s
Definition: alignCSCRings.py:92
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
L1MuGMTMatrix::c_size
int c_size
Definition: L1MuGMTMatrix.h:102
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
L1MuGMTMatrix::r_size
int r_size
Definition: L1MuGMTMatrix.h:102
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
T
long double T
Definition: Basic3DVectorLD.h:48
L1MuGMTMatrix::p_
std::unique_ptr< T[]> p_
Definition: L1MuGMTMatrix.h:104
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66