parent
1f8663aad2
commit
cc5ab775bc
9 changed files with 181 additions and 2 deletions
47
test/integration/aliasing.cpp
Normal file
47
test/integration/aliasing.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
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("noalias behavior - dynamicallly sized", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> a{{1,2},{3,4}};
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> ref{{7,10},{15,22}};
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> b(2,2),c(2,2),d(2,2);
|
||||
|
||||
rotgen::noalias(b) = a * a;
|
||||
TTS_EQUAL(b, ref);
|
||||
|
||||
auto e = rotgen::extract(c,0,0,2,2);
|
||||
rotgen::noalias(e) = a * a;
|
||||
TTS_EQUAL(c, ref);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> m(d.data(),2,2);
|
||||
rotgen::noalias(m) = a * a;
|
||||
TTS_EQUAL(m, ref);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("noalias behavior - statically sized", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
rotgen::matrix<T,2,2,O::value> a{{1,2},{3,4}};
|
||||
rotgen::matrix<T,2,2,O::value> ref{{7,10},{15,22}};
|
||||
rotgen::matrix<T,2,2,O::value> b,c,d;
|
||||
|
||||
rotgen::noalias(b) = a * a;
|
||||
TTS_EQUAL(b, ref);
|
||||
|
||||
auto e = rotgen::extract(c,0,0,2,2);
|
||||
rotgen::noalias(e) = a * a;
|
||||
TTS_EQUAL(c, ref);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,2,2,O::value>> m(d.data());
|
||||
rotgen::noalias(m) = a * a;
|
||||
TTS_EQUAL(m, ref);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue