diff --git a/src/algebra/TinyMatrix.hpp b/src/algebra/TinyMatrix.hpp index 1717b48c78deaedc7cabd9f60feb215e29a80ebe..8e0bbd4db39f20977afa3725177f728d7094710d 100644 --- a/src/algebra/TinyMatrix.hpp +++ b/src/algebra/TinyMatrix.hpp @@ -43,6 +43,18 @@ class [[nodiscard]] TinyMatrix } } + template <typename... Args> + PUGS_FORCEINLINE constexpr void + _unpackVariadicInput(const TinyVector<M, T>& t, Args&&... args) noexcept + { + for (size_t j = 0; j < M; ++j) { + m_values[_index(j, N - 1 - sizeof...(args))] = t[j]; + } + if constexpr (sizeof...(args) > 0) { + this->_unpackVariadicInput(std::forward<Args>(args)...); + } + } + public: PUGS_INLINE constexpr bool @@ -322,6 +334,13 @@ class [[nodiscard]] TinyMatrix this->_unpackVariadicInput(t, std::forward<Args>(args)...); } + template <typename... Args> + PUGS_INLINE explicit constexpr TinyMatrix(const TinyVector<M, T>& t, Args&&... args) noexcept + { + static_assert(sizeof...(args) == N - 1, "wrong number of parameters"); + this->_unpackVariadicInput(t, std::forward<Args>(args)...); + } + // One does not use the '=default' constructor to avoid (unexpected) // performances issues PUGS_INLINE diff --git a/src/scheme/FluxingAdvectionSolver.cpp b/src/scheme/FluxingAdvectionSolver.cpp index eba4c3278151291dea9a411e0e528cf6d19e08c2..4576dedcb67ced609d8ffd226deb6e53f081410d 100644 --- a/src/scheme/FluxingAdvectionSolver.cpp +++ b/src/scheme/FluxingAdvectionSolver.cpp @@ -205,10 +205,10 @@ FluxingAdvectionSolver<3>::_computeAlgebraicFluxingVolume() const Rd& x2 = old_xr[face_to_node[2]]; const Rd& x3 = old_xr[face_to_node[3]]; - const Rd& x4 = new_xr[face_to_node[1]]; - const Rd& x5 = new_xr[face_to_node[0]]; - const Rd& x6 = new_xr[face_to_node[1]]; - const Rd& x7 = new_xr[face_to_node[0]]; + const Rd& x4 = new_xr[face_to_node[0]]; + const Rd& x5 = new_xr[face_to_node[1]]; + const Rd& x6 = new_xr[face_to_node[2]]; + const Rd& x7 = new_xr[face_to_node[3]]; const Rd& a1 = x6 - x1; const Rd& a2 = x6 - x3; diff --git a/tests/test_TinyMatrix.cpp b/tests/test_TinyMatrix.cpp index f6f09cf55dd2ad1ffef55c9275b989c203598f7e..03d3bbe5dc0ad69655cda5d3ae764d8e770b0d60 100644 --- a/tests/test_TinyMatrix.cpp +++ b/tests/test_TinyMatrix.cpp @@ -32,10 +32,14 @@ TEST_CASE("TinyMatrix", "[algebra]") REQUIRE(TinyMatrix<5, 4, int>::NumberOfColumns == 4); TinyMatrix<3, 4, int> A(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); + TinyVector<3, int> x1(1, 5, 9); + TinyVector<3, int> x2(2, 6, 10); + TinyVector<3, int> x3(3, 7, 11); + TinyVector<3, int> x4(4, 8, 12); REQUIRE(((A(0, 0) == 1) and (A(0, 1) == 2) and (A(0, 2) == 3) and (A(0, 3) == 4) and // (A(1, 0) == 5) and (A(1, 1) == 6) and (A(1, 2) == 7) and (A(1, 3) == 8) and // (A(2, 0) == 9) and (A(2, 1) == 10) and (A(2, 2) == 11) and (A(2, 3) == 12))); - + REQUIRE(A == TinyMatrix<3, 4, int>(x1, x2, x3, x4)); TinyMatrix<3, 4, int> B(6, 5, 3, 8, 34, 6, 35, 6, 7, 1, 3, 6); SECTION("checking for opposed matrix")