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
|
|
@ -9,8 +9,13 @@
|
|||
#include <rotgen/rotgen.hpp>
|
||||
#include <vector>
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn, auto b_init_fn, auto ops, auto self_ops)
|
||||
template<typename MatrixType>
|
||||
void test_map_operations(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
auto a_init_fn,
|
||||
auto b_init_fn,
|
||||
auto ops,
|
||||
auto self_ops)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType b_data(rows, cols);
|
||||
|
|
@ -19,8 +24,8 @@ void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn,
|
|||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
{
|
||||
a_data(r,c) = a_init_fn(r, c);
|
||||
b_data(r,c) = b_init_fn(r, c);
|
||||
a_data(r, c) = a_init_fn(r, c);
|
||||
b_data(r, c) = b_init_fn(r, c);
|
||||
}
|
||||
|
||||
ref_data = ops(a_data, b_data);
|
||||
|
|
@ -35,15 +40,19 @@ void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn,
|
|||
TTS_EXPECT(verify_rotgen_reentrance(self_ops(a_map, b_map)));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_scalar_operations(rotgen::Index rows, rotgen::Index cols, auto fn, auto s, auto ops, auto self_ops)
|
||||
template<typename MatrixType>
|
||||
void test_map_scalar_operations(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
auto fn,
|
||||
auto s,
|
||||
auto ops,
|
||||
auto self_ops)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
a_data(r,c) = fn(r, c);
|
||||
for (rotgen::Index c = 0; c < cols; ++c) a_data(r, c) = fn(r, c);
|
||||
|
||||
ref_data = ops(a_data, s);
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
|
|
@ -56,15 +65,17 @@ void test_map_scalar_operations(rotgen::Index rows, rotgen::Index cols, auto fn,
|
|||
TTS_EXPECT(verify_rotgen_reentrance(self_ops(a_map, s)));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_scalar_multiplications(rotgen::Index rows, rotgen::Index cols, auto fn, auto s)
|
||||
template<typename MatrixType>
|
||||
void test_map_scalar_multiplications(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
auto fn,
|
||||
auto s)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
a_data(r,c) = fn(r, c);
|
||||
for (rotgen::Index c = 0; c < cols; ++c) a_data(r, c) = fn(r, c);
|
||||
|
||||
ref_data = a_data * s;
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
|
|
@ -79,8 +90,11 @@ void test_map_scalar_multiplications(rotgen::Index rows, rotgen::Index cols, aut
|
|||
TTS_EXPECT(verify_rotgen_reentrance(a_map *= s));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init_fn, auto b_init_fn)
|
||||
template<typename MatrixType>
|
||||
void test_map_multiplication(rotgen::Index rows,
|
||||
rotgen::Index cols,
|
||||
auto a_init_fn,
|
||||
auto b_init_fn)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType b_data(cols, rows);
|
||||
|
|
@ -89,8 +103,8 @@ void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init
|
|||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
{
|
||||
a_data(r,c) = a_init_fn(r,c);
|
||||
b_data(c,r) = b_init_fn(c,r);
|
||||
a_data(r, c) = a_init_fn(r, c);
|
||||
b_data(c, r) = b_init_fn(c, r);
|
||||
}
|
||||
|
||||
ref_data = a_data * b_data;
|
||||
|
|
@ -100,103 +114,111 @@ void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init
|
|||
TTS_EQUAL(a_map * b_map, ref_data);
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map * b_map));
|
||||
|
||||
if(rows == cols)
|
||||
if (rows == cols)
|
||||
{
|
||||
a_map *= b_map;
|
||||
TTS_EQUAL(a_map, ref_data);
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map *= b_map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline constexpr auto init_a = [](auto r, auto c) { return 9.9*r*r*r - 6*c - 12; };
|
||||
inline constexpr auto init_b = [](auto r, auto c) { return 3.1*r + 4.2*c - 12.3; };
|
||||
inline constexpr auto init_0 = [](auto , auto ) { return 0; };
|
||||
inline constexpr auto init_a = [](auto r, auto c) {
|
||||
return 9.9 * r * r * r - 6 * c - 12;
|
||||
};
|
||||
inline constexpr auto init_b = [](auto r, auto c) {
|
||||
return 3.1 * r + 4.2 * c - 12.3;
|
||||
};
|
||||
inline constexpr auto init_0 = [](auto, auto) { return 0; };
|
||||
|
||||
TTS_CASE_TPL("Check map addition", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Check map 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; };
|
||||
auto s_op = [](auto& a, auto b) { return a += b; };
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a + b; };
|
||||
auto s_op = [](auto& a, auto b) { return a += b; };
|
||||
|
||||
test_map_operations<mat_t>(1 , 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(1, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3, 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(10, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(1 ,10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_0, op, s_op);
|
||||
test_map_operations<mat_t>(1, 10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map subtraction", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Check map subtraction",
|
||||
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; };
|
||||
auto s_op = [](auto& a, auto b) { return a -= b; };
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a - b; };
|
||||
auto s_op = [](auto& a, auto b) { return a -= b; };
|
||||
|
||||
test_map_operations<mat_t>(1 , 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(1, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3, 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(10, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(1 ,10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_0, op, s_op);
|
||||
test_map_operations<mat_t>(1, 10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5, 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map multiplications", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Check map 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>;
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto init_id = [](auto r, auto c) { return r == c ? 1 : 0; };
|
||||
|
||||
test_map_multiplication<mat_t>(1 , 1, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(3 , 5, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 3, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_b , init_a );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_a );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_id);
|
||||
test_map_multiplication<mat_t>(5 , 5, init_id, init_a );
|
||||
test_map_multiplication<mat_t>(10, 1, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(1 ,10, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_0 , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_0 );
|
||||
test_map_multiplication<mat_t>(1, 1, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(3, 5, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(5, 3, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(5, 5, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(5, 5, init_b, init_a);
|
||||
test_map_multiplication<mat_t>(5, 5, init_a, init_a);
|
||||
test_map_multiplication<mat_t>(5, 5, init_a, init_id);
|
||||
test_map_multiplication<mat_t>(5, 5, init_id, init_a);
|
||||
test_map_multiplication<mat_t>(10, 1, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(1, 10, init_a, init_b);
|
||||
test_map_multiplication<mat_t>(5, 5, init_0, init_b);
|
||||
test_map_multiplication<mat_t>(5, 5, init_a, init_0);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map multiplication with scalar", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Check map 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>;
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
|
||||
test_map_scalar_multiplications<mat_t>(1 , 1, init_a, T{ 3.5});
|
||||
test_map_scalar_multiplications<mat_t>(3 , 5, init_a, T{-2.5});
|
||||
test_map_scalar_multiplications<mat_t>(5 , 3, init_a, T{ 4. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{-5. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{ 1. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{ 6. });
|
||||
test_map_scalar_multiplications<mat_t>(10, 1, init_a, T{ 10.});
|
||||
test_map_scalar_multiplications<mat_t>(1 ,10, init_a, T{-0.5});
|
||||
test_map_scalar_multiplications<mat_t>(1, 1, init_a, T{3.5});
|
||||
test_map_scalar_multiplications<mat_t>(3, 5, init_a, T{-2.5});
|
||||
test_map_scalar_multiplications<mat_t>(5, 3, init_a, T{4.});
|
||||
test_map_scalar_multiplications<mat_t>(5, 5, init_a, T{-5.});
|
||||
test_map_scalar_multiplications<mat_t>(5, 5, init_a, T{1.});
|
||||
test_map_scalar_multiplications<mat_t>(5, 5, init_a, T{6.});
|
||||
test_map_scalar_multiplications<mat_t>(10, 1, init_a, T{10.});
|
||||
test_map_scalar_multiplications<mat_t>(1, 10, init_a, T{-0.5});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map division with scalar", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Check map 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; };
|
||||
auto s_op = [](auto& a, auto b) { return a /= b; };
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
auto op = [](auto a, auto b) { return a / b; };
|
||||
auto s_op = [](auto& a, auto b) { return a /= b; };
|
||||
|
||||
test_map_scalar_operations<mat_t>(1 , 1, init_a, T{ 3.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(3 , 5, init_a, T{-2.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 3, init_a, T{ 4. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{-5. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{ 1. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{ 6. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(10, 1, init_a, T{ 10.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(1 ,10, init_a, T{-0.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(1, 1, init_a, T{3.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(3, 5, init_a, T{-2.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5, 3, init_a, T{4.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5, 5, init_a, T{-5.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5, 5, init_a, T{1.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5, 5, init_a, T{6.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(10, 1, init_a, T{10.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(1, 10, init_a, T{-0.5}, op, s_op);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue