ModErn Text Analysis
META Enumerates Textual Applications
dense_matrix.h
Go to the documentation of this file.
1 
10 #ifndef META_UTIL_DENSE_MATRIX_H_
11 #define META_UTIL_DENSE_MATRIX_H_
12 
13 #include <cstdint>
14 #include <vector>
15 
16 namespace meta
17 {
18 namespace util
19 {
20 
26 template <class T>
28 {
29  public:
33  dense_matrix() = default;
34 
38  dense_matrix(const dense_matrix&) = default;
39 
43  dense_matrix(dense_matrix&&) = default;
44 
48  dense_matrix& operator=(const dense_matrix&) = default;
49 
53  dense_matrix& operator=(dense_matrix&&) = default;
54 
64  dense_matrix(uint64_t rows, uint64_t columns);
65 
74  void resize(uint64_t rows, uint64_t columns);
75 
83  T& operator()(uint64_t row, uint64_t column);
84 
92  const T& operator()(uint64_t row, uint64_t column) const;
93 
94  using row_iterator = typename std::vector<T>::iterator;
95  using const_row_iterator = typename std::vector<T>::const_iterator;
96 
101  row_iterator begin(uint64_t row);
102 
107  const_row_iterator begin(uint64_t row) const;
108 
113  row_iterator end(uint64_t row);
114 
119  const_row_iterator end(uint64_t row) const;
120 
124  uint64_t rows() const;
125 
129  uint64_t columns() const;
130 
131  private:
133  std::vector<T> storage_;
135  uint64_t columns_;
136 };
137 
138 }
139 }
140 
141 #include "util/dense_matrix.tcc"
142 
143 #endif
uint64_t rows() const
Definition: dense_matrix.tcc:66
Simple wrapper class for representing a dense matrix laid out in row-major order (that is...
Definition: dense_matrix.h:27
row_iterator end(uint64_t row)
Definition: dense_matrix.tcc:54
uint64_t columns() const
Definition: dense_matrix.tcc:72
std::vector< T > storage_
the underlying storage for the matrix
Definition: dense_matrix.h:133
uint64_t columns_
the number of columns in the matrix
Definition: dense_matrix.h:135
void resize(uint64_t rows, uint64_t columns)
Resizes the dense_matrix to have the specified number of rows and columns.
Definition: dense_matrix.tcc:34
row_iterator begin(uint64_t row)
Definition: dense_matrix.tcc:42
T & operator()(uint64_t row, uint64_t column)
Obtains the column-th element of the row-th row.
Definition: dense_matrix.tcc:22
dense_matrix & operator=(const dense_matrix &)=default
dense_matrix may be copy assigned.
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
dense_matrix()=default
Default constructed matrices are empty.