Adding clang-format configuration file and formatting all source files
Co-authored-by: Jules Pénuchot <jules@penuchot.com> Co-authored-by: Joel FALCOU <jfalcou@codereckons.com> See merge request oss/rotgen!41
This commit is contained in:
parent
e92e824a18
commit
648dd768ee
94 changed files with 6778 additions and 4722 deletions
|
|
@ -8,134 +8,141 @@
|
|||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
void test_value(const auto& matrix, std::size_t rows, std::size_t cols, auto constant)
|
||||
void test_value(auto const& matrix,
|
||||
std::size_t rows,
|
||||
std::size_t cols,
|
||||
auto constant)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
TTS_EQUAL(matrix(r, c), constant);
|
||||
for (std::size_t r = 0; r < rows; ++r)
|
||||
for (std::size_t c = 0; c < cols; ++c) TTS_EQUAL(matrix(r, c), constant);
|
||||
}
|
||||
|
||||
void test_random(const auto& matrix, std::size_t rows, std::size_t cols)
|
||||
void test_random(auto const& matrix, std::size_t rows, std::size_t cols)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
for (std::size_t r = 0; r < rows; ++r)
|
||||
for (std::size_t c = 0; c < cols; ++c)
|
||||
{
|
||||
TTS_GREATER_EQUAL(matrix(r, c), -1.0);
|
||||
TTS_LESS_EQUAL(matrix(r, c), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void test_identity(const auto& matrix, std::size_t rows, std::size_t cols)
|
||||
void test_identity(auto const& matrix, std::size_t rows, std::size_t cols)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
TTS_EQUAL(matrix(r, c), r==c ? 1 : 0);
|
||||
for (std::size_t r = 0; r < rows; ++r)
|
||||
for (std::size_t c = 0; c < cols; ++c)
|
||||
TTS_EQUAL(matrix(r, c), r == c ? 1 : 0);
|
||||
}
|
||||
|
||||
TTS_CASE_TPL("Test zero", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test zero", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using namespace rotgen;
|
||||
test_value(setZero<matrix<T, 3, 4, O::value> >(), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 1, 1, O::value> >(), 1, 1, 0);
|
||||
test_value(setZero<matrix<T, 10, 10, O::value> >(), 10, 10, 0);
|
||||
test_value(setZero<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 7, 5, O::value> >(7, 5), 7, 5, 0);
|
||||
test_value(setZero<matrix<T, 9,Dynamic> >(9, 3), 9, 3, 0);
|
||||
test_value(setZero<matrix<T,Dynamic, 3> >(2, 3), 2, 3, 0);
|
||||
test_value(setZero<matrix<T, 3, 4, O::value>>(), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 1, 1, O::value>>(), 1, 1, 0);
|
||||
test_value(setZero<matrix<T, 10, 10, O::value>>(), 10, 10, 0);
|
||||
test_value(setZero<matrix<T, Dynamic, Dynamic, O::value>>(3, 4), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 7, 5, O::value>>(7, 5), 7, 5, 0);
|
||||
test_value(setZero<matrix<T, 9, Dynamic>>(9, 3), 9, 3, 0);
|
||||
test_value(setZero<matrix<T, Dynamic, 3>>(2, 3), 2, 3, 0);
|
||||
|
||||
test_value(setZero(matrix<T, 3, 4, O::value>{} ), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 1, 1, O::value>{} ), 1, 1, 0);
|
||||
test_value(setZero(matrix<T, 10, 10, O::value>{} ), 10, 10, 0);
|
||||
test_value(setZero(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 7, 5, O::value>{} ), 7, 5, 0);
|
||||
test_value(setZero(matrix<T, 9,Dynamic>{9, 3} ), 9, 3, 0);
|
||||
test_value(setZero(matrix<T,Dynamic, 3>{2, 3} ), 2, 3, 0);
|
||||
test_value(setZero(matrix<T, 3, 4, O::value>{}), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 1, 1, O::value>{}), 1, 1, 0);
|
||||
test_value(setZero(matrix<T, 10, 10, O::value>{}), 10, 10, 0);
|
||||
test_value(setZero(matrix<T, Dynamic, Dynamic, O::value>{3, 4}), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 7, 5, O::value>{}), 7, 5, 0);
|
||||
test_value(setZero(matrix<T, 9, Dynamic>{9, 3}), 9, 3, 0);
|
||||
test_value(setZero(matrix<T, Dynamic, 3>{2, 3}), 2, 3, 0);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test ones", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test ones", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using namespace rotgen;
|
||||
test_value(setOnes<matrix<T, 3, 4, O::value> >(), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 1, 1, O::value> >(), 1, 1, 1);
|
||||
test_value(setOnes<matrix<T, 10, 10, O::value> >(), 10, 10, 1);
|
||||
test_value(setOnes<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 7, 5, O::value> >(7, 5), 7, 5, 1);
|
||||
test_value(setOnes<matrix<T, 9,Dynamic> >(9, 3), 9, 3, 1);
|
||||
test_value(setOnes<matrix<T,Dynamic, 3> >(2, 3), 2, 3, 1);
|
||||
test_value(setOnes<matrix<T, 3, 4, O::value>>(), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 1, 1, O::value>>(), 1, 1, 1);
|
||||
test_value(setOnes<matrix<T, 10, 10, O::value>>(), 10, 10, 1);
|
||||
test_value(setOnes<matrix<T, Dynamic, Dynamic, O::value>>(3, 4), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 7, 5, O::value>>(7, 5), 7, 5, 1);
|
||||
test_value(setOnes<matrix<T, 9, Dynamic>>(9, 3), 9, 3, 1);
|
||||
test_value(setOnes<matrix<T, Dynamic, 3>>(2, 3), 2, 3, 1);
|
||||
|
||||
test_value(setOnes(matrix<T, 3, 4, O::value>{} ), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 1, 1, O::value>{} ), 1, 1, 1);
|
||||
test_value(setOnes(matrix<T, 10, 10, O::value>{} ), 10, 10, 1);
|
||||
test_value(setOnes(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 7, 5, O::value>{} ), 7, 5, 1);
|
||||
test_value(setOnes(matrix<T, 9,Dynamic>{9, 3} ), 9, 3, 1);
|
||||
test_value(setOnes(matrix<T,Dynamic, 3>{2, 3} ), 2, 3, 1);
|
||||
test_value(setOnes(matrix<T, 3, 4, O::value>{}), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 1, 1, O::value>{}), 1, 1, 1);
|
||||
test_value(setOnes(matrix<T, 10, 10, O::value>{}), 10, 10, 1);
|
||||
test_value(setOnes(matrix<T, Dynamic, Dynamic, O::value>{3, 4}), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 7, 5, O::value>{}), 7, 5, 1);
|
||||
test_value(setOnes(matrix<T, 9, Dynamic>{9, 3}), 9, 3, 1);
|
||||
test_value(setOnes(matrix<T, Dynamic, 3>{2, 3}), 2, 3, 1);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test constant", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test constant", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using namespace rotgen;
|
||||
test_value(setConstant<matrix<T, 3, 4, O::value> >(T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 1, 1, O::value> >(T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant<matrix<T, 10, 10, O::value> >(T(5.12)), 10, 10, T(5.12));
|
||||
test_value(setConstant<matrix<T,Dynamic,Dynamic, O::value>>(3, 4, T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 7, 5, O::value> >(7, 5, T(5.12)), 7, 5, T(5.12));
|
||||
test_value(setConstant<matrix<T, 9,Dynamic> >(9, 3, T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant<matrix<T,Dynamic, 3> >(2, 3, T(5.12)), 2, 3, T(5.12));
|
||||
test_value(setConstant<matrix<T, 3, 4, O::value>>(T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 1, 1, O::value>>(T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant<matrix<T, 10, 10, O::value>>(T(5.12)), 10, 10,
|
||||
T(5.12));
|
||||
test_value(setConstant<matrix<T, Dynamic, Dynamic, O::value>>(3, 4, T(5.12)),
|
||||
3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 7, 5, O::value>>(7, 5, T(5.12)), 7, 5,
|
||||
T(5.12));
|
||||
test_value(setConstant<matrix<T, 9, Dynamic>>(9, 3, T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant<matrix<T, Dynamic, 3>>(2, 3, T(5.12)), 2, 3, T(5.12));
|
||||
|
||||
test_value(setConstant(matrix<T, 3, 4, O::value>{} , T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 1, 1, O::value>{} , T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant(matrix<T, 10, 10, O::value>{} , T(5.12)), 10, 10, T(5.12));
|
||||
test_value(setConstant(matrix<T,Dynamic,Dynamic, O::value>{3, 4}, T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 7, 5, O::value>{} , T(5.12)), 7, 5, T(5.12));
|
||||
test_value(setConstant(matrix<T, 9,Dynamic>{9, 3} , T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant(matrix<T,Dynamic, 3>{2, 3} , T(5.12)), 2, 3, T(5.12));
|
||||
test_value(setConstant(matrix<T, 3, 4, O::value>{}, T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 1, 1, O::value>{}, T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant(matrix<T, 10, 10, O::value>{}, T(5.12)), 10, 10,
|
||||
T(5.12));
|
||||
test_value(setConstant(matrix<T, Dynamic, Dynamic, O::value>{3, 4}, T(5.12)),
|
||||
3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 7, 5, O::value>{}, T(5.12)), 7, 5, T(5.12));
|
||||
test_value(setConstant(matrix<T, 9, Dynamic>{9, 3}, T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant(matrix<T, Dynamic, 3>{2, 3}, T(5.12)), 2, 3, T(5.12));
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test random", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test random", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using namespace rotgen;
|
||||
test_random(setRandom<matrix<T, 3, 4, O::value> >(), 3, 4);
|
||||
test_random(setRandom<matrix<T, 1, 1, O::value> >(), 1, 1);
|
||||
test_random(setRandom<matrix<T, 10, 10, O::value> >(), 10, 10);
|
||||
test_random(setRandom<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_random(setRandom<matrix<T, 7, 5, O::value> >(7, 5), 7, 5);
|
||||
test_random(setRandom<matrix<T, 9,Dynamic> >(9, 3), 9, 3);
|
||||
test_random(setRandom<matrix<T,Dynamic, 3> >(2, 3), 2, 3);
|
||||
test_random(setRandom<matrix<T, 3, 4, O::value>>(), 3, 4);
|
||||
test_random(setRandom<matrix<T, 1, 1, O::value>>(), 1, 1);
|
||||
test_random(setRandom<matrix<T, 10, 10, O::value>>(), 10, 10);
|
||||
test_random(setRandom<matrix<T, Dynamic, Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_random(setRandom<matrix<T, 7, 5, O::value>>(7, 5), 7, 5);
|
||||
test_random(setRandom<matrix<T, 9, Dynamic>>(9, 3), 9, 3);
|
||||
test_random(setRandom<matrix<T, Dynamic, 3>>(2, 3), 2, 3);
|
||||
|
||||
test_random(setRandom(matrix<T, 3, 4, O::value>{} ), 3, 4);
|
||||
test_random(setRandom(matrix<T, 1, 1, O::value>{} ), 1, 1);
|
||||
test_random(setRandom(matrix<T, 10, 10, O::value>{} ), 10, 10);
|
||||
test_random(setRandom(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_random(setRandom(matrix<T, 7, 5, O::value>{} ), 7, 5);
|
||||
test_random(setRandom(matrix<T, 9,Dynamic>{9, 3} ), 9, 3);
|
||||
test_random(setRandom(matrix<T,Dynamic, 3>{2, 3} ), 2, 3);
|
||||
test_random(setRandom(matrix<T, 3, 4, O::value>{}), 3, 4);
|
||||
test_random(setRandom(matrix<T, 1, 1, O::value>{}), 1, 1);
|
||||
test_random(setRandom(matrix<T, 10, 10, O::value>{}), 10, 10);
|
||||
test_random(setRandom(matrix<T, Dynamic, Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_random(setRandom(matrix<T, 7, 5, O::value>{}), 7, 5);
|
||||
test_random(setRandom(matrix<T, 9, Dynamic>{9, 3}), 9, 3);
|
||||
test_random(setRandom(matrix<T, Dynamic, 3>{2, 3}), 2, 3);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test identity", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test identity", rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using namespace rotgen;
|
||||
test_identity(setIdentity<matrix<T, 3, 4, O::value> >(), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 1, 1, O::value> >(), 1, 1);
|
||||
test_identity(setIdentity<matrix<T, 10, 10, O::value> >(), 10, 10);
|
||||
test_identity(setIdentity<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 7, 5, O::value> >(7, 5), 7, 5);
|
||||
test_identity(setIdentity<matrix<T, 9,Dynamic> >(9, 3), 9, 3);
|
||||
test_identity(setIdentity<matrix<T,Dynamic, 3> >(2, 3), 2, 3);
|
||||
test_identity(setIdentity<matrix<T, 3, 4, O::value>>(), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 1, 1, O::value>>(), 1, 1);
|
||||
test_identity(setIdentity<matrix<T, 10, 10, O::value>>(), 10, 10);
|
||||
test_identity(setIdentity<matrix<T, Dynamic, Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 7, 5, O::value>>(7, 5), 7, 5);
|
||||
test_identity(setIdentity<matrix<T, 9, Dynamic>>(9, 3), 9, 3);
|
||||
test_identity(setIdentity<matrix<T, Dynamic, 3>>(2, 3), 2, 3);
|
||||
|
||||
test_identity(setIdentity(matrix<T, 3, 4, O::value>{} ), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 1, 1, O::value>{} ), 1, 1);
|
||||
test_identity(setIdentity(matrix<T, 10, 10, O::value>{} ), 10, 10);
|
||||
test_identity(setIdentity(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 7, 5, O::value>{} ), 7, 5);
|
||||
test_identity(setIdentity(matrix<T, 9,Dynamic>{9, 3} ), 9, 3);
|
||||
test_identity(setIdentity(matrix<T,Dynamic, 3>{2, 3} ), 2, 3);
|
||||
};
|
||||
test_identity(setIdentity(matrix<T, 3, 4, O::value>{}), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 1, 1, O::value>{}), 1, 1);
|
||||
test_identity(setIdentity(matrix<T, 10, 10, O::value>{}), 10, 10);
|
||||
test_identity(setIdentity(matrix<T, Dynamic, Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 7, 5, O::value>{}), 7, 5);
|
||||
test_identity(setIdentity(matrix<T, 9, Dynamic>{9, 3}), 9, 3);
|
||||
test_identity(setIdentity(matrix<T, Dynamic, 3>{2, 3}), 2, 3);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue