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,261 +8,269 @@
#include "unit/tests.hpp"
#include <rotgen/rotgen.hpp>
void test_value ( const auto& matrix, auto value
, rotgen::Index i0, rotgen::Index j0
, rotgen::Index rows, rotgen::Index cols
)
void test_value(auto const& matrix,
auto value,
rotgen::Index i0,
rotgen::Index j0,
rotgen::Index rows,
rotgen::Index cols)
{
for(rotgen::Index r=0;r<rows;++r)
for(rotgen::Index c=0;c<cols;++c)
TTS_EQUAL(matrix(i0+r, j0+c), value);
for (rotgen::Index r = 0; r < rows; ++r)
for (rotgen::Index c = 0; c < cols; ++c)
TTS_EQUAL(matrix(i0 + r, j0 + c), value);
}
void test_identity( const auto& matrix
, rotgen::Index i0, rotgen::Index j0
, rotgen::Index rows, rotgen::Index cols
)
void test_identity(auto const& matrix,
rotgen::Index i0,
rotgen::Index j0,
rotgen::Index rows,
rotgen::Index cols)
{
for(rotgen::Index r=0;r<rows;++r)
for(rotgen::Index c=0;c<cols;++c)
TTS_EQUAL(matrix(i0+r, j0+c), r==c ? 1 : 0);
for (rotgen::Index r = 0; r < rows; ++r)
for (rotgen::Index c = 0; c < cols; ++c)
TTS_EQUAL(matrix(i0 + r, j0 + c), r == c ? 1 : 0);
}
void test_random( const auto& matrix
, rotgen::Index i0, rotgen::Index j0
, rotgen::Index rows, rotgen::Index cols
)
void test_random(auto const& matrix,
rotgen::Index i0,
rotgen::Index j0,
rotgen::Index rows,
rotgen::Index cols)
{
for(rotgen::Index r=0;r<rows;++r)
for(rotgen::Index c=0;c<cols;++c)
for (rotgen::Index r = 0; r < rows; ++r)
for (rotgen::Index c = 0; c < cols; ++c)
{
TTS_GREATER_EQUAL(matrix(i0+r, j0+c), -1.0);
TTS_LESS_EQUAL(matrix(i0+r, j0+c), 1.0);
TTS_GREATER_EQUAL(matrix(i0 + r, j0 + c), -1.0);
TTS_LESS_EQUAL(matrix(i0 + r, j0 + c), 1.0);
}
}
TTS_CASE_TPL("Test dynamic block::setZero", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>>)
TTS_CASE_TPL("Test dynamic block::setZero",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_block_references<T,O>();
for (const auto& [matrix_desc, i0, j0, ni, nj] : cases)
auto const cases = rotgen::tests::generate_block_references<T, O>();
for (auto const& [matrix_desc, i0, j0, ni, nj] : cases)
{
auto[rows,cols,fn] = matrix_desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto [rows, cols, fn] = matrix_desc;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract(m, i0, j0, ni, nj);
input.setZero();
test_value(m,T{0},i0,j0,ni,nj);
test_value(m, T{0}, i0, j0, ni, nj);
using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj));
auto values = input_type::Zero(ni,nj);
test_value(values,T{0},0,0,ni,nj);
auto values = input_type::Zero(ni, nj);
test_value(values, T{0}, 0, 0, ni, nj);
}
};
TTS_CASE_TPL("Test static block:setZero", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
TTS_CASE_TPL("Test static block:setZero",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_block_references<T,O>();
auto const cases = rotgen::tests::generate_static_block_references<T, O>();
auto process = []<typename D>(D const& d)
{
auto[desc,i0,j0] = d;
auto[rows,cols,fn] = desc;
auto process = []<typename D>(D const& d) {
auto [desc, i0, j0] = d;
auto [rows, cols, fn] = desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto input = rotgen::extract<D::ni,D::nj>(m, i0, j0);
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract<D::ni, D::nj>(m, i0, j0);
input.setZero();
test_value(m,T{0},i0,j0,D::ni,D::nj);
test_value(m, T{0}, i0, j0, D::ni, D::nj);
using input_type = decltype(rotgen::extract<D::ni,D::nj>(m, i0, j0));
using input_type = decltype(rotgen::extract<D::ni, D::nj>(m, i0, j0));
auto values = input_type::Zero();
test_value(values,T{0},0,0,D::ni,D::nj);
test_value(values, T{0}, 0, 0, D::ni, D::nj);
};
std::apply([&](auto const&... d) { (process(d),...);}, cases);
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};
TTS_CASE_TPL("Test dynamic block::setOnes", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>>)
TTS_CASE_TPL("Test dynamic block::setOnes",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_block_references<T,O>();
for (const auto& [matrix_desc, i0, j0, ni, nj] : cases)
auto const cases = rotgen::tests::generate_block_references<T, O>();
for (auto const& [matrix_desc, i0, j0, ni, nj] : cases)
{
auto[rows,cols,fn] = matrix_desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto [rows, cols, fn] = matrix_desc;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract(m, i0, j0, ni, nj);
input.setOnes();
test_value(m,T{1},i0,j0,ni,nj);
test_value(m, T{1}, i0, j0, ni, nj);
using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj));
auto values = input_type::Ones(ni,nj);
test_value(values,T{1},0,0,ni,nj);
auto values = input_type::Ones(ni, nj);
test_value(values, T{1}, 0, 0, ni, nj);
}
};
TTS_CASE_TPL("Test static block:setOnes", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
TTS_CASE_TPL("Test static block:setOnes",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_block_references<T,O>();
auto const cases = rotgen::tests::generate_static_block_references<T, O>();
auto process = []<typename D>(D const& d)
{
auto[desc,i0,j0] = d;
auto[rows,cols,fn] = desc;
auto process = []<typename D>(D const& d) {
auto [desc, i0, j0] = d;
auto [rows, cols, fn] = desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto input = rotgen::extract<D::ni,D::nj>(m, i0, j0);
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract<D::ni, D::nj>(m, i0, j0);
input.setOnes();
test_value(m,T{1},i0,j0,D::ni,D::nj);
test_value(m, T{1}, i0, j0, D::ni, D::nj);
using input_type = decltype(rotgen::extract<D::ni,D::nj>(m, i0, j0));
using input_type = decltype(rotgen::extract<D::ni, D::nj>(m, i0, j0));
auto values = input_type::Ones();
test_value(values,T{1},0,0,D::ni,D::nj);
test_value(values, T{1}, 0, 0, D::ni, D::nj);
};
std::apply([&](auto const&... d) { (process(d),...);}, cases);
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};
TTS_CASE_TPL("Test dynamic block::setConstant", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>>)
TTS_CASE_TPL("Test dynamic block::setConstant",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_block_references<T,O>();
for (const auto& [matrix_desc, i0, j0, ni, nj] : cases)
auto const cases = rotgen::tests::generate_block_references<T, O>();
for (auto const& [matrix_desc, i0, j0, ni, nj] : cases)
{
auto[rows,cols,fn] = matrix_desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto [rows, cols, fn] = matrix_desc;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract(m, i0, j0, ni, nj);
input.setConstant(T{13.37f});
test_value(m,T{13.37f},i0,j0,ni,nj);
test_value(m, T{13.37f}, i0, j0, ni, nj);
using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj));
auto values = input_type::Constant(ni,nj,T{13.37f});
test_value(values,T{13.37f},0,0,ni,nj);
auto values = input_type::Constant(ni, nj, T{13.37f});
test_value(values, T{13.37f}, 0, 0, ni, nj);
}
};
TTS_CASE_TPL("Test static block:setConstant", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
TTS_CASE_TPL("Test static block:setConstant",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_block_references<T,O>();
auto const cases = rotgen::tests::generate_static_block_references<T, O>();
auto process = []<typename D>(D const& d)
{
auto[desc,i0,j0] = d;
auto[rows,cols,fn] = desc;
auto process = []<typename D>(D const& d) {
auto [desc, i0, j0] = d;
auto [rows, cols, fn] = desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto input = rotgen::extract<D::ni,D::nj>(m, i0, j0);
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract<D::ni, D::nj>(m, i0, j0);
input.setConstant(T{13.37f});
test_value(m,T{13.37f},i0,j0,D::ni,D::nj);
test_value(m, T{13.37f}, i0, j0, D::ni, D::nj);
using input_type = decltype(rotgen::extract<D::ni,D::nj>(m, i0, j0));
using input_type = decltype(rotgen::extract<D::ni, D::nj>(m, i0, j0));
auto values = input_type::Constant(T{13.37f});
test_value(values,T{13.37f},0,0,D::ni,D::nj);
test_value(values, T{13.37f}, 0, 0, D::ni, D::nj);
};
std::apply([&](auto const&... d) { (process(d),...);}, cases);
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};
TTS_CASE_TPL("Test dynamic block::setIdentity", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>>)
TTS_CASE_TPL("Test dynamic block::setIdentity",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_block_references<T,O>();
for (const auto& [matrix_desc, i0, j0, ni, nj] : cases)
auto const cases = rotgen::tests::generate_block_references<T, O>();
for (auto const& [matrix_desc, i0, j0, ni, nj] : cases)
{
auto[rows,cols,fn] = matrix_desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto [rows, cols, fn] = matrix_desc;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract(m, i0, j0, ni, nj);
input.setIdentity();
test_identity(m,i0,j0,ni,nj);
test_identity(m, i0, j0, ni, nj);
using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj));
auto values = input_type::Identity(ni,nj);
test_identity(values,0,0,ni,nj);
auto values = input_type::Identity(ni, nj);
test_identity(values, 0, 0, ni, nj);
}
};
TTS_CASE_TPL("Test static block:setIdentity", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
TTS_CASE_TPL("Test static block:setIdentity",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_block_references<T,O>();
auto const cases = rotgen::tests::generate_static_block_references<T, O>();
auto process = []<typename D>(D const& d)
{
auto[desc,i0,j0] = d;
auto[rows,cols,fn] = desc;
auto process = []<typename D>(D const& d) {
auto [desc, i0, j0] = d;
auto [rows, cols, fn] = desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto input = rotgen::extract<D::ni,D::nj>(m, i0, j0);
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract<D::ni, D::nj>(m, i0, j0);
input.setIdentity();
test_identity(m,i0,j0,D::ni,D::nj);
test_identity(m, i0, j0, D::ni, D::nj);
using input_type = decltype(rotgen::extract<D::ni,D::nj>(m, i0, j0));
using input_type = decltype(rotgen::extract<D::ni, D::nj>(m, i0, j0));
auto values = input_type::Identity();
test_identity(values,0,0,D::ni,D::nj);
test_identity(values, 0, 0, D::ni, D::nj);
};
std::apply([&](auto const&... d) { (process(d),...);}, cases);
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};
TTS_CASE_TPL("Test dynamic block::setRandom", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>>)
TTS_CASE_TPL("Test dynamic block::setRandom",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_block_references<T,O>();
for (const auto& [matrix_desc, i0, j0, ni, nj] : cases)
auto const cases = rotgen::tests::generate_block_references<T, O>();
for (auto const& [matrix_desc, i0, j0, ni, nj] : cases)
{
auto[rows,cols,fn] = matrix_desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto [rows, cols, fn] = matrix_desc;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract(m, i0, j0, ni, nj);
input.setRandom();
test_random(m,i0,j0,ni,nj);
test_random(m, i0, j0, ni, nj);
using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj));
auto values = input_type::Random(ni,nj);
test_random(values,0,0,ni,nj);
auto values = input_type::Random(ni, nj);
test_random(values, 0, 0, ni, nj);
}
};
TTS_CASE_TPL("Test static block:setRandom", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
TTS_CASE_TPL("Test static block:setRandom",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
auto const cases = rotgen::tests::generate_static_block_references<T,O>();
auto const cases = rotgen::tests::generate_static_block_references<T, O>();
auto process = []<typename D>(D const& d)
{
auto[desc,i0,j0] = d;
auto[rows,cols,fn] = desc;
auto process = []<typename D>(D const& d) {
auto [desc, i0, j0] = d;
auto [rows, cols, fn] = desc;
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> m(rows, cols);
rotgen::tests::prepare(rows,cols,fn,m);
auto input = rotgen::extract<D::ni,D::nj>(m, i0, j0);
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> m(rows, cols);
rotgen::tests::prepare(rows, cols, fn, m);
auto input = rotgen::extract<D::ni, D::nj>(m, i0, j0);
input.setRandom();
test_random(m,i0,j0,D::ni,D::nj);
test_random(m, i0, j0, D::ni, D::nj);
using input_type = decltype(rotgen::extract<D::ni,D::nj>(m, i0, j0));
using input_type = decltype(rotgen::extract<D::ni, D::nj>(m, i0, j0));
auto values = input_type::Random();
test_random(values,0,0,D::ni,D::nj);
test_random(values, 0, 0, D::ni, D::nj);
};
std::apply([&](auto const&... d) { (process(d),...);}, cases);
};
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
};