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:
Jules Pénuchot 2025-10-14 16:19:03 +02:00
parent e92e824a18
commit 648dd768ee
94 changed files with 6778 additions and 4722 deletions

View file

@ -8,88 +8,90 @@
#include "unit/tests.hpp"
#include <rotgen/rotgen.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>>)
{
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> dyn_map(data,1,12);
rotgen::map<rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>>
dyn_map(data, 1, 12);
TTS_EQUAL(dyn_map.rows(), rotgen::Index{1});
TTS_EQUAL(dyn_map.cols(), rotgen::Index{12});
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor>> s112_map(data);
rotgen::map<rotgen::matrix<T, 1, 12, rotgen::RowMajor>> s112_map(data);
TTS_EQUAL(s112_map.rows(), rotgen::Index{1});
TTS_EQUAL(s112_map.cols(), rotgen::Index{12});
TTS_EQUAL(s112_map.size(), rotgen::Index{12});
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor>> s121_map(data);
rotgen::map<rotgen::matrix<T, 12, 1, rotgen::ColMajor>> s121_map(data);
TTS_EQUAL(s121_map.rows(), rotgen::Index{12});
TTS_EQUAL(s121_map.cols(), rotgen::Index{1});
TTS_EQUAL(s121_map.size(), rotgen::Index{12});
rotgen::map<rotgen::matrix<T,3,4,O::value>> s34_map(data);
rotgen::map<rotgen::matrix<T, 3, 4, O::value>> s34_map(data);
TTS_EQUAL(s34_map.rows(), rotgen::Index{3});
TTS_EQUAL(s34_map.cols(), rotgen::Index{4});
TTS_EQUAL(s34_map.size(), rotgen::Index{12});
rotgen::map<rotgen::matrix<T,6,2,O::value>> s62_map(data);
rotgen::map<rotgen::matrix<T, 6, 2, O::value>> s62_map(data);
TTS_EQUAL(s62_map.rows(), rotgen::Index{6});
TTS_EQUAL(s62_map.cols(), rotgen::Index{2});
TTS_EQUAL(s62_map.size(), rotgen::Index{12});
};
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>>)
{
using base = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
using base = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
rotgen::map<base> a(data,4,3);
for(rotgen::Index i=0;i<4;i++)
rotgen::map<base> a(data, 4, 3);
for (rotgen::Index i = 0; i < 4; i++)
{
for(rotgen::Index j=0;j<3;j++)
for (rotgen::Index j = 0; j < 3; j++)
{
if constexpr(O::value) TTS_EQUAL(a(i,j), data[j+3*i]);
else TTS_EQUAL(a(i,j), data[i+4*j]);
if constexpr (O::value) TTS_EQUAL(a(i, j), data[j + 3 * i]);
else TTS_EQUAL(a(i, j), data[i + 4 * j]);
}
}
a(1, 1) = 42;
TTS_EQUAL(a(1,1), 42);
TTS_EQUAL(a(1, 1), 42);
T& ref = a(2, 2);
ref = 17;
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>>)
{
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
auto m = [&]()
{
if constexpr(O::value == rotgen::ColMajor)
auto m = [&]() {
if constexpr (O::value == rotgen::ColMajor)
{
using base = rotgen::matrix<T,1,rotgen::Dynamic>;
rotgen::map<base> a(data,12);
using base = rotgen::matrix<T, 1, rotgen::Dynamic>;
rotgen::map<base> a(data, 12);
return a;
}
else
{
using base = rotgen::matrix<T,rotgen::Dynamic,1>;
rotgen::map<base> a(data,12);
using base = rotgen::matrix<T, rotgen::Dynamic, 1>;
rotgen::map<base> a(data, 12);
return a;
}
}();
TTS_EXPECT(m.IsVectorAtCompileTime);
for(rotgen::Index i=0;i<m.size();i++)
for (rotgen::Index i = 0; i < m.size(); i++)
TTS_EQUAL(m(i), data[i]) << "Index: " << i << "\n";
for(rotgen::Index i=0;i<m.size();i++)
for (rotgen::Index i = 0; i < m.size(); i++)
TTS_EQUAL(m[i], data[i]) << "Index: " << i << "\n";
m(1) = 42;