Loading...
Searching...
No Matches
TinyMatrix.h
Go to the documentation of this file.
1// TinyMatrix.h --- Implements a rudimentary matrix class
2
3#ifndef _TINYMATRIX_H
4#define _TINYMATRIX_H
5
6template <class Type> class TinyMatrix {
7public:
8 TinyMatrix() { data = 0; }
9 TinyMatrix(int rows, int columns) { Allocate(rows, columns); }
10 void Allocate(int rows, int columns) {
11 r = rows;
12 c = columns;
13 data = new Type[r * c];
14 }
15 ~TinyMatrix() { delete[] data; }
16 Type *operator[](int row) { return data + c * row; }
17 const Type *operator[](int row) const { return data + c * row; }
18
19private:
20 int r, c;
21 Type *data;
22};
23
25
26#endif // _TINYMATRIX_H
TinyMatrix< double > TinyDoubleMatrix
Definition TinyMatrix.h:24
TinyMatrix(int rows, int columns)
Definition TinyMatrix.h:9
const Type * operator[](int row) const
Definition TinyMatrix.h:17
void Allocate(int rows, int columns)
Definition TinyMatrix.h:10
Type * operator[](int row)
Definition TinyMatrix.h:16