89 lines
3 KiB
C++
89 lines
3 KiB
C++
//==================================================================================================
|
|
/*
|
|
ROTGEN - Runtime Overlay for Eigen
|
|
Copyright : CODE RECKONS
|
|
SPDX-License-Identifier: BSL-1.0
|
|
*/
|
|
//==================================================================================================
|
|
#include "unit/tests.hpp"
|
|
#include <rotgen/rotgen.hpp>
|
|
|
|
TTS_CASE_TPL("map constructor from pointer and single static 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};
|
|
|
|
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor>> row_map(data);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(row_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor> const> const_row_map(data);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(const_row_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor>> col_map(data);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(col_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor> const> const_col_map(data);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(const_col_map(i), data[i]);
|
|
};
|
|
|
|
TTS_CASE_TPL("map constructor from pointer and static size", rotgen::tests::types)
|
|
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
|
{
|
|
using base = rotgen::matrix<T,4,3,O::value>;
|
|
|
|
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
|
|
|
rotgen::map<base> dyn_map(data);
|
|
for(rotgen::Index i=0;i<4;i++)
|
|
{
|
|
for(rotgen::Index j=0;j<3;j++)
|
|
{
|
|
if constexpr(O::value) TTS_EQUAL(dyn_map(i,j), data[j+3*i]);
|
|
else TTS_EQUAL(dyn_map(i,j), data[i+4*j]);
|
|
}
|
|
}
|
|
};
|
|
|
|
TTS_CASE_TPL("map constructor from pointer and single dynamic 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};
|
|
|
|
rotgen::map<rotgen::matrix<T,1,rotgen::Dynamic,rotgen::RowMajor>> row_map(data,12);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(row_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,1,rotgen::Dynamic,rotgen::RowMajor> const> const_row_map(data,12);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(const_row_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,1,rotgen::ColMajor>> col_map(data,12);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(col_map(i), data[i]);
|
|
|
|
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,1,rotgen::ColMajor> const> const_col_map(data,12);
|
|
for(rotgen::Index i=0;i<12;i++)
|
|
TTS_EQUAL(const_col_map(i), data[i]);
|
|
};
|
|
|
|
TTS_CASE_TPL("map constructor from pointer and dynamic size", rotgen::tests::types)
|
|
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
|
{
|
|
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};
|
|
|
|
rotgen::map<base> dyn_map(data,4,3);
|
|
for(rotgen::Index i=0;i<4;i++)
|
|
{
|
|
for(rotgen::Index j=0;j<3;j++)
|
|
{
|
|
if constexpr(O::value) TTS_EQUAL(dyn_map(i,j), data[j+3*i]);
|
|
else TTS_EQUAL(dyn_map(i,j), data[i+4*j]);
|
|
}
|
|
}
|
|
};
|