Implement IOFormat wrappers

See merge request oss/rotgen!34
This commit is contained in:
Joel Falcou 2025-10-02 19:28:43 +02:00
parent 71109fa551
commit 5a6cd4b0f2
18 changed files with 333 additions and 115 deletions

View file

@ -1,47 +0,0 @@
//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#include "unit/tests.hpp"
#include <rotgen/rotgen.hpp>
#include <sstream>
TTS_CASE_TPL("I/O for matrix", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
{
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> x({ {1,2} , {3,4} });
std::ostringstream os;
os << x;
TTS_EQUAL(os.str(), std::string{"1 2\n3 4"});
};
TTS_CASE_TPL("I/O for block", rotgen::tests::types)
<typename T, typename O>( tts::type< tts::types<T,O>> )
{
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base({ {1,2} , {3,4} });
auto x = rotgen::extract(base,0,0,2,2);
std::ostringstream os;
os << x;
TTS_EQUAL(os.str(), std::string{"1 2\n3 4"});
};
TTS_CASE_TPL("I/O for map test", 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};
rotgen::map<base> x(data,2,2);
std::ostringstream os;
os << x;
if constexpr(O::value) TTS_EQUAL(os.str(), std::string{"1 2\n3 4"});
else TTS_EQUAL(os.str(), std::string{"1 3\n2 4"});
};