diff --git a/.gitea/workflows/Merge-Checker.yaml b/.gitea/workflows/Merge-Checker.yaml new file mode 100644 index 0000000..4a220dd --- /dev/null +++ b/.gitea/workflows/Merge-Checker.yaml @@ -0,0 +1,26 @@ +name: Merge-Checker + +on: + pull_request: + branches: ["**"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install dependencies (CMake + Ninja + Compiler) + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build build-essential + + - name: Configure project with CMake + run: | + cmake -G Ninja -S . -B build/ + + - name: Build with Ninja + run: | + ninja -C build/ diff --git a/.gitignore b/.gitignore index d163863..5b79a54 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build/ \ No newline at end of file +build/ +.cache/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index b25d6b6..9f2ed3f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,5 @@ { "C_Cpp.intelliSenseEngine": "default", - "clangd.arguments": [ - "--include-directory=build/unit-tests" - ], "C_Cpp.default.intelliSenseMode": "linux-gcc-x64", "files.associations": { "*.h": "cpp", @@ -76,6 +73,7 @@ "csignal": "cpp", "span": "cpp" }, - "clangd.enable": false, - "C_Cpp.dimInactiveRegions": false + "clangd.enable": true, + "C_Cpp.dimInactiveRegions": false, + "editor.defaultFormatter": "xaver.clang-format" } \ No newline at end of file diff --git a/src/Matrix.cpp b/src/Matrix.cpp index bc1e443..387bf3c 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -212,8 +212,8 @@ Matrix::Transpose() const // explicitly define the determinant for a 2x2 matrix because it is definitely // the fastest way to calculate a 2x2 matrix determinant -template <> -inline float Matrix<0, 0>::Det() const { return 1e+6; } +// template <> +// inline float Matrix<0, 0>::Det() const { return 1e+6; } template <> inline float Matrix<1, 1>::Det() const { return this->matrix[0]; } template <> diff --git a/src/Matrix.hpp b/src/Matrix.hpp index ea31748..ebc0151 100644 --- a/src/Matrix.hpp +++ b/src/Matrix.hpp @@ -10,10 +10,10 @@ // TODO: Add a function for SVD decomposition // TODO: Add a function for LQ decomposition -template -class Matrix -{ +template class Matrix { public: + static_assert(rows > 0, "Template error: rows must be greater than 0."); + static_assert(columns > 0, "Template error: columns must be greater than 0."); /** * @brief create a matrix but leave all of its values unitialized */ @@ -37,8 +37,7 @@ public: /** * @brief Initialize a matrix directly with any number of arguments */ - template - Matrix(Args... args); + template Matrix(Args... args); /** * @brief set the matrix diagonals to 1 and all other values to 0 @@ -189,14 +188,17 @@ public: Matrix operator-(const Matrix &other) const; template - Matrix operator*(const Matrix &other) const; + Matrix + operator*(const Matrix &other) const; Matrix operator*(float scalar) const; - template + template Matrix SubMatrix() const; - template + template void SetSubMatrix(const Matrix &sub_matrix); /** @@ -210,8 +212,9 @@ public: static float DotProduct(const Matrix &vec1, const Matrix &vec2); - static float DotProduct(const Matrix<1, 1> &vec1, - const Matrix<1, 1> &vec2) { return vec1.Get(0, 0) * vec2.Get(0, 0); } + static float DotProduct(const Matrix<1, 1> &vec1, const Matrix<1, 1> &vec2) { + return vec1.Get(0, 0) * vec2.Get(0, 0); + } protected: std::array matrix;