aboutsummaryrefslogtreecommitdiff
path: root/src/matrix.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
committerHampusM <hampus@hampusmat.com>2022-01-09 21:47:23 +0100
commit8ceb79db1d0687bba005cef4a77bb889bf7ec3c3 (patch)
treeb7c13359f652506d60c8556ea386ae8d50bfc5bc /src/matrix.hpp
parent097aa95c1f0cb159e7d9d0a3edf9284c421ee298 (diff)
refactor: rewrite to c++
Diffstat (limited to 'src/matrix.hpp')
-rw-r--r--src/matrix.hpp67
1 files changed, 67 insertions, 0 deletions
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 <vector>
+
+/**
+ * A Matrix.
+ */
+template <typename Element>
+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<std::vector<Element>> _matrix;
+ unsigned int _rows;
+ unsigned int _columns;
+};
+
+#include "matrix.tpp"
+
+#endif