/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
DQMOffline/RecoB/src/SimpleMatrix.h
42 строки
1 KB
Cms Build
Clang-Format
11 июн 2019, 11:28
11 июн 2019, 11:28
a394ce1
Код
Авторство
О чём код?
#ifndef RecoBTag_Analysis_SimpleMatrix_h #define RecoBTag_Analysis_SimpleMatrix_h #include <memory> #include <vector> namespace btag { template <typename T> class SimpleMatrix { public: typedef T value_type; typedef typename std::vector<T>::size_type size_type; SimpleMatrix(size_type rows, size_type cols) : width(cols), height(rows), container(rows * cols) {} ~SimpleMatrix() {} inline size_type rows() const { return height; } inline size_type cols() const { return width; } inline size_type size() const { return container.size(); } inline double &operator()(size_type row, size_type col) { return container[index(row, col)]; } inline double operator()(size_type row, size_type col) const { return container[index(row, col)]; } inline double &operator[](size_type index) { return container[index]; } inline double operator[](size_type index) const { return container[index]; } inline size_type row(size_type index) const { return index / width; } inline size_type col(size_type index) const { return index % width; } protected: size_type index(size_type row, size_type col) const { return row * width + col; } private: size_type width, height; std::vector<T> container; }; } // namespace btag #endif // GeneratorEvent_Analysis_SimpleMatrix_h