-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatx.h
More file actions
29 lines (21 loc) · 692 Bytes
/
Matx.h
File metadata and controls
29 lines (21 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef MATX_H
#define MATX_H
#include <memory>
template<bool BY_ROWS = true>
class CMatx {
public:
CMatx(size_t _rows = 1, size_t _cols = 1) :
m_Matx(std::make_unique<float[]>(_rows * _cols)),
m_Rows(_rows), m_Cols(_cols) { }
size_t Rows() const { return m_Rows; }
size_t Cols() const { return m_Cols; }
float& At(size_t _row, size_t _col);
private:
std::unique_ptr<float[]> m_Matx;
size_t m_Rows, m_Cols;
};
template<>
inline float& CMatx<true>::At(size_t _row, size_t _col) { return m_Matx[_row * m_Cols + _col]; }
template<>
inline float& CMatx<false>::At(size_t _row, size_t _col) { return m_Matx[_col * m_Rows + _row]; }
#endif // MATX_H