rotgen/test/integration/aliasing.cpp
Jules Pénuchot 648dd768ee 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
2025-10-14 16:19:03 +02:00

53 lines
1.7 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("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);
};