diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index a3b0205..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' - create: - branches: - - 'v*' - -jobs: - package: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release - - - name: Build - run: cmake --build build --config Release - - - name: Package - run: cd build && cpack - - - name: Upload package as artifact - uses: actions/upload-artifact@v4 - with: - name: release-package - path: build/*.tar.gz - - - name: Create GitHub Release and Upload Asset - uses: softprops/action-gh-release@v2 - with: - files: build/*.tar.gz # Adjust to match what cpack generates - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8749458..7adb300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,6 @@ INCLUDE_DIRECTORIES( ${ROOT_DIR}/third-party/include/catch2 ) -LINK_DIRECTORIES(${ROOT_DIR}/lib) - -FILE(GLOB_RECURSE PROJECT_SOURCES ${ROOT_DIR}/lib/*.cpp) - FILE(GLOB_RECURSE PROJECT_HEADERS ${ROOT_DIR}/include/*.hpp) FILE(GLOB_RECURSE THIRD_PARTY_SOURCES ${ROOT_DIR}/third-party/lib/*.cpp) @@ -30,8 +26,7 @@ FILE(GLOB_RECURSE THIRD_PARTY_HEADERS ${ROOT_DIR}/third-party/include/*.hpp) SET(CMAKE_CXX_STANDARD 23) SET(CMAKE_CXX_STANDARD_REQUIRED ON) -ADD_LIBRARY(LinearLib STATIC ${PROJECT_SOURCES} - ${PROJECT_HEADERS} +ADD_LIBRARY(LinearLib STATIC ${PROJECT_HEADERS} ${THIRD_PARTY_SOURCES} ${THIRD_PARTY_HEADERS}) @@ -62,10 +57,6 @@ INSTALL(DIRECTORY ${ROOT_DIR}/include/ DESTINATION ${ROOT_DIR}/include/ FILES_MATCHING PATTERN "*.hpp") -INSTALL(DIRECTORY ${ROOT_DIR}/lib/ - DESTINATION ${ROOT_DIR}/lib/ - FILES_MATCHING PATTERN "*.cpp") - SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_PACKAGE_DESCRIPTION "A Linear Algebra Library.") diff --git a/include/Matrix.hpp b/include/LinearLib/Matrix.hpp similarity index 100% rename from include/Matrix.hpp rename to include/LinearLib/Matrix.hpp diff --git a/include/Vector.hpp b/include/LinearLib/Vector.hpp similarity index 87% rename from include/Vector.hpp rename to include/LinearLib/Vector.hpp index be8803a..dd1ce18 100644 --- a/include/Vector.hpp +++ b/include/LinearLib/Vector.hpp @@ -64,6 +64,9 @@ namespace LinearLib { return res; } + /** + * Dot Product + */ T operator*(const Vector& other) const { T res = 0; @@ -74,6 +77,19 @@ namespace LinearLib { return res; } + /** + * Scalar Multiplication + */ + Vector operator*(const T& other) const { + Vector res; + + for (std::size_t i = 0; i < N; i++) { + res[i] = data[i] * other; + } + + return res; + } + Vector<3,T> operator&(const Vector<3,T>& other) const { Vector<3,T> res; diff --git a/lib/Matrix.cpp b/lib/Matrix.cpp deleted file mode 100644 index 8c70baf..0000000 --- a/lib/Matrix.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Matrix.hpp" - -namespace LinearLib {} \ No newline at end of file diff --git a/lib/Vector.cpp b/lib/Vector.cpp deleted file mode 100644 index aaa46c9..0000000 --- a/lib/Vector.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Vector.hpp" - -namespace LinearLib {} \ No newline at end of file diff --git a/tests/MatrixTests.cpp b/tests/MatrixTests.cpp index e072034..bff4913 100644 --- a/tests/MatrixTests.cpp +++ b/tests/MatrixTests.cpp @@ -1,5 +1,5 @@ #include "catch_amalgamated.hpp" -#include "Matrix.hpp" +#include "../include/LinearLib/Matrix.hpp" using namespace LinearLib; diff --git a/tests/VectorTests.cpp b/tests/VectorTests.cpp index 31d40bd..054ceab 100644 --- a/tests/VectorTests.cpp +++ b/tests/VectorTests.cpp @@ -1,5 +1,5 @@ #include "catch_amalgamated.hpp" -#include "Vector.hpp" +#include "../include/LinearLib/Vector.hpp" using namespace LinearLib; @@ -28,6 +28,25 @@ TEST_CASE("Vector operations", "[vector]") { REQUIRE(result[2] == 3); } + SECTION("Vector scalar multiplication") { + Vector<3, bool> v1 {true, false, true}; + + Vector<3, bool> res = v1 * false; + + REQUIRE(res[0] == false); + REQUIRE(res[1] == false); + REQUIRE(res[2] == false); + + Vector<4, float> v2 {1.0f, 2.0f, 3.0f, 4.0f}; + + Vector<4, float> res2 = v2 * 2.0f; + + REQUIRE(res2[0] == 2.0f); + REQUIRE(res2[1] == 4.0f); + REQUIRE(res2[2] == 6.0f); + REQUIRE(res2[3] == 8.0f); + } + SECTION("Dot product") { Vector<3, int> v1 {1, 2, 3}; Vector<3, int> v2 {4, 5, 6};