Mercator
Matrix.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2003 Alistair Riddoch
4 
5 #ifndef MERCATOR_MATRIX_H
6 #define MERCATOR_MATRIX_H
7 
8 namespace Mercator {
9 
13 template <unsigned int COLS, unsigned int ROWS, typename FloatType = float>
14 class Matrix {
15  private:
17  FloatType m_data[COLS * ROWS];
18  public:
20  Matrix() { }
21 
23  FloatType & operator()(unsigned int col, unsigned int row) {
24  return m_data[row * COLS + col];
25  }
26 
28  const FloatType & operator()(unsigned int col, unsigned int row) const {
29  return m_data[row * COLS + col];
30  }
31 
33  FloatType & operator[](unsigned int idx) {
34  return m_data[idx];
35  }
36 };
37 
38 }
39 
40 #endif // MERCATOR_MATRIX_H
FloatType & operator[](unsigned int idx)
Accessor for accessing the array as one dimensional.
Definition: Matrix.h:33
Matrix()
Constructor for the Matrix.
Definition: Matrix.h:20
Definition: Area.cpp:20
A fixed sized array of objects.
Definition: Matrix.h:14
FloatType & operator()(unsigned int col, unsigned int row)
Accessor for modifying the array.
Definition: Matrix.h:23
FloatType m_data[COLS *ROWS]
Storage for the array of objects.
Definition: Matrix.h:17
const FloatType & operator()(unsigned int col, unsigned int row) const
Accessor for the array.
Definition: Matrix.h:28