Skip to content
Snippets Groups Projects
Commit 53f57cb0 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add meta-programming access to convenient static values

These are TinyMatrix::Dimension TinyMatrix::NumberOfRows and TinyMatrix::NumberOfColumns

Also add related tests
parent 28b9380b
No related branches found
No related tags found
1 merge request!116Add tests for EmbeddedIDiscreteFunctionUtils
......@@ -14,6 +14,10 @@ template <size_t M, size_t N = M, typename T = double>
class [[nodiscard]] TinyMatrix
{
public:
inline static constexpr size_t Dimension = M * N;
inline static constexpr size_t NumberOfRows = M;
inline static constexpr size_t NumberOfColumns = N;
using data_type = T;
private:
......
......@@ -21,6 +21,16 @@ template class TinyMatrix<4, 4, double>;
TEST_CASE("TinyMatrix", "[algebra]")
{
REQUIRE(TinyMatrix<1, 1, int>::Dimension == 1);
REQUIRE(TinyMatrix<1, 1, int>::NumberOfRows == 1);
REQUIRE(TinyMatrix<1, 1, int>::NumberOfColumns == 1);
REQUIRE(TinyMatrix<2, 3, int>::Dimension == 6);
REQUIRE(TinyMatrix<2, 3, int>::NumberOfRows == 2);
REQUIRE(TinyMatrix<2, 3, int>::NumberOfColumns == 3);
REQUIRE(TinyMatrix<5, 4, int>::Dimension == 20);
REQUIRE(TinyMatrix<5, 4, int>::NumberOfRows == 5);
REQUIRE(TinyMatrix<5, 4, int>::NumberOfColumns == 4);
TinyMatrix<3, 4, int> A(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 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 //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment