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,13 +8,15 @@
|
|||
#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>>)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> empty_matrix;
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> matrix(3,4);
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> row_vector(9,1);
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> column_vector(1,5);
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> empty_matrix;
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> matrix(3, 4);
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> row_vector(9,
|
||||
1);
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value> column_vector(
|
||||
1, 5);
|
||||
|
||||
TTS_EQUAL(empty_matrix.size(), rotgen::Index{0});
|
||||
TTS_EQUAL(matrix.size(), rotgen::Index{12});
|
||||
|
|
@ -22,72 +24,69 @@ TTS_CASE_TPL("Function size", rotgen::tests::types)
|
|||
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);
|
||||
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 < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = 42 + 2 * c + r;
|
||||
|
||||
a.resize(3, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(3));
|
||||
TTS_EQUAL(a.cols(), 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 < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) TTS_GREATER(a(r, c), 0);
|
||||
|
||||
a.resize(2,2);
|
||||
a.resize(2, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), 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);
|
||||
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 < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = i++;
|
||||
|
||||
a.conservativeResize(2, 3);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), 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 < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) TTS_EQUAL(a(r, c), i++);
|
||||
|
||||
a.conservativeResize(3, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(3));
|
||||
TTS_EQUAL(a.cols(), 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]);
|
||||
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]);
|
||||
|
||||
a.conservativeResize(4, 4);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(4));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(4));
|
||||
TTS_EQUAL(a(0,0), 1);
|
||||
TTS_EQUAL(a(3,3), 0);
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(3, 3), 0);
|
||||
|
||||
a.conservativeResize(2, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(2));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(a(0,0), 1);
|
||||
TTS_EQUAL(a(1,1), 5);
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(1, 1), 5);
|
||||
|
||||
a.conservativeResize(1, 2);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(1));
|
||||
TTS_EQUAL(a.cols(), rotgen::Index(2));
|
||||
TTS_EQUAL(a(0,0), 1);
|
||||
TTS_EQUAL(a(0,1), 2);
|
||||
TTS_EQUAL(a(0, 0), 1);
|
||||
TTS_EQUAL(a(0, 1), 2);
|
||||
|
||||
a.conservativeResize(0, 0);
|
||||
TTS_EQUAL(a.rows(), rotgen::Index(0));
|
||||
|
|
@ -98,50 +97,48 @@ TTS_CASE_TPL("Dynamix matrix conservative resizing", rotgen::tests::types)
|
|||
TTS_EQUAL(a.cols(), 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);
|
||||
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 < a.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < a.cols(); ++c) a(r, c) = r + 2 * c + 3;
|
||||
|
||||
TTS_EQUAL(a(0,0), 3);
|
||||
TTS_EQUAL(a(1,1), 6);
|
||||
TTS_EQUAL(a(1,0), 4);
|
||||
TTS_EQUAL(a(2,2), 9);
|
||||
TTS_EQUAL(a(2,4), 13);
|
||||
TTS_EQUAL(a(0, 0), 3);
|
||||
TTS_EQUAL(a(1, 1), 6);
|
||||
TTS_EQUAL(a(1, 0), 4);
|
||||
TTS_EQUAL(a(2, 2), 9);
|
||||
TTS_EQUAL(a(2, 4), 13);
|
||||
|
||||
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>>)
|
||||
{
|
||||
auto a = [&]()
|
||||
{
|
||||
if constexpr(O::value == rotgen::ColMajor) return rotgen::matrix<T,1,rotgen::Dynamic>(1,8);
|
||||
else return rotgen::matrix<T,rotgen::Dynamic,1>(8,1);
|
||||
auto a = [&]() {
|
||||
if constexpr (O::value == rotgen::ColMajor)
|
||||
return rotgen::matrix<T, 1, rotgen::Dynamic>(1, 8);
|
||||
else return rotgen::matrix<T, rotgen::Dynamic, 1>(8, 1);
|
||||
}();
|
||||
|
||||
TTS_EXPECT(a.IsVectorAtCompileTime);
|
||||
|
||||
for(rotgen::Index s=0;s<a.size();++s)
|
||||
a(s) = s+1;
|
||||
for (rotgen::Index s = 0; s < a.size(); ++s) a(s) = s + 1;
|
||||
|
||||
int i = 1;
|
||||
for(rotgen::Index s=0;s<a.size();++s)
|
||||
TTS_EQUAL(a(s), i++) << a;
|
||||
for (rotgen::Index s = 0; s < a.size(); ++s) TTS_EQUAL(a(s), i++) << a;
|
||||
|
||||
i = 1;
|
||||
for(rotgen::Index s=0;s<a.size();++s)
|
||||
TTS_EQUAL(a[s], i++) << a;
|
||||
for (rotgen::Index s = 0; s < a.size(); ++s) TTS_EQUAL(a[s], i++) << a;
|
||||
|
||||
T& ref = a(2);
|
||||
ref = 999.5;
|
||||
|
|
@ -150,4 +147,4 @@ TTS_CASE_TPL("Test one index coefficient accessors", rotgen::tests::types)
|
|||
T& bref = a[3];
|
||||
bref = 42.5;
|
||||
TTS_EQUAL(a[3], 42.5);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue