CMS 3D CMS Logo

SimpleMatrix.h
Go to the documentation of this file.
1 #ifndef RecoBTag_Analysis_SimpleMatrix_h
2 #define RecoBTag_Analysis_SimpleMatrix_h
3 
4 #include <memory>
5 #include <vector>
6 
7 namespace btag {
8 
9  template <typename T>
10  class SimpleMatrix {
11  public:
12  typedef T value_type;
14 
16 
18 
19  inline size_type rows() const { return height; }
20  inline size_type cols() const { return width; }
21  inline size_type size() const { return container.size(); }
22 
23  inline double &operator()(size_type row, size_type col) { return container[index(row, col)]; }
24  inline double operator()(size_type row, size_type col) const { return container[index(row, col)]; }
25 
26  inline double &operator[](size_type index) { return container[index]; }
27  inline double operator[](size_type index) const { return container[index]; }
28 
29  inline size_type row(size_type index) const { return index / width; }
30  inline size_type col(size_type index) const { return index % width; }
31 
32  protected:
33  size_type index(size_type row, size_type col) const { return row * width + col; }
34 
35  private:
37  std::vector<T> container;
38  };
39 
40 } // namespace btag
41 
42 #endif // GeneratorEvent_Analysis_SimpleMatrix_h
btag::SimpleMatrix::col
size_type col(size_type index) const
Definition: SimpleMatrix.h:30
btag::SimpleMatrix::~SimpleMatrix
~SimpleMatrix()
Definition: SimpleMatrix.h:17
btag::SimpleMatrix::container
std::vector< T > container
Definition: SimpleMatrix.h:37
btag::SimpleMatrix::size
size_type size() const
Definition: SimpleMatrix.h:21
btag::SimpleMatrix::SimpleMatrix
SimpleMatrix(size_type rows, size_type cols)
Definition: SimpleMatrix.h:15
btag::SimpleMatrix::size_type
std::vector< T >::size_type size_type
Definition: SimpleMatrix.h:13
btag::SimpleMatrix::rows
size_type rows() const
Definition: SimpleMatrix.h:19
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
btag::SimpleMatrix::cols
size_type cols() const
Definition: SimpleMatrix.h:20
btag::SimpleMatrix::row
size_type row(size_type index) const
Definition: SimpleMatrix.h:29
btag::SimpleMatrix::operator[]
double operator[](size_type index) const
Definition: SimpleMatrix.h:27
btag::SimpleMatrix::index
size_type index(size_type row, size_type col) const
Definition: SimpleMatrix.h:33
btag::SimpleMatrix::operator[]
double & operator[](size_type index)
Definition: SimpleMatrix.h:26
btag::SimpleMatrix::value_type
T value_type
Definition: SimpleMatrix.h:12
T
long double T
Definition: Basic3DVectorLD.h:48
btag::SimpleMatrix::operator()
double operator()(size_type row, size_type col) const
Definition: SimpleMatrix.h:24
btag::SimpleMatrix::operator()
double & operator()(size_type row, size_type col)
Definition: SimpleMatrix.h:23
btag::SimpleMatrix::height
size_type height
Definition: SimpleMatrix.h:36
btag::SimpleMatrix::width
size_type width
Definition: SimpleMatrix.h:36
btag
Definition: Matching.h:10
btag::SimpleMatrix
Definition: SimpleMatrix.h:10