Implement fixed size options for rotgen containers
See merge request oss/rotgen!11
This commit is contained in:
parent
8e545dd51a
commit
2084874b1b
39 changed files with 1247 additions and 323 deletions
|
|
@ -6,15 +6,15 @@
|
|||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/matrix.hpp>
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("Default matrix dynamic constructor", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> matrix;
|
||||
|
||||
TTS_EQUAL(matrix.rows(), 0ULL);
|
||||
TTS_EQUAL(matrix.cols(), 0ULL);
|
||||
TTS_EQUAL(matrix.rows(), rotgen::Index{0});
|
||||
TTS_EQUAL(matrix.cols(), rotgen::Index{0});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Default matrix static constructor", rotgen::tests::types)
|
||||
|
|
@ -22,8 +22,8 @@ TTS_CASE_TPL("Default matrix static constructor", rotgen::tests::types)
|
|||
{
|
||||
rotgen::matrix<T,4,9,O::value> matrix;
|
||||
|
||||
TTS_EQUAL(matrix.rows(), 4ULL);
|
||||
TTS_EQUAL(matrix.cols(), 9ULL);
|
||||
TTS_EQUAL(matrix.rows(), rotgen::Index{4});
|
||||
TTS_EQUAL(matrix.cols(), rotgen::Index{9});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Dynamic matrix constructor with row and columns", rotgen::tests::types)
|
||||
|
|
@ -31,8 +31,8 @@ TTS_CASE_TPL("Dynamic matrix constructor with row and columns", rotgen::tests::t
|
|||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> matrix(10, 5);
|
||||
|
||||
TTS_EQUAL(matrix.rows(), 10ULL);
|
||||
TTS_EQUAL(matrix.cols(), 5ULL);
|
||||
TTS_EQUAL(matrix.rows(), rotgen::Index{10});
|
||||
TTS_EQUAL(matrix.cols(), rotgen::Index{5});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Static matrix constructor with row and columns", rotgen::tests::types)
|
||||
|
|
@ -40,8 +40,8 @@ TTS_CASE_TPL("Static matrix constructor with row and columns", rotgen::tests::ty
|
|||
{
|
||||
rotgen::matrix<T,6,11,O::value> matrix(6, 11);
|
||||
|
||||
TTS_EQUAL(matrix.rows(), 6ULL);
|
||||
TTS_EQUAL(matrix.cols(), 11ULL);
|
||||
TTS_EQUAL(matrix.rows(), rotgen::Index{6});
|
||||
TTS_EQUAL(matrix.cols(), rotgen::Index{11});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Copy constructor produces identical but independent matrix", rotgen::tests::types)
|
||||
|
|
@ -49,8 +49,8 @@ TTS_CASE_TPL("Copy constructor produces identical but independent matrix", rotge
|
|||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> a(3, 3);
|
||||
|
||||
for(std::size_t r=0;r<a.rows();r++)
|
||||
for(std::size_t c=0;c<a.cols();c++)
|
||||
for(rotgen::Index r=0;r<a.rows();r++)
|
||||
for(rotgen::Index c=0;c<a.cols();c++)
|
||||
a(r,c) = r + c;
|
||||
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b = a;
|
||||
|
|
@ -58,8 +58,8 @@ TTS_CASE_TPL("Copy constructor produces identical but independent matrix", rotge
|
|||
TTS_EQUAL(b.rows(), a.rows());
|
||||
TTS_EQUAL(b.cols(), a.cols());
|
||||
|
||||
for(std::size_t r=0;r<a.rows();r++)
|
||||
for(std::size_t c=0;c<a.cols();c++)
|
||||
for(rotgen::Index r=0;r<a.rows();r++)
|
||||
for(rotgen::Index c=0;c<a.cols();c++)
|
||||
TTS_EQUAL(b(r,c), a(r,c));
|
||||
|
||||
TTS_EQUAL(b(0, 0), 0.0);
|
||||
|
|
@ -75,8 +75,8 @@ TTS_CASE_TPL("Copy constructor on default matrix", rotgen::tests::types)
|
|||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> a;
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b = a;
|
||||
TTS_EQUAL(b.rows(), 0ULL);
|
||||
TTS_EQUAL(b.cols(), 0ULL);
|
||||
TTS_EQUAL(b.rows(), rotgen::Index{0});
|
||||
TTS_EQUAL(b.cols(), rotgen::Index{0});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Copy constructor from const matrix", rotgen::tests::types)
|
||||
|
|
@ -84,17 +84,17 @@ TTS_CASE_TPL("Copy constructor from const matrix", rotgen::tests::types)
|
|||
{
|
||||
const rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> a(2, 2);
|
||||
auto b = a;
|
||||
TTS_EQUAL(b.rows(), 2ULL);
|
||||
TTS_EQUAL(b.cols(), 2ULL);
|
||||
TTS_EQUAL(b.rows(), rotgen::Index{2});
|
||||
TTS_EQUAL(b.cols(), rotgen::Index{2});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Copy constructor on static matrix", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T, 2, 5> a;
|
||||
rotgen::matrix<T, 2, 5> b = a;
|
||||
TTS_EQUAL(b.rows(), 2ULL);
|
||||
TTS_EQUAL(b.cols(), 5ULL);
|
||||
rotgen::matrix<T, 2, 5> a;
|
||||
rotgen::matrix<T, 2, 5> b = a;
|
||||
TTS_EQUAL(b.rows(), rotgen::Index{2});
|
||||
TTS_EQUAL(b.cols(), rotgen::Index{5});
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -126,8 +126,8 @@ TTS_CASE_TPL("Move constructor transfers contents", rotgen::tests::types)
|
|||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b = std::move(a);
|
||||
|
||||
TTS_EQUAL(b(1,1), 7);
|
||||
TTS_EQUAL(b.rows(), 3ULL);
|
||||
TTS_EQUAL(b.cols(), 3ULL);
|
||||
TTS_EQUAL(b.rows(), rotgen::Index{3});
|
||||
TTS_EQUAL(b.cols(), rotgen::Index{3});
|
||||
TTS_EXPECT(b.data() == ptr);
|
||||
};
|
||||
|
||||
|
|
@ -135,31 +135,32 @@ TTS_CASE_TPL("Move constructor from Rvalue", rotgen::tests::types)
|
|||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>(2, 2);
|
||||
TTS_EQUAL(b.rows(), 2ULL);
|
||||
TTS_EQUAL(b.cols(), 2ULL);
|
||||
TTS_EQUAL(b.rows(), rotgen::Index{2});
|
||||
TTS_EQUAL(b.cols(), rotgen::Index{2});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Constructor from Initializer list", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,1,1,O::value> b1 = {3.5};
|
||||
TTS_EQUAL(b1.rows(), 1ULL);
|
||||
TTS_EQUAL(b1.cols(), 1ULL);
|
||||
rotgen::matrix<T,1,1,O::value> b1{3.5};
|
||||
TTS_EQUAL(b1.rows(), rotgen::Index{1});
|
||||
TTS_EQUAL(b1.cols(), rotgen::Index{1});
|
||||
TTS_EQUAL(b1(0) , 3.5);
|
||||
|
||||
rotgen::matrix<T,5,1,O::value> b9 = {0.25, 0.5, 1, 2, 4};
|
||||
TTS_EQUAL(b9.rows(), 5ULL);
|
||||
TTS_EQUAL(b9.cols(), 1ULL);
|
||||
rotgen::matrix<T,5,1,rotgen::ColMajor> b9{0.25, 0.5, 1, 2, 4};
|
||||
TTS_EQUAL(b9.rows(), rotgen::Index{5});
|
||||
TTS_EQUAL(b9.cols(), rotgen::Index{1});
|
||||
|
||||
T i = 0.25;
|
||||
for(std::size_t r=0;r<b9.rows();++r) {
|
||||
for(rotgen::Index r=0;r<b9.rows();++r)
|
||||
{
|
||||
TTS_EQUAL(b9(r,0), i);
|
||||
i *= 2;
|
||||
}
|
||||
|
||||
rotgen::matrix<T,1,3,O::value> b13 = {1.2,2.3,3.4};
|
||||
TTS_EQUAL(b13.rows(), 1ULL);
|
||||
TTS_EQUAL(b13.cols(), 3ULL);
|
||||
rotgen::matrix<T,1,3,rotgen::RowMajor> b13{1.2,2.3,3.4};
|
||||
TTS_EQUAL(b13.rows(), rotgen::Index{1});
|
||||
TTS_EQUAL(b13.cols(), rotgen::Index{3});
|
||||
TTS_EQUAL(b13(0) , T(1.2));
|
||||
TTS_EQUAL(b13(1) , T(2.3));
|
||||
TTS_EQUAL(b13(2) , T(3.4));
|
||||
|
|
@ -168,16 +169,18 @@ TTS_CASE_TPL("Constructor from Initializer list", rotgen::tests::types)
|
|||
TTS_CASE_TPL("Constructor from Initializer list of rows", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b1 = {{3.5}};
|
||||
TTS_EQUAL(b1.rows(), 1ULL);
|
||||
TTS_EQUAL(b1.cols(), 1ULL);
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b1{{3.5}};
|
||||
TTS_EQUAL(b1.rows(), rotgen::Index{1});
|
||||
TTS_EQUAL(b1.cols(), rotgen::Index{1});
|
||||
TTS_EQUAL(b1(0,0) , T(3.5));
|
||||
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b23 = { {1.2,2.3,3.4}
|
||||
, {10,200,3000}
|
||||
};
|
||||
TTS_EQUAL(b23.rows(), 2ULL);
|
||||
TTS_EQUAL(b23.cols(), 3ULL);
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>
|
||||
b23 { {1.2,2.3,3.4}
|
||||
, {10,200,3000}
|
||||
};
|
||||
|
||||
TTS_EQUAL(b23.rows(), rotgen::Index{2});
|
||||
TTS_EQUAL(b23.cols(), rotgen::Index{3});
|
||||
TTS_EQUAL(b23(0,0) , T(1.2));
|
||||
TTS_EQUAL(b23(0,1) , T(2.3));
|
||||
TTS_EQUAL(b23(0,2) , T(3.4));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue