//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include "unit/tests.hpp" #include void test_size(const auto& matrix, rotgen::Index rows, rotgen::Index cols) { TTS_EQUAL(matrix.rows(), rows); TTS_EQUAL(matrix.cols(), cols); TTS_EQUAL(matrix.size(), rows*cols); } void test_value(const auto& matrix, rotgen::Index rows, rotgen::Index cols, auto constant) { TTS_EXPECT(verify_rotgen_reentrance(matrix)); test_size(matrix, rows, cols); for(rotgen::Index r=0;r( tts::type< tts::types>) { test_value(rotgen::block, 3, 4>::Zero(), 3, 4, 0); test_value(rotgen::block, 1, 1>::Zero(), 1, 1, 0); test_value(rotgen::block, 10, 10>::Zero(), 10, 10, 0); test_value(rotgen::block, 3, 4>::Zero(3, 4), 3, 4, 0); test_value(rotgen::block, 3, 3>::Zero(3, 3), 3, 3, 0); test_value(rotgen::block, 2, 2>::Zero(2, 2), 2, 2, 0); test_value(rotgen::block, rotgen::Dynamic, rotgen::Dynamic>::Zero(2, 3), 2, 3, 0); test_value(rotgen::block, 0, 0>::Zero(0, 0), 0, 0, 0); test_value(rotgen::block::Identity(2, 7)), rotgen::Dynamic, 7>::Zero(3, 7), 3, 7, 0); test_value(rotgen::block::Random(14, 3)), 4, rotgen::Dynamic>::Zero(4, 3), 4, 3, 0); }; TTS_CASE_TPL("Test constant", rotgen::tests::types) ( tts::type< tts::types> ) { test_value(rotgen::block, 3, 4>::Constant(5.12), 3, 4, T(5.12)); test_value(rotgen::block, 1, 1>::Constant(2.2), 1, 1, T(2.2)); test_value(rotgen::block, 10, 10>::Constant(13), 10, 10, T(13)); test_value(rotgen::block, rotgen::Dynamic, rotgen::Dynamic>::Constant(2, 7, 5.6), 2, 7, T(5.6)); test_value(rotgen::block, 2, 2>::Constant(2, 2, 2.0), 2, 2, T(2.0)); test_value(rotgen::block, rotgen::Dynamic, 9>::Constant(9, 9, 1.1), 9, 9, T(1.1)); test_value(rotgen::block, 5, rotgen::Dynamic>::Constant(5, 9, 42), 5, 9, T(42)); test_value(rotgen::block, 4, 3>::Constant(4, 3, 0), 4, 3, 0); test_value(rotgen::block::Identity(3, 7)), rotgen::Dynamic, 7>::Constant(3, 7, 88), 3, 7, T(88)); test_value(rotgen::block::Random(14, 3)), 4, rotgen::Dynamic>::Constant(4, 3, 3.99), 4, 3, T(3.99)); }; TTS_CASE_TPL("Test random", rotgen::tests::types) ( tts::type< tts::types> ) { test_random(rotgen::block, 3, 3>::Random(), 3, 3); test_random(rotgen::block, 1, 1>::Random(), 1, 1); test_random(rotgen::block, 3, 4>::Random(), 3, 4); test_random(rotgen::block, rotgen::Dynamic, rotgen::Dynamic>::Random(1, 5), 1, 5); test_random(rotgen::block, 2, 1>::Random(2, 1), 2, 1); test_random(rotgen::block, rotgen::Dynamic, 9>::Random(3, 9), 3, 9); test_random(rotgen::block, 5, rotgen::Dynamic>::Random(5, 2), 5, 2); test_random(rotgen::block, 4, 3>::Random(4, 3), 4, 3); test_random(rotgen::block::Identity(3, 7)), rotgen::Dynamic, 7>::Random(3, 7), 3, 7); test_random(rotgen::block::Random(14, 15)), 4, rotgen::Dynamic>::Random(4, 11), 4, 11); }; TTS_CASE_TPL("Test identity", rotgen::tests::types) ( tts::type< tts::types> ) { test_identity(rotgen::block, 3, 3>::Identity(), 3, 3); test_identity(rotgen::block, 1, 1>::Identity(), 1, 1); test_identity(rotgen::block, 3, 4>::Identity(), 3, 4); test_identity(rotgen::block, rotgen::Dynamic, rotgen::Dynamic>::Identity(1, 5), 1, 5); test_identity(rotgen::block, 2, 1>::Identity(2, 1), 2, 1); test_identity(rotgen::block, rotgen::Dynamic, 9>::Identity(3, 9), 3, 9); test_identity(rotgen::block, 5, rotgen::Dynamic>::Identity(5, 2), 5, 2); test_identity(rotgen::block, 4, 3>::Identity(4, 3), 4, 3); test_identity(rotgen::block::Identity(3, 7)), rotgen::Dynamic, 7>::Identity(3, 7), 3, 7); test_identity(rotgen::block::Random(14, 15)), 4, rotgen::Dynamic>::Identity(4, 11), 4, 11); };