//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include "unit/tests.hpp" #include "unit/common/arithmetic.hpp" #include TTS_CASE_TPL("Test dynamic map transposition-like operations", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_matrix_references(); for (const auto& [rows, cols, fn] : cases) { using mat_t = rotgen::matrix; mat_t base(rows, cols); rotgen::tests::prepare(rows,cols,fn,base); rotgen::map input(base.data(),rows,cols); rotgen::tests::check_shape_functions(input); } }; TTS_CASE_TPL("Test static map transposition-like operations", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_matrix_references(); auto process = [](D const& desc) { rotgen::matrix base(D::rows,D::cols); rotgen::tests::prepare(base.rows(),base.cols(),desc.init_fn,base); rotgen::map> input(base.data()); rotgen::tests::check_shape_functions(input); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dynamic map reduction-like operations", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_matrix_references(); for (const auto& [rows, cols, fn] : cases) { rotgen::matrix base(rows, cols); rotgen::tests::prepare(rows,cols,fn,base); rotgen::map> input(base.data(),rows,cols); rotgen::tests::check_reduction_functions(input); } }; TTS_CASE_TPL("Test static map reduction-like operations", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_matrix_references(); auto process = [](D const& desc) { rotgen::matrix base(D::rows,D::cols); rotgen::tests::prepare(base.rows(),base.cols(),desc.init_fn,base); rotgen::map> input(base.data()); rotgen::tests::check_reduction_functions(input); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dot product", float, double) ( tts::type ) { { auto v = rotgen::setConstant>(1,16,2); auto a = rotgen::map(v.data(),1,8); auto b = rotgen::map(v.data()+8,1,8); TTS_EQUAL(rotgen::dot(a,b), 32); } { auto v = rotgen::setConstant>(16,1,2); auto a = rotgen::map(v.data(),8,1); auto b = rotgen::map(v.data()+8,8,1); TTS_EQUAL(rotgen::dot(a,b), 32); } { auto v = rotgen::setConstant>(1,16,2); auto a = rotgen::map>(v.data()); auto b = rotgen::map>(v.data()+8); TTS_EQUAL(rotgen::dot(a,b), 32); } { auto v = rotgen::setConstant>(1,16,2); auto a = rotgen::map>(v.data()); auto b = rotgen::map>(v.data()+8); TTS_EQUAL(rotgen::dot(a,b), 32); } };