Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/cd.yml

This file was deleted.

11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})

Expand Down Expand Up @@ -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.")

Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions include/Vector.hpp → include/LinearLib/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ namespace LinearLib {
return res;
}

/**
* Dot Product
*/
T operator*(const Vector& other) const {
T res = 0;

Expand All @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions lib/Matrix.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions lib/Vector.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion tests/MatrixTests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "catch_amalgamated.hpp"
#include "Matrix.hpp"
#include "../include/LinearLib/Matrix.hpp"

using namespace LinearLib;

Expand Down
21 changes: 20 additions & 1 deletion tests/VectorTests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "catch_amalgamated.hpp"
#include "Vector.hpp"
#include "../include/LinearLib/Vector.hpp"

using namespace LinearLib;

Expand Down Expand Up @@ -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};
Expand Down