From ca54f71149cbe1ad92af16654b698fc666d085d2 Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Mon, 9 Dec 2024 12:15:47 -0500 Subject: [PATCH 1/4] Generalize MatVec multiplication types --- include/educelab/core/types/Mat.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/educelab/core/types/Mat.hpp b/include/educelab/core/types/Mat.hpp index 6875e16..dc0e495 100644 --- a/include/educelab/core/types/Mat.hpp +++ b/include/educelab/core/types/Mat.hpp @@ -116,10 +116,10 @@ auto operator*(const Mat& A, const Mat& B) -> Mat } /** @brief Matrix-vector multiplication */ -template -auto operator*(const Mat& mat, const Vec& vec) -> Vec +template +auto operator*(const Mat& mat, const Vector& vec) -> Vector { - Vec res; + Vector res; for (std::size_t m{0}; m < M; m++) { for (std::size_t n{0}; n < N; n++) { res[m] += mat(m, n) * vec[n]; From 3a85308551364e631e862e756d0b6f1b981a3dd8 Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Mon, 9 Dec 2024 12:18:30 -0500 Subject: [PATCH 2/4] string: Add ref --- include/educelab/core/utils/String.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/educelab/core/utils/String.hpp b/include/educelab/core/utils/String.hpp index 0b0d641..dda3b01 100644 --- a/include/educelab/core/utils/String.hpp +++ b/include/educelab/core/utils/String.hpp @@ -197,7 +197,7 @@ static auto split(std::string_view s, const Ds&... ds) // Split string std::vector tokens; std::string_view::size_type begin{0}; - for (const auto [end, size] : delimPos) { + for (const auto& [end, size] : delimPos) { // ignore nested delimiters if (end < begin) { continue; From 7a526755d2be2b90bbdc2eac802eb8b819ca1202 Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Mon, 9 Dec 2024 14:16:37 -0500 Subject: [PATCH 3/4] Restore mat/vec --- include/educelab/core/types/Mat.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/educelab/core/types/Mat.hpp b/include/educelab/core/types/Mat.hpp index dc0e495..6875e16 100644 --- a/include/educelab/core/types/Mat.hpp +++ b/include/educelab/core/types/Mat.hpp @@ -116,10 +116,10 @@ auto operator*(const Mat& A, const Mat& B) -> Mat } /** @brief Matrix-vector multiplication */ -template -auto operator*(const Mat& mat, const Vector& vec) -> Vector +template +auto operator*(const Mat& mat, const Vec& vec) -> Vec { - Vector res; + Vec res; for (std::size_t m{0}; m < M; m++) { for (std::size_t n{0}; n < N; n++) { res[m] += mat(m, n) * vec[n]; From 139481f036547aa802363bfb9120365a71925a45 Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Mon, 9 Dec 2024 14:44:43 -0500 Subject: [PATCH 4/4] Remove trailing semicolon --- include/educelab/core/types/Mat.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/educelab/core/types/Mat.hpp b/include/educelab/core/types/Mat.hpp index 6875e16..25ebc7d 100644 --- a/include/educelab/core/types/Mat.hpp +++ b/include/educelab/core/types/Mat.hpp @@ -26,7 +26,7 @@ class Mat static constexpr std::size_t cols{Cols}; /** Default constructor */ - Mat() { vals_.fill(0); }; + Mat() { vals_.fill(0); } /** @brief Constructor with fill values */ template