From eca24e5a3ff8a3f4c71e82bb94dd8adc8d4e5bb7 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Jun 2025 15:28:00 +0300 Subject: [PATCH 1/7] Missing `#include ` in Functional.hpp 1. Missing `#include ` ``` In file included from C:\Users\Admin\AppData\Local\Temp\.xmake\250616\_A06D4C99BAEB47BF9D52FB3EAF91C354.cpp:2: In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector.hpp:8: In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/Arithmetic.hpp:8: C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Common/Functional.hpp:126:15: error: no member named 'max' in namespace 'std' return std::max(lhs, rhs); ~~~~~^ C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Common/Functional.hpp:155:15: error: no member named 'min' in namespace 'std'; did you mean 'fmin'? return std::min(lhs, rhs); ~~~~~^ ``` --- include/Mathter/Common/Functional.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Mathter/Common/Functional.hpp b/include/Mathter/Common/Functional.hpp index 0c1c9a9..6ab93b3 100644 --- a/include/Mathter/Common/Functional.hpp +++ b/include/Mathter/Common/Functional.hpp @@ -9,6 +9,7 @@ #include #include +#include namespace mathter { @@ -332,4 +333,4 @@ struct sqrt { } }; -} // namespace mathter \ No newline at end of file +} // namespace mathter From cec8bd59bcc87b02c1687668f5cd733e0550db85 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Jun 2025 15:31:48 +0300 Subject: [PATCH 2/7] Fix "member reference base type is not a structure" error by using proper member access syntax ``` In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector.hpp:11: In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Matrix/../Vector/Math.hpp:314: In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Matrix/Math.hpp:440: C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Matrix/../Decompositions/DecomposeLU.hpp:129:33: error: member reference base type 'DecompositionLU' is not a structure or union return DecompositionLU{ L, U }.Solve(Permute(b)); ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Matrix/../Decompositions/DecomposeLU.hpp:132:48: error: member reference base type 'DecompositionLU' is not a structure or union return InversePermute(DecompositionLU{ L, U }.Solve(b)); ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ 2 errors generated. ``` --- include/Mathter/Decompositions/DecomposeLU.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/Mathter/Decompositions/DecomposeLU.hpp b/include/Mathter/Decompositions/DecomposeLU.hpp index c179e93..3102867 100644 --- a/include/Mathter/Decompositions/DecomposeLU.hpp +++ b/include/Mathter/Decompositions/DecomposeLU.hpp @@ -126,10 +126,12 @@ template auto DecompositionLUP::Solve(const Matrix& b) const { if constexpr (Order == eMatrixOrder::PRECEDE_VECTOR) { - return DecompositionLU{ L, U }.Solve(Permute(b)); + DecompositionLU dec(L, U); + return dec.Solve(Permute(b)); } else { - return InversePermute(DecompositionLU{ L, U }.Solve(b)); + DecompositionLU dec(L, U); + return InversePermute(dec.Solve(b)); } } @@ -269,4 +271,4 @@ auto DecomposeLUP(const Matrix& m) { return DecompositionLUP{ L, MatResult(U), P }; } -} // namespace mathter \ No newline at end of file +} // namespace mathter From 48b70cb1eff93bec5fae934cecf616ec54c107f1 Mon Sep 17 00:00:00 2001 From: Saikari Date: Mon, 16 Jun 2025 15:33:17 +0300 Subject: [PATCH 3/7] Create temporary variable temp to hold the result of a.zxy & apply unary minus to the temporary variable instead of directly to Vector constructor. ``` In file included from C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector.hpp:11: C:\Users\Admin\AppData\Local\.xmake\packages\m\mathter\v2.0.0\4428b8c9c4454261be12cd053ca4a35b\include\Mathter/Vector/../Matrix/../Vector/Math.hpp:379:45: error: invalid argument type 'Vector' to unary expression return FMTA(Vector(a.yzx), Vector(b.zxy), -Vector(a.zxy), Vector(b.yzx)); ^~~~~~~~~~~~~~ 1 error generated. ``` --- include/Mathter/Vector/Math.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/Mathter/Vector/Math.hpp b/include/Mathter/Vector/Math.hpp index 897d04e..3acdd7a 100644 --- a/include/Mathter/Vector/Math.hpp +++ b/include/Mathter/Vector/Math.hpp @@ -376,7 +376,8 @@ auto Cross(IterFirst first, IterLast last) -> std::enable_if_t, throw std::invalid_argument("not enough arguments for cross product"); } const auto& b = *first++; - return FMTA(Vector(a.yzx), Vector(b.zxy), -Vector(a.zxy), Vector(b.yzx)); + Vector temp = Vector(a.zxy); + return FMTA(Vector(a.yzx), Vector(b.zxy), -temp, Vector(b.yzx)); } else { return impl::CrossND(first, last); @@ -389,4 +390,4 @@ auto Cross(IterFirst first, IterLast last) -> std::enable_if_t, #if defined(MATHTER_MINMAX) #pragma pop_macro("min") #pragma pop_macro("max") -#endif \ No newline at end of file +#endif From 63b37933b19675b3d7ea3c922fee0f74f590f0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Mon, 16 Jun 2025 19:56:16 +0200 Subject: [PATCH 4/7] Fix clang11 and android ndk22 build errors --- include/Mathter/Common/Functional.hpp | 1 + include/Mathter/Decompositions/DecomposeLU.hpp | 18 ++++++++++-------- include/Mathter/Decompositions/DecomposeQR.hpp | 11 ++++++----- include/Mathter/IoStream.hpp | 1 + include/Mathter/Vector/Math.hpp | 4 ++-- include/Mathter/Vector/SIMDUtil.hpp | 3 +++ test/Cases.hpp | 1 + 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/Mathter/Common/Functional.hpp b/include/Mathter/Common/Functional.hpp index 0c1c9a9..9bf3f1d 100644 --- a/include/Mathter/Common/Functional.hpp +++ b/include/Mathter/Common/Functional.hpp @@ -7,6 +7,7 @@ #include "TypeTraits.hpp" +#include #include #include diff --git a/include/Mathter/Decompositions/DecomposeLU.hpp b/include/Mathter/Decompositions/DecomposeLU.hpp index c179e93..4927d94 100644 --- a/include/Mathter/Decompositions/DecomposeLU.hpp +++ b/include/Mathter/Decompositions/DecomposeLU.hpp @@ -39,8 +39,8 @@ struct DecompositionLU { template -DecompositionLU(const Matrix&, - const Matrix&) -> DecompositionLU; +DecompositionLU(Matrix, + Matrix) -> DecompositionLU; template @@ -73,7 +73,7 @@ auto DecompositionLU::Solve(const Vector -auto mathter::DecompositionLU::Inverse() const -> Matrix { +auto DecompositionLU::Inverse() const -> Matrix { return Solve(Mat(Identity())); } @@ -117,19 +117,21 @@ struct DecompositionLUP { template -DecompositionLUP(const Matrix&, - const Matrix&, - const Vector&) -> DecompositionLUP; +DecompositionLUP(Matrix, + Matrix, + Vector) -> DecompositionLUP; template template auto DecompositionLUP::Solve(const Matrix& b) const { if constexpr (Order == eMatrixOrder::PRECEDE_VECTOR) { - return DecompositionLU{ L, U }.Solve(Permute(b)); + const auto lu = DecompositionLU{ L, U }; + return lu.Solve(Permute(b)); } else { - return InversePermute(DecompositionLU{ L, U }.Solve(b)); + const auto lu = DecompositionLU{ L, U }; + return InversePermute(lu.Solve(b)); } } diff --git a/include/Mathter/Decompositions/DecomposeQR.hpp b/include/Mathter/Decompositions/DecomposeQR.hpp index d5f0ad3..96ff087 100644 --- a/include/Mathter/Decompositions/DecomposeQR.hpp +++ b/include/Mathter/Decompositions/DecomposeQR.hpp @@ -154,8 +154,8 @@ template auto DecompositionLQ::Solve(const Matrix& b) const { static_assert(Order == eMatrixOrder::FOLLOW_VECTOR, MATHTER_LQ_SOLVE_ORDER_ERROR); - return FlipLayoutAndOrder(DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) } - .Solve(FlipLayoutAndOrder(b))); + const auto qr = DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) }; + return FlipLayoutAndOrder(qr.Solve(FlipLayoutAndOrder(b))); } @@ -163,14 +163,15 @@ template auto DecompositionLQ::Solve(const Vector& b) const { static_assert(Order == eMatrixOrder::FOLLOW_VECTOR, MATHTER_LQ_SOLVE_ORDER_ERROR); - return DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) }.Solve(b); + const auto qr = DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) }; + return qr.Solve(b); } template auto DecompositionLQ::Inverse() const -> Matrix { - return FlipLayoutAndOrder(DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) } - .Inverse()); + const auto qr = DecompositionQR{ FlipLayoutAndOrder(Q), FlipLayoutAndOrder(L) }; + return FlipLayoutAndOrder(qr.Inverse()); } diff --git a/include/Mathter/IoStream.hpp b/include/Mathter/IoStream.hpp index 3758c18..ac9c16f 100644 --- a/include/Mathter/IoStream.hpp +++ b/include/Mathter/IoStream.hpp @@ -14,6 +14,7 @@ #include #include +#include namespace mathter { diff --git a/include/Mathter/Vector/Math.hpp b/include/Mathter/Vector/Math.hpp index 897d04e..b5f5e15 100644 --- a/include/Mathter/Vector/Math.hpp +++ b/include/Mathter/Vector/Math.hpp @@ -326,7 +326,7 @@ namespace impl { std::array>, Dim - 1> vectors; auto [argIt, outIt] = std::tuple(first, vectors.begin()); for (; argIt != last && outIt != vectors.end(); ++argIt, ++outIt) { - *outIt = std::ref(*argIt); + *outIt = { std::ref(*argIt) }; } if (outIt != vectors.end()) { throw std::invalid_argument("not enough arguments for cross product"); @@ -376,7 +376,7 @@ auto Cross(IterFirst first, IterLast last) -> std::enable_if_t, throw std::invalid_argument("not enough arguments for cross product"); } const auto& b = *first++; - return FMTA(Vector(a.yzx), Vector(b.zxy), -Vector(a.zxy), Vector(b.yzx)); + return FMTA(Vector(a.yzx), Vector(b.zxy), -std::move(Vector(a.zxy)), Vector(b.yzx)); // std::move due to CTAD bug in Clang 11. } else { return impl::CrossND(first, last); diff --git a/include/Mathter/Vector/SIMDUtil.hpp b/include/Mathter/Vector/SIMDUtil.hpp index 7f1f20c..70b1a00 100644 --- a/include/Mathter/Vector/SIMDUtil.hpp +++ b/include/Mathter/Vector/SIMDUtil.hpp @@ -2,6 +2,9 @@ #if MATHTER_ENABLE_SIMD +// clang-format: off +#include // Include tuple for XSimd. +// clang-format: on #include #endif diff --git a/test/Cases.hpp b/test/Cases.hpp index 646a033..670aa49 100644 --- a/test/Cases.hpp +++ b/test/Cases.hpp @@ -5,6 +5,7 @@ #include #include +#include #define CASE_LIST(X) decltype(X{}) From 7d17c8976b1be85232b39e9454ed360d3c2fe08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Mon, 16 Jun 2025 20:00:48 +0200 Subject: [PATCH 5/7] Dedupe header clang-format --- include/Mathter/Common/Functional.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/Mathter/Common/Functional.hpp b/include/Mathter/Common/Functional.hpp index 850458f..929f7b1 100644 --- a/include/Mathter/Common/Functional.hpp +++ b/include/Mathter/Common/Functional.hpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace mathter { From 9435ed9285cfdae974589127a1614c5bb2835340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Mon, 16 Jun 2025 20:05:11 +0200 Subject: [PATCH 6/7] More format... --- test/Cases.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Cases.hpp b/test/Cases.hpp index 670aa49..50919a4 100644 --- a/test/Cases.hpp +++ b/test/Cases.hpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #define CASE_LIST(X) decltype(X{}) From b119a4c668fe07c5dd2e549ed0a8690af28db774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kardos?= Date: Mon, 16 Jun 2025 20:36:27 +0200 Subject: [PATCH 7/7] fix clang-format directive syntax --- include/Mathter/Vector/SIMDUtil.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Mathter/Vector/SIMDUtil.hpp b/include/Mathter/Vector/SIMDUtil.hpp index 70b1a00..8d9dc2d 100644 --- a/include/Mathter/Vector/SIMDUtil.hpp +++ b/include/Mathter/Vector/SIMDUtil.hpp @@ -2,9 +2,9 @@ #if MATHTER_ENABLE_SIMD -// clang-format: off +// clang-format off #include // Include tuple for XSimd. -// clang-format: on +// clang-format on #include #endif