From 8ceb79db1d0687bba005cef4a77bb889bf7ec3c3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 9 Jan 2022 21:47:23 +0100 Subject: refactor: rewrite to c++ --- src/matrix.hpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/matrix.hpp (limited to 'src/matrix.hpp') diff --git a/src/matrix.hpp b/src/matrix.hpp new file mode 100644 index 0000000..83f9fc2 --- /dev/null +++ b/src/matrix.hpp @@ -0,0 +1,67 @@ +#ifndef MATRIX_HPP +#define MATRIX_HPP + +#include "vector2.hpp" +#include + +/** + * A Matrix. + */ +template +class Matrix +{ +public: + /** + * Creates a matrix. + * + * @param rows The number of rows of the matrix + * @param columns The number of columns of the matrix + */ + Matrix(unsigned int rows, unsigned int columns); + + /** + * Fills the matrix with a element. + * + * @param element A element + */ + void fill(Element element); + + /** + * Prints the matrix. + */ + void print(); + + /** + * Returns a element of the matrix. + * + * @param pos The position of a element + */ + Element get(Vector2 pos); + + /** + * Sets a element of the matrix. + * + * @param pos The position of a element + * @param element A new element + */ + void set(Vector2 pos, Element element); + + /** + * Returns the number of rows the matrix has. + */ + unsigned int rows(); + + /** + * Returns the number of columns the matrix has. + */ + unsigned int columns(); + +private: + std::vector> _matrix; + unsigned int _rows; + unsigned int _columns; +}; + +#include "matrix.tpp" + +#endif -- cgit v1.2.3-18-g5258