From bc6943aed06924027de251d284136f855fb8799d Mon Sep 17 00:00:00 2001
From: Kevin <kevin.hoellring@fau.de>
Date: Mon, 28 Oct 2019 14:49:54 +0100
Subject: [PATCH] Fix broken iteration in matrix class

---
 src/matrix.h | 100 +++++++++++++++++++++++++--------------------------
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/src/matrix.h b/src/matrix.h
index 8db2dd9..47806e2 100644
--- a/src/matrix.h
+++ b/src/matrix.h
@@ -1,65 +1,65 @@
 #ifndef __MATRIX_H__
 #define __MATRIX_H__
-#include <vector>
 #include <iostream>
+#include <vector>
 
 namespace magic {
-	using std::vector;
+using std::vector;
 
-	// This is a custom Matrix type to allow for matrix multiplication
-	class Matrix {
-	public:
-		Matrix(uint8_t rows, uint8_t columns) {
-			this->_rows = rows;
-			this->_columns = columns;
-			this->entries.assign(rows, vector<int32_t>(columns, 0));
-		}
+// This is a custom Matrix type to allow for matrix multiplication
+class Matrix {
+  public:
+    Matrix(uint32_t rows, uint32_t columns) {
+        this->_rows = rows;
+        this->_columns = columns;
+        this->entries.assign(rows, vector<int32_t>(columns, 0));
+    }
 
-		void setValue(uint8_t i, uint8_t j, int32_t value) {
-			entries[i][j] = value;
-		}
+    void setValue(uint8_t i, uint8_t j, int32_t value) {
+        entries[i][j] = value;
+    }
 
-		int32_t getValue(uint8_t i, uint8_t j) {
-			return entries[i][j];
-		}
+    int32_t getValue(uint8_t i, uint8_t j) { return entries[i][j]; }
 
-		// Calculate the matrix product with another matrix
-		Matrix multiply(Matrix &other) {
-			// Create the result matrix
-			Matrix result(this->_rows, other._columns);
+    // Calculate the matrix product with another matrix
+    Matrix multiply(Matrix& other) {
+        // Create the result matrix
+        Matrix result(this->_rows, other._columns);
 
-			// Calculate all entries in the resulting matrix
-			for (uint8_t r = 0; r < this->_rows; r++) {
-				for (uint8_t c = 0; c < other._columns; c++) {
-					for (uint8_t link = 0; link < this->_columns; link++) {
-						int32_t res = result.getValue(r, c) + this->getValue(r, link) * other.getValue(link, c);
-						result.setValue(r, c, res);
-					}
-				}
-			}
+        // Calculate all entries in the resulting matrix
+        for (uint32_t r = 0; r < this->_rows; r++) {
+            for (uint32_t c = 0; c < other._columns; c++) {
+                for (uint32_t link = 0; link < this->_columns; link++) {
+                    int32_t res =
+                        result.getValue(r, c) +
+                        this->getValue(r, link) * other.getValue(link, c);
+                    result.setValue(r, c, res);
+                }
+            }
+        }
 
-			// Return the resulting matrix
-			return result;
-		}
+        // Return the resulting matrix
+        return result;
+    }
 
-		// Output the matrix to screen
-		void print() {
-			using std::cout;
-			using std::endl;
+    // Output the matrix to screen
+    void print() {
+        using std::cout;
+        using std::endl;
 
-			for (uint8_t r = 0; r < this->_rows; r++) {
-				for (uint8_t c = 0; c < this->_columns; c++) {
-					cout << entries[r][c] << '\t';
-				}
-				cout << endl;
-			}
-		}
+        for (uint8_t r = 0; r < this->_rows; r++) {
+            for (uint8_t c = 0; c < this->_columns; c++) {
+                cout << entries[r][c] << '\t';
+            }
+            cout << endl;
+        }
+    }
 
-	private:
-		uint8_t _rows;
-		uint8_t _columns;
-		vector<vector<int32_t>> entries;
-	};
-}
+  private:
+    uint32_t _rows;
+    uint32_t _columns;
+    vector<vector<int32_t>> entries;
+};
+} // namespace magic
 
-#endif
\ No newline at end of file
+#endif
-- 
GitLab