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:
parent
6489697c05
commit
e151e136d6
52 changed files with 2212 additions and 1556 deletions
|
|
@ -13,8 +13,9 @@
|
|||
#include "unit/tests.hpp"
|
||||
|
||||
TTS_CASE_TPL("Test dynamic matrix transposition-like operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
|
|
@ -27,14 +28,15 @@ TTS_CASE_TPL("Test dynamic matrix transposition-like operations",
|
|||
};
|
||||
|
||||
TTS_CASE_TPL("Test static matrix transposition-like operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc) {
|
||||
rotgen::matrix<T, D::rows, D::cols, O::value> input;
|
||||
rotgen::tests::prepare(input.rows(), input.cols(), desc.init_fn, input);
|
||||
rotgen::tests::prepare(rows(input), cols(input), desc.init_fn, input);
|
||||
rotgen::tests::check_shape_functions(input);
|
||||
};
|
||||
|
||||
|
|
@ -42,8 +44,9 @@ TTS_CASE_TPL("Test static matrix transposition-like operations",
|
|||
};
|
||||
|
||||
TTS_CASE_TPL("Test dynamic matrix reduction-like operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
|
|
@ -56,21 +59,23 @@ TTS_CASE_TPL("Test dynamic matrix reduction-like operations",
|
|||
};
|
||||
|
||||
TTS_CASE_TPL("Test static matrix reduction-like operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc) {
|
||||
rotgen::matrix<T, D::rows, D::cols, O::value> input;
|
||||
rotgen::tests::prepare(input.rows(), input.cols(), desc.init_fn, input);
|
||||
rotgen::tests::prepare(rows(input), cols(input), desc.init_fn, input);
|
||||
rotgen::tests::check_reduction_functions(input);
|
||||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test dot product", float, double)<typename T>(tts::type<T>){
|
||||
TTS_CASE_TPL("Test dot product", float, double)
|
||||
<typename T>(tts::type<T>){
|
||||
{auto a = rotgen::setConstant<rotgen::matrix<T, 1, rotgen::Dynamic>>(1, 8, 2);
|
||||
auto b = rotgen::setConstant<rotgen::matrix<T, 1, rotgen::Dynamic>>(1, 8, 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
#include "unit/tests.hpp"
|
||||
|
||||
TTS_CASE_TPL("Function size", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Function size", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> empty_matrix;
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> matrix(3, 4);
|
||||
|
|
@ -25,87 +26,87 @@ TTS_CASE_TPL("Function size", rotgen::tests::types)<typename T, typename O>(
|
|||
TTS_EQUAL(column_vector.size(), rotgen::Index{5});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Resizing dynamic matrix",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Resizing dynamic matrix", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a(2, 3);
|
||||
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = 42 + 2 * c + r;
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) a(r, c) = 42 + 2 * c + r;
|
||||
|
||||
rotgen::resize(a, 3, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(3));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(3));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(2));
|
||||
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) TTS_GREATER(a(r, c), 0);
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) TTS_GREATER(a(r, c), 0);
|
||||
|
||||
rotgen::resize(a, 2, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(2));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(2));
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Dynamix matrix conservative resizing",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Dynamix matrix conservative resizing", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a(2, 3);
|
||||
|
||||
int i = 1;
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = i++;
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) a(r, c) = i++;
|
||||
|
||||
rotgen::conservativeResize(a, 2, 3);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(3));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(2));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(3));
|
||||
|
||||
i = 1;
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) TTS_EQUAL(a(r, c), i++);
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) TTS_EQUAL(a(r, c), i++);
|
||||
|
||||
rotgen::conservativeResize(a, 3, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(3));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(3));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(2));
|
||||
int expected[3][2] = {{1, 2}, {4, 5}};
|
||||
for (rotgen::Index r = 0; r < 2; ++r)
|
||||
for (rotgen::Index c = 0; c < 2; ++c) TTS_EQUAL(a(r, c), expected[r][c]);
|
||||
|
||||
rotgen::conservativeResize(a, 4, 4);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(4));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(4));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(4));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(4));
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(3, 3), 0);
|
||||
|
||||
rotgen::conservativeResize(a, 2, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(2));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(2));
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(1, 1), 5);
|
||||
|
||||
rotgen::conservativeResize(a, 1, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(1));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(1));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(2));
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(0, 1), 2);
|
||||
|
||||
rotgen::conservativeResize(a, 0, 0);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(0));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(0));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(0));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(0));
|
||||
|
||||
rotgen::conservativeResize(a, 3, 3);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(3));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(3));
|
||||
TTS_EQUAL(rows(a), rotgen::Index(3));
|
||||
TTS_EQUAL(cols(a), rotgen::Index(3));
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test coefficient accessors",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test coefficient accessors", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> a(3, 5);
|
||||
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = r + 2 * c + 3;
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) a(r, c) = r + 2 * c + 3;
|
||||
|
||||
TTS_EQUAL(a(0, 0), 3);
|
||||
TTS_EQUAL(a(1, 1), 6);
|
||||
|
|
@ -121,9 +122,9 @@ TTS_CASE_TPL("Test coefficient accessors",
|
|||
TTS_EQUAL(a(2, 2), 17);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test one index coefficient accessors",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test one index coefficient accessors", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto a = [&]() {
|
||||
if constexpr (O::value == rotgen::ColMajor)
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
#include "unit/common/references.hpp"
|
||||
#include "unit/tests.hpp"
|
||||
|
||||
TTS_CASE_TPL("Test dynamic matrix cwise operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test dynamic matrix cwise operations", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
|
|
@ -25,15 +25,15 @@ TTS_CASE_TPL("Test dynamic matrix cwise operations",
|
|||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static matrix cwise operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test static matrix cwise operations", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc) {
|
||||
rotgen::matrix<T, D::rows, D::cols, O::value> input;
|
||||
rotgen::tests::prepare(input.rows(), input.cols(), desc.init_fn, input);
|
||||
rotgen::tests::prepare(rows(input), cols(input), desc.init_fn, input);
|
||||
rotgen::tests::check_cwise_functions(input);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
#include "unit/common/references.hpp"
|
||||
#include "unit/tests.hpp"
|
||||
|
||||
TTS_CASE_TPL("Test dynamic matrix inverse",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test dynamic matrix inverse", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto eps = std::numeric_limits<T>::epsilon();
|
||||
|
|
@ -23,7 +23,7 @@ TTS_CASE_TPL("Test dynamic matrix inverse",
|
|||
auto inv = rotgen::inverse(input);
|
||||
|
||||
auto rec = input * inv;
|
||||
auto id = mat_t::Identity(rotgen::rows(rec), rotgen::cols(rec));
|
||||
auto id = rotgen::setIdentity<mat_t>(rotgen::rows(rec), rotgen::cols(rec));
|
||||
auto error = rec - id;
|
||||
|
||||
TTS_LESS_EQUAL(rotgen::maxCoeff(rotgen::abs(error)) / eps, 256.)
|
||||
|
|
@ -43,7 +43,7 @@ template<typename T, typename O, int N> void check_static_inverse()
|
|||
auto inv = rotgen::inverse(input);
|
||||
|
||||
auto rec = input * inv;
|
||||
auto id = mat_t::Identity(rotgen::rows(rec), rotgen::cols(rec));
|
||||
auto id = rotgen::setIdentity<mat_t>(rotgen::rows(rec), rotgen::cols(rec));
|
||||
auto error = rec - id;
|
||||
|
||||
TTS_LESS_EQUAL(rotgen::maxCoeff(rotgen::abs(error)) / eps, 256.)
|
||||
|
|
@ -53,9 +53,9 @@ template<typename T, typename O, int N> void check_static_inverse()
|
|||
<< error << "\n";
|
||||
}
|
||||
|
||||
TTS_CASE_TPL("Test static matrix inverse",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test static matrix inverse", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
check_static_inverse<T, O, 2>();
|
||||
check_static_inverse<T, O, 3>();
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
#include "unit/common/references.hpp"
|
||||
#include "unit/tests.hpp"
|
||||
|
||||
TTS_CASE_TPL("Test dynamic matrix norm operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test dynamic matrix norm operations", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
|
|
@ -25,15 +25,15 @@ TTS_CASE_TPL("Test dynamic matrix norm operations",
|
|||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static matrix norm operations",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Test static matrix norm operations", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc) {
|
||||
rotgen::matrix<T, D::rows, D::cols, O::value> input;
|
||||
rotgen::tests::prepare(input.rows(), input.cols(), desc.init_fn, input);
|
||||
rotgen::tests::prepare(rows(input), cols(input), desc.init_fn, input);
|
||||
rotgen::tests::check_norms_functions(input);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@
|
|||
#include "unit/tests.hpp"
|
||||
|
||||
template<typename MatrixType>
|
||||
void test_matrix_operations(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
void test_matrix_operations(rotgen::Index rr,
|
||||
rotgen::Index cc,
|
||||
auto a_init_fn,
|
||||
auto b_init_fn,
|
||||
auto ops,
|
||||
auto self_ops)
|
||||
{
|
||||
MatrixType a(rows, cols);
|
||||
MatrixType b(rows, cols);
|
||||
MatrixType ref(rows, cols);
|
||||
MatrixType a(rr, cc);
|
||||
MatrixType b(rr, cc);
|
||||
MatrixType ref(rr, cc);
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index r = 0; r < rr; ++r)
|
||||
{
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
for (rotgen::Index c = 0; c < cc; ++c)
|
||||
{
|
||||
a(r, c) = a_init_fn(r, c);
|
||||
b(r, c) = b_init_fn(r, c);
|
||||
|
|
@ -40,19 +40,19 @@ void test_matrix_operations(rotgen::Index rows,
|
|||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void test_scalar_operations(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
void test_scalar_operations(rotgen::Index rr,
|
||||
rotgen::Index cc,
|
||||
auto a_init_fn,
|
||||
auto s,
|
||||
auto ops,
|
||||
auto self_ops)
|
||||
{
|
||||
MatrixType a(rows, cols);
|
||||
MatrixType ref(rows, cols);
|
||||
MatrixType a(rr, cc);
|
||||
MatrixType ref(rr, cc);
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index r = 0; r < rr; ++r)
|
||||
{
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
for (rotgen::Index c = 0; c < cc; ++c)
|
||||
{
|
||||
a(r, c) = a_init_fn(r, c);
|
||||
ref(r, c) = ops(a(r, c), s);
|
||||
|
|
@ -68,17 +68,17 @@ void test_scalar_operations(rotgen::Index rows,
|
|||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void test_scalar_multiplications(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
void test_scalar_multiplications(rotgen::Index rr,
|
||||
rotgen::Index cc,
|
||||
auto fn,
|
||||
auto s)
|
||||
{
|
||||
MatrixType a(rows, cols);
|
||||
MatrixType ref(rows, cols);
|
||||
MatrixType a(rr, cc);
|
||||
MatrixType ref(rr, cc);
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index r = 0; r < rr; ++r)
|
||||
{
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
for (rotgen::Index c = 0; c < cc; ++c)
|
||||
{
|
||||
a(r, c) = fn(r, c);
|
||||
ref(r, c) = a(r, c) * s;
|
||||
|
|
@ -96,27 +96,27 @@ void test_scalar_multiplications(rotgen::Index rows,
|
|||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void test_matrix_multiplication(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
void test_matrix_multiplication(rotgen::Index rr,
|
||||
rotgen::Index cc,
|
||||
auto a_init_fn,
|
||||
auto b_init_fn)
|
||||
{
|
||||
MatrixType a(rows, cols);
|
||||
MatrixType b(cols, rows);
|
||||
MatrixType ref(rows, rows);
|
||||
MatrixType a(rr, cc);
|
||||
MatrixType b(cc, rr);
|
||||
MatrixType ref(rr, rr);
|
||||
|
||||
for (rotgen::Index r = 0; r < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = a_init_fn(r, c);
|
||||
for (rotgen::Index r = 0; r < rows(a); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(a); ++c) a(r, c) = a_init_fn(r, c);
|
||||
|
||||
for (rotgen::Index r = 0; r < b.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < b.cols(); ++c) b(r, c) = b_init_fn(r, c);
|
||||
for (rotgen::Index r = 0; r < rows(b); ++r)
|
||||
for (rotgen::Index c = 0; c < cols(b); ++c) b(r, c) = b_init_fn(r, c);
|
||||
|
||||
for (rotgen::Index i = 0; i < a.rows(); ++i)
|
||||
for (rotgen::Index i = 0; i < rows(a); ++i)
|
||||
{
|
||||
for (rotgen::Index j = 0; j < b.cols(); ++j)
|
||||
for (rotgen::Index j = 0; j < cols(b); ++j)
|
||||
{
|
||||
ref(i, j) = 0;
|
||||
for (rotgen::Index k = 0; k < a.cols(); ++k)
|
||||
for (rotgen::Index k = 0; k < cols(a); ++k)
|
||||
ref(i, j) += a(i, k) * b(k, j);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,9 +134,9 @@ inline constexpr auto init_b = [](auto r, auto c) {
|
|||
};
|
||||
inline constexpr auto init_0 = [](auto, auto) { return 0; };
|
||||
|
||||
TTS_CASE_TPL("Check matrix addition",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check matrix addition", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a + b; };
|
||||
|
|
@ -153,9 +153,9 @@ TTS_CASE_TPL("Check matrix addition",
|
|||
test_matrix_operations<mat_t>(5, 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check matrix substraction",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check matrix substraction", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a - b; };
|
||||
|
|
@ -172,9 +172,9 @@ TTS_CASE_TPL("Check matrix substraction",
|
|||
test_matrix_operations<mat_t>(5, 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check matrix multiplications",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check matrix multiplications", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto init_id = [](auto r, auto c) { return r == c ? 1 : 0; };
|
||||
|
|
@ -193,9 +193,9 @@ TTS_CASE_TPL("Check matrix multiplications",
|
|||
test_matrix_multiplication<mat_t>(5, 5, init_a, init_0);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check matrix multiplication with scalar",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check matrix multiplication with scalar", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
|
||||
|
|
@ -209,9 +209,9 @@ TTS_CASE_TPL("Check matrix multiplication with scalar",
|
|||
test_scalar_multiplications<mat_t>(1, 10, init_a, T{-0.5});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check matrix division with scalar",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check matrix division with scalar", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a / b; };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue