CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
15  SimpleMatrix(size_type rows, size_type cols) : width(cols), height(rows), container(rows * cols) {}
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
size_type rows() const
Definition: SimpleMatrix.h:19
double operator()(size_type row, size_type col) const
Definition: SimpleMatrix.h:24
size_type col(size_type index) const
Definition: SimpleMatrix.h:30
size_type row(size_type index) const
Definition: SimpleMatrix.h:29
double & operator()(size_type row, size_type col)
Definition: SimpleMatrix.h:23
std::vector< T > container
Definition: SimpleMatrix.h:37
size_type cols() const
Definition: SimpleMatrix.h:20
uint16_t size_type
size_type size() const
Definition: SimpleMatrix.h:21
double & operator[](size_type index)
Definition: SimpleMatrix.h:26
std::vector< T >::size_type size_type
Definition: SimpleMatrix.h:13
tuple btag
Definition: BTagSF.py:16
double operator[](size_type index) const
Definition: SimpleMatrix.h:27
SimpleMatrix(size_type rows, size_type cols)
Definition: SimpleMatrix.h:15
long double T
size_type index(size_type row, size_type col) const
Definition: SimpleMatrix.h:33