Clarify single index API for data access.
This commit is contained in:
parent
a50098f761
commit
d89da18709
13 changed files with 249 additions and 128 deletions
|
|
@ -138,27 +138,30 @@ TTS_CASE_TPL("Test coefficient accessors", rotgen::tests::types)
|
|||
TTS_CASE_TPL("Test one index 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(2, 4);
|
||||
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;
|
||||
|
||||
int i = 1;
|
||||
if constexpr(!O::value)
|
||||
{
|
||||
for(rotgen::Index c=0;c<a.cols();++c)
|
||||
for(rotgen::Index r=0;r<a.rows();++r)
|
||||
a(r, c) = i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 s=0;s<a.size();++s)
|
||||
TTS_EQUAL(a(s), i++) << a;
|
||||
|
||||
i = 1;
|
||||
for(rotgen::Index r=0;r<a.rows()*a.cols();++r)
|
||||
TTS_EQUAL(a(r), i++) << a;
|
||||
for(rotgen::Index s=0;s<a.size();++s)
|
||||
TTS_EQUAL(a[s], i++) << a;
|
||||
|
||||
T& ref = a(2);
|
||||
ref = 999.5;
|
||||
TTS_EQUAL(a(2), 999.5);
|
||||
|
||||
T& bref = a[3];
|
||||
bref = 42.5;
|
||||
TTS_EQUAL(a[3], 42.5);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue