//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include "unit/tests.hpp" #include void test_value ( const auto& matrix, auto value , rotgen::Index i0, rotgen::Index j0 , rotgen::Index rows, rotgen::Index cols ) { for(rotgen::Index r=0;r( tts::type< tts::types>) { auto const cases = rotgen::tests::generate_block_references(); for (const auto& [matrix_desc, i0, j0, ni, nj] : cases) { auto[rows,cols,fn] = matrix_desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0, ni, nj); input.setZero(); test_value(m,T{0},i0,j0,ni,nj); using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj)); auto values = input_type::Zero(ni,nj); test_value(values,T{0},0,0,ni,nj); } }; TTS_CASE_TPL("Test static block:setZero", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_block_references(); auto process = [](D const& d) { auto[desc,i0,j0] = d; auto[rows,cols,fn] = desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0); input.setZero(); test_value(m,T{0},i0,j0,D::ni,D::nj); using input_type = decltype(rotgen::extract(m, i0, j0)); auto values = input_type::Zero(); test_value(values,T{0},0,0,D::ni,D::nj); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dynamic block::setOnes", rotgen::tests::types) ( tts::type< tts::types>) { auto const cases = rotgen::tests::generate_block_references(); for (const auto& [matrix_desc, i0, j0, ni, nj] : cases) { auto[rows,cols,fn] = matrix_desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0, ni, nj); input.setOnes(); test_value(m,T{1},i0,j0,ni,nj); using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj)); auto values = input_type::Ones(ni,nj); test_value(values,T{1},0,0,ni,nj); } }; TTS_CASE_TPL("Test static block:setOnes", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_block_references(); auto process = [](D const& d) { auto[desc,i0,j0] = d; auto[rows,cols,fn] = desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0); input.setOnes(); test_value(m,T{1},i0,j0,D::ni,D::nj); using input_type = decltype(rotgen::extract(m, i0, j0)); auto values = input_type::Ones(); test_value(values,T{1},0,0,D::ni,D::nj); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dynamic block::setConstant", rotgen::tests::types) ( tts::type< tts::types>) { auto const cases = rotgen::tests::generate_block_references(); for (const auto& [matrix_desc, i0, j0, ni, nj] : cases) { auto[rows,cols,fn] = matrix_desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0, ni, nj); input.setConstant(T{13.37f}); test_value(m,T{13.37f},i0,j0,ni,nj); using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj)); auto values = input_type::Constant(ni,nj,T{13.37f}); test_value(values,T{13.37f},0,0,ni,nj); } }; TTS_CASE_TPL("Test static block:setConstant", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_block_references(); auto process = [](D const& d) { auto[desc,i0,j0] = d; auto[rows,cols,fn] = desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0); input.setConstant(T{13.37f}); test_value(m,T{13.37f},i0,j0,D::ni,D::nj); using input_type = decltype(rotgen::extract(m, i0, j0)); auto values = input_type::Constant(T{13.37f}); test_value(values,T{13.37f},0,0,D::ni,D::nj); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dynamic block::setIdentity", rotgen::tests::types) ( tts::type< tts::types>) { auto const cases = rotgen::tests::generate_block_references(); for (const auto& [matrix_desc, i0, j0, ni, nj] : cases) { auto[rows,cols,fn] = matrix_desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0, ni, nj); input.setIdentity(); test_identity(m,i0,j0,ni,nj); using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj)); auto values = input_type::Identity(ni,nj); test_identity(values,0,0,ni,nj); } }; TTS_CASE_TPL("Test static block:setIdentity", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_block_references(); auto process = [](D const& d) { auto[desc,i0,j0] = d; auto[rows,cols,fn] = desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0); input.setIdentity(); test_identity(m,i0,j0,D::ni,D::nj); using input_type = decltype(rotgen::extract(m, i0, j0)); auto values = input_type::Identity(); test_identity(values,0,0,D::ni,D::nj); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); }; TTS_CASE_TPL("Test dynamic block::setRandom", rotgen::tests::types) ( tts::type< tts::types>) { auto const cases = rotgen::tests::generate_block_references(); for (const auto& [matrix_desc, i0, j0, ni, nj] : cases) { auto[rows,cols,fn] = matrix_desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0, ni, nj); input.setRandom(); test_random(m,i0,j0,ni,nj); using input_type = decltype(rotgen::extract(m, i0, j0, ni, nj)); auto values = input_type::Random(ni,nj); test_random(values,0,0,ni,nj); } }; TTS_CASE_TPL("Test static block:setRandom", rotgen::tests::types) ( tts::type< tts::types> ) { auto const cases = rotgen::tests::generate_static_block_references(); auto process = [](D const& d) { auto[desc,i0,j0] = d; auto[rows,cols,fn] = desc; rotgen::matrix m(rows, cols); rotgen::tests::prepare(rows,cols,fn,m); auto input = rotgen::extract(m, i0, j0); input.setRandom(); test_random(m,i0,j0,D::ni,D::nj); using input_type = decltype(rotgen::extract(m, i0, j0)); auto values = input_type::Random(); test_random(values,0,0,D::ni,D::nj); }; std::apply([&](auto const&... d) { (process(d),...);}, cases); };