CMS 3D CMS Logo

Array2D.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTMTT_Array2D_h
2 #define L1Trigger_TrackFindingTMTT_Array2D_h
3 
5 
6 #include <vector>
7 #include <utility>
8 
9 //=== Generic 2D array class.
10 
11 // (Replaced boost::numeric::ublas::matrix when boost library
12 // became too big).
13 
14 // Author: Lucas Camolezi
15 
16 namespace tmtt {
17 
18  template <typename T>
19  class Array2D {
20  public:
21  //for a mxn matrix - row major
22  Array2D(unsigned int m, unsigned int n) : array2D_(m * n), m_{m}, n_{n} {}
23 
24  const T& operator()(unsigned int i, unsigned int j) const {
25  if (i >= m_ || j >= n_)
26  throw cms::Exception("LogicError")
27  << "Array2D: indices out of range " << i << " " << j << " " << m_ << " " << n_;
28  return array2D_[i * n_ + j];
29  }
30 
31  T& operator()(unsigned int i, unsigned int j) {
32  // Non-const version of operator, without needing to duplicate code.
33  // (Scott Meyers trick).
34  return const_cast<T&>(std::as_const(*this)(i, j));
35  }
36 
37  private:
38  std::vector<T> array2D_;
39  unsigned int m_, n_;
40  };
41 } // namespace tmtt
42 
43 #endif
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
tmtt::Array2D
Definition: Array2D.h:19
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
tmtt::Array2D::Array2D
Array2D(unsigned int m, unsigned int n)
Definition: Array2D.h:22
tmtt::Array2D::operator()
const T & operator()(unsigned int i, unsigned int j) const
Definition: Array2D.h:24
tmtt::Array2D::n_
unsigned int n_
Definition: Array2D.h:39
tmtt::Array2D::m_
unsigned int m_
Definition: Array2D.h:39
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:245
Exception.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt::Array2D::operator()
T & operator()(unsigned int i, unsigned int j)
Definition: Array2D.h:31
tmtt::Array2D::array2D_
std::vector< T > array2D_
Definition: Array2D.h:38
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16