Resolve "[API-#2] Pseudo-privatization of rotgen entity member functions"

Closes #18

Co-authored-by: Jules Pénuchot <jules@penuchot.com>

See merge request oss/rotgen!50
This commit is contained in:
Jules Pénuchot 2025-12-17 20:48:00 +01:00 committed by Joel Falcou
parent 6489697c05
commit e151e136d6
52 changed files with 2212 additions and 1556 deletions

View file

@ -15,8 +15,8 @@ TTS_CASE_TPL("Default matrix dynamic constructor", rotgen::tests::types)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> matrix;
TTS_EQUAL(matrix.rows(), rotgen::Index{0});
TTS_EQUAL(matrix.cols(), rotgen::Index{0});
TTS_EQUAL(rows(matrix), rotgen::Index{0});
TTS_EQUAL(cols(matrix), rotgen::Index{0});
};
TTS_CASE_TPL("Default matrix static constructor", rotgen::tests::types)
@ -25,8 +25,8 @@ TTS_CASE_TPL("Default matrix static constructor", rotgen::tests::types)
{
rotgen::matrix<T, 4, 9, O::value> matrix;
TTS_EQUAL(matrix.rows(), rotgen::Index{4});
TTS_EQUAL(matrix.cols(), rotgen::Index{9});
TTS_EQUAL(rows(matrix), rotgen::Index{4});
TTS_EQUAL(cols(matrix), rotgen::Index{9});
};
TTS_CASE_TPL("Dynamic matrix constructor with row and columns",
@ -36,8 +36,8 @@ TTS_CASE_TPL("Dynamic matrix constructor with row and columns",
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> matrix(10, 5);
TTS_EQUAL(matrix.rows(), rotgen::Index{10});
TTS_EQUAL(matrix.cols(), rotgen::Index{5});
TTS_EQUAL(rows(matrix), rotgen::Index{10});
TTS_EQUAL(cols(matrix), rotgen::Index{5});
};
TTS_CASE_TPL("Static matrix constructor with row and columns", float, double)
@ -72,16 +72,16 @@ TTS_CASE_TPL("Copy constructor produces identical but independent matrix",
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a(3, 3);
for (rotgen::Index r = 0; r < a.rows(); r++)
for (rotgen::Index c = 0; c < a.cols(); c++) a(r, c) = r + c;
for (rotgen::Index r = 0; r < rows(a); r++)
for (rotgen::Index c = 0; c < cols(a); c++) a(r, c) = r + c;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b = a;
TTS_EQUAL(b.rows(), a.rows());
TTS_EQUAL(b.cols(), a.cols());
TTS_EQUAL(rows(b), rows(a));
TTS_EQUAL(cols(b), cols(a));
for (rotgen::Index r = 0; r < a.rows(); r++)
for (rotgen::Index c = 0; c < a.cols(); c++) TTS_EQUAL(b(r, c), a(r, c));
for (rotgen::Index r = 0; r < rows(a); r++)
for (rotgen::Index c = 0; c < cols(a); c++) TTS_EQUAL(b(r, c), a(r, c));
TTS_EQUAL(b(0, 0), 0.0);
TTS_EQUAL(b(1, 0), 1.0);
@ -97,8 +97,8 @@ TTS_CASE_TPL("Copy constructor on default matrix", rotgen::tests::types)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b = a;
TTS_EQUAL(b.rows(), rotgen::Index{0});
TTS_EQUAL(b.cols(), rotgen::Index{0});
TTS_EQUAL(rows(b), rotgen::Index{0});
TTS_EQUAL(cols(b), rotgen::Index{0});
};
TTS_CASE_TPL("Copy constructor from const matrix", rotgen::tests::types)
@ -107,8 +107,8 @@ TTS_CASE_TPL("Copy constructor from const matrix", rotgen::tests::types)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> const a(2, 2);
auto b = a;
TTS_EQUAL(b.rows(), rotgen::Index{2});
TTS_EQUAL(b.cols(), rotgen::Index{2});
TTS_EQUAL(rows(b), rotgen::Index{2});
TTS_EQUAL(cols(b), rotgen::Index{2});
};
TTS_CASE_TPL("Copy constructor on static matrix", rotgen::tests::types)
@ -117,8 +117,8 @@ TTS_CASE_TPL("Copy constructor on static matrix", rotgen::tests::types)
{
rotgen::matrix<T, 2, 5> a;
rotgen::matrix<T, 2, 5> b = a;
TTS_EQUAL(b.rows(), rotgen::Index{2});
TTS_EQUAL(b.cols(), rotgen::Index{5});
TTS_EQUAL(rows(b), rotgen::Index{2});
TTS_EQUAL(cols(b), rotgen::Index{5});
};
TTS_CASE_TPL("Copy constructor on static/dynamic matrix", rotgen::tests::types)
@ -127,8 +127,8 @@ TTS_CASE_TPL("Copy constructor on static/dynamic matrix", rotgen::tests::types)
{
rotgen::matrix<T, 11, 4, O::value> a;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b = a;
TTS_EQUAL(b.rows(), 11);
TTS_EQUAL(b.cols(), 4);
TTS_EQUAL(rows(b), 11);
TTS_EQUAL(cols(b), 4);
};
TTS_CASE_TPL("Copy constructor on dynamic/static matrix", rotgen::tests::types)
@ -137,8 +137,8 @@ TTS_CASE_TPL("Copy constructor on dynamic/static matrix", rotgen::tests::types)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a(5, 7);
rotgen::matrix<T, 5, 7, O::value> b = a;
TTS_EQUAL(b.rows(), 5);
TTS_EQUAL(b.cols(), 7);
TTS_EQUAL(rows(b), 5);
TTS_EQUAL(cols(b), 7);
};
TTS_CASE_TPL("Move constructor transfers contents", rotgen::tests::types)
@ -153,8 +153,8 @@ TTS_CASE_TPL("Move constructor transfers contents", rotgen::tests::types)
std::move(a);
TTS_EQUAL(b(1, 1), 7);
TTS_EQUAL(b.rows(), rotgen::Index{3});
TTS_EQUAL(b.cols(), rotgen::Index{3});
TTS_EQUAL(rows(b), rotgen::Index{3});
TTS_EQUAL(cols(b), rotgen::Index{3});
TTS_EXPECT(b.data() == ptr);
};
@ -164,8 +164,8 @@ TTS_CASE_TPL("Move constructor from Rvalue", rotgen::tests::types)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b =
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>(2, 2);
TTS_EQUAL(b.rows(), rotgen::Index{2});
TTS_EQUAL(b.cols(), rotgen::Index{2});
TTS_EQUAL(rows(b), rotgen::Index{2});
TTS_EQUAL(cols(b), rotgen::Index{2});
};
TTS_CASE_TPL("Constructor from Initializer list", rotgen::tests::types)
@ -173,24 +173,24 @@ TTS_CASE_TPL("Constructor from Initializer list", rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
rotgen::matrix<T, 1, 1, O::value> b1{3.5};
TTS_EQUAL(b1.rows(), rotgen::Index{1});
TTS_EQUAL(b1.cols(), rotgen::Index{1});
TTS_EQUAL(rows(b1), rotgen::Index{1});
TTS_EQUAL(cols(b1), rotgen::Index{1});
TTS_EQUAL(b1(0), 3.5);
rotgen::matrix<T, 5, 1, rotgen::ColMajor> b9{0.25, 0.5, 1, 2, 4};
TTS_EQUAL(b9.rows(), rotgen::Index{5});
TTS_EQUAL(b9.cols(), rotgen::Index{1});
TTS_EQUAL(rows(b9), rotgen::Index{5});
TTS_EQUAL(cols(b9), rotgen::Index{1});
T i = 0.25;
for (rotgen::Index r = 0; r < b9.rows(); ++r)
for (rotgen::Index r = 0; r < rows(b9); ++r)
{
TTS_EQUAL(b9(r, 0), i);
i *= 2;
}
rotgen::matrix<T, 1, 3, rotgen::RowMajor> b13{1.2, 2.3, 3.4};
TTS_EQUAL(b13.rows(), rotgen::Index{1});
TTS_EQUAL(b13.cols(), rotgen::Index{3});
TTS_EQUAL(rows(b13), rotgen::Index{1});
TTS_EQUAL(cols(b13), rotgen::Index{3});
TTS_EQUAL(b13(0), T(1.2));
TTS_EQUAL(b13(1), T(2.3));
TTS_EQUAL(b13(2), T(3.4));
@ -201,16 +201,16 @@ TTS_CASE_TPL("Constructor from Initializer list of rows", rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b1{{3.5}};
TTS_EQUAL(b1.rows(), rotgen::Index{1});
TTS_EQUAL(b1.cols(), rotgen::Index{1});
TTS_EQUAL(rows(b1), rotgen::Index{1});
TTS_EQUAL(cols(b1), rotgen::Index{1});
TTS_EQUAL(b1(0, 0), T(3.5));
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> b23{
{1.2, 2.3, 3.4},
{10, 200, 3000}};
TTS_EQUAL(b23.rows(), rotgen::Index{2});
TTS_EQUAL(b23.cols(), rotgen::Index{3});
TTS_EQUAL(rows(b23), rotgen::Index{2});
TTS_EQUAL(cols(b23), rotgen::Index{3});
TTS_EQUAL(b23(0, 0), T(1.2));
TTS_EQUAL(b23(0, 1), T(2.3));
TTS_EQUAL(b23(0, 2), T(3.4));