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
double & operator()(size_type row, size_type col)
Definition: SimpleMatrix.h:23
std::vector< T > container
Definition: SimpleMatrix.h:37
uint16_t size_type
Definition: Matching.h:10
double operator()(size_type row, size_type col) const
Definition: SimpleMatrix.h:24
size_type cols() const
Definition: SimpleMatrix.h:20
size_type row(size_type index) const
Definition: SimpleMatrix.h:29
double & operator[](size_type index)
Definition: SimpleMatrix.h:26
size_type index(size_type row, size_type col) const
Definition: SimpleMatrix.h:33
size_type rows() const
Definition: SimpleMatrix.h:19
double operator[](size_type index) const
Definition: SimpleMatrix.h:27
std::vector< T >::size_type size_type
Definition: SimpleMatrix.h:13
size_type col(size_type index) const
Definition: SimpleMatrix.h:30
SimpleMatrix(size_type rows, size_type cols)
Definition: SimpleMatrix.h:15
long double T
size_type size() const
Definition: SimpleMatrix.h:21