//================================================================================================== /* 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, std::size_t rows, std::size_t cols, auto constant) { TTS_EXPECT(verify_rotgen_reentrance(matrix)); for(std::size_t r=0;r( tts::type< tts::types> ) { test_value(rotgen::matrix{}.setZero(), 3, 4, 0); test_value(rotgen::matrix{}.setZero(), 1, 1, 0); test_value(rotgen::matrix{}.setZero(), 10, 10, 0); test_value(rotgen::matrix(1,1).setZero(3,4), 3, 4, 0); test_value(rotgen::matrix().setZero(7, 5), 7, 5, 0); test_value(rotgen::matrix(9,1).setZero(9, 3), 9, 3, 0); test_value(rotgen::matrix(1,3).setZero(2, 3), 2, 3, 0); test_value(rotgen::matrix::Zero(), 3, 4, 0); test_value(rotgen::matrix::Zero(), 1, 1, 0); test_value(rotgen::matrix::Zero(), 10, 10, 0); test_value(rotgen::matrix::Zero(3, 4), 3, 4, 0); test_value(rotgen::matrix::Zero(7, 5), 7, 5, 0); test_value(rotgen::matrix::Zero(9, 3), 9, 3, 0); test_value(rotgen::matrix::Zero(2, 3), 2, 3, 0); }; TTS_CASE_TPL("Test ones", rotgen::tests::types) ( tts::type< tts::types> ) { test_value(rotgen::matrix{}.setOnes(), 3, 4, 1); test_value(rotgen::matrix{}.setOnes(), 1, 1, 1); test_value(rotgen::matrix{}.setOnes(), 10, 10, 1); test_value(rotgen::matrix(1,1).setOnes(3, 4), 3, 4, 1); test_value(rotgen::matrix{}.setOnes(7, 5), 7, 5, 1); test_value(rotgen::matrix(9,1).setOnes(9, 3), 9, 3, 1); test_value(rotgen::matrix(1,3).setOnes(2, 3), 2, 3, 1); test_value(rotgen::matrix::Ones(), 3, 4, 1); test_value(rotgen::matrix::Ones(), 1, 1, 1); test_value(rotgen::matrix::Ones(), 10, 10, 1); test_value(rotgen::matrix::Ones(3, 4), 3, 4, 1); test_value(rotgen::matrix::Ones(7, 5), 7, 5, 1); test_value(rotgen::matrix::Ones(9, 3), 9, 3, 1); test_value(rotgen::matrix::Ones(2, 3), 2, 3, 1); }; TTS_CASE_TPL("Test constant", rotgen::tests::types) ( tts::type< tts::types> ) { test_value(rotgen::matrix{}.setConstant(5.12), 3, 8, T(5.12)); test_value(rotgen::matrix{}.setConstant(2.2), 1, 1, T(2.2)); test_value(rotgen::matrix{}.setConstant(13), 11, 12, T(13)); test_value(rotgen::matrix(1,1).setConstant(2, 7, 5.6), 2, 7, T(5.6)); test_value(rotgen::matrix{}.setConstant(2, 2, 2.0), 2, 2, T(2.0)); test_value(rotgen::matrix(9,1).setConstant(9, 3, 1.1), 9, 3, T(1.1)); test_value(rotgen::matrix(1,9).setConstant(5, 9, 42), 5, 9,T(42)); test_value(rotgen::matrix::Constant(5.12), 3, 8, T(5.12)); test_value(rotgen::matrix::Constant(2.2), 1, 1, T(2.2)); test_value(rotgen::matrix::Constant(13), 11, 12, T(13)); test_value(rotgen::matrix::Constant(2, 7, 5.6), 2, 7, T(5.6)); test_value(rotgen::matrix::Constant(2, 2, 2.0), 2, 2, T(2.0)); test_value(rotgen::matrix::Constant(9, 3, 1.1), 9, 3, T(1.1)); test_value(rotgen::matrix::Constant(5, 9, 42), 5, 9,T(42)); }; TTS_CASE_TPL("Test random", rotgen::tests::types) ( tts::type< tts::types> ) { test_random(rotgen::matrix{}.setRandom(), 2, 3); test_random(rotgen::matrix{}.setRandom(), 1, 1); test_random(rotgen::matrix{}.setRandom(), 11, 17); test_random(rotgen::matrix{1,1}.setRandom(7, 3), 7, 3); test_random(rotgen::matrix{}.setRandom(2, 2), 2, 2); test_random(rotgen::matrix{4,1}.setRandom(4, 3), 4, 3); test_random(rotgen::matrix{1,5}.setRandom(5, 5), 5, 5); test_random(rotgen::matrix::Random(), 2, 3); test_random(rotgen::matrix::Random(), 1, 1); test_random(rotgen::matrix::Random(), 11, 17); test_random(rotgen::matrix::Random(7, 3), 7, 3); test_random(rotgen::matrix::Random(2, 2), 2, 2); test_random(rotgen::matrix::Random(4, 3), 4, 3); test_random(rotgen::matrix::Random(5, 5), 5, 5); }; TTS_CASE_TPL("Test identity", rotgen::tests::types) ( tts::type< tts::types> ) { test_identity(rotgen::matrix{}.setIdentity(), 4, 5); test_identity(rotgen::matrix{}.setIdentity(), 1, 1); test_identity(rotgen::matrix{}.setIdentity(), 21, 3); test_identity(rotgen::matrix{1,1}.setIdentity(2, 7), 2, 7); test_identity(rotgen::matrix{}.setIdentity(2, 2), 2, 2); test_identity(rotgen::matrix{3,1}.setIdentity(3, 3), 3, 3); test_identity(rotgen::matrix{1,11}.setIdentity(5, 11), 5, 11); test_identity(rotgen::matrix::Identity(), 4, 5); test_identity(rotgen::matrix::Identity(), 1, 1); test_identity(rotgen::matrix::Identity(), 21, 3); test_identity(rotgen::matrix::Identity(2, 7), 2, 7); test_identity(rotgen::matrix::Identity(2, 2), 2, 2); test_identity(rotgen::matrix::Identity(3, 3), 3, 3); test_identity(rotgen::matrix::Identity(5, 11), 5, 11); };