Adapt generator static functions as free functions.
This commit is contained in:
parent
fe68663ab9
commit
62802273e4
3 changed files with 223 additions and 87 deletions
|
|
@ -38,99 +38,104 @@ void test_identity(const auto& matrix, std::size_t rows, std::size_t cols)
|
|||
TTS_CASE_TPL("Test zero", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
test_value(rotgen::matrix<T, 3, 4, O::value>{}.setZero(), 3, 4, 0);
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>{}.setZero(), 1, 1, 0);
|
||||
test_value(rotgen::matrix<T, 10, 10, O::value>{}.setZero(), 10, 10, 0);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>(1,1).setZero(3,4), 3, 4, 0);
|
||||
test_value(rotgen::matrix<T, 7, 5, O::value>().setZero(7, 5), 7, 5, 0);
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>(9,1).setZero(9, 3), 9, 3, 0);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 3, O::value>(1,3).setZero(2, 3), 2, 3, 0);
|
||||
using namespace rotgen;
|
||||
test_value(setZero<matrix<T, 3, 4, O::value> >(), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 1, 1, O::value> >(), 1, 1, 0);
|
||||
test_value(setZero<matrix<T, 10, 10, O::value> >(), 10, 10, 0);
|
||||
test_value(setZero<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4, 0);
|
||||
test_value(setZero<matrix<T, 7, 5, O::value> >(7, 5), 7, 5, 0);
|
||||
test_value(setZero<matrix<T, 9,Dynamic> >(9, 3), 9, 3, 0);
|
||||
test_value(setZero<matrix<T,Dynamic, 3> >(2, 3), 2, 3, 0);
|
||||
|
||||
test_value(rotgen::matrix<T, 3, 4, O::value>::Zero(), 3, 4, 0);
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>::Zero(), 1, 1, 0);
|
||||
test_value(rotgen::matrix<T, 10, 10, O::value>::Zero(), 10, 10, 0);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>::Zero(3, 4), 3, 4, 0);
|
||||
test_value(rotgen::matrix<T, 7, 5, O::value>::Zero(7, 5), 7, 5, 0);
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>::Zero(9, 3), 9, 3, 0);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 3, O::value>::Zero(2, 3), 2, 3, 0);
|
||||
test_value(setZero(matrix<T, 3, 4, O::value>{} ), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 1, 1, O::value>{} ), 1, 1, 0);
|
||||
test_value(setZero(matrix<T, 10, 10, O::value>{} ), 10, 10, 0);
|
||||
test_value(setZero(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4, 0);
|
||||
test_value(setZero(matrix<T, 7, 5, O::value>{7, 5} ), 7, 5, 0);
|
||||
test_value(setZero(matrix<T, 9,Dynamic>{9, 3} ), 9, 3, 0);
|
||||
test_value(setZero(matrix<T,Dynamic, 3>{2, 3} ), 2, 3, 0);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test ones", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
test_value(rotgen::matrix<T, 3, 4, O::value>{}.setOnes(), 3, 4, 1);
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>{}.setOnes(), 1, 1, 1);
|
||||
test_value(rotgen::matrix<T, 10, 10, O::value>{}.setOnes(), 10, 10, 1);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>(1,1).setOnes(3, 4), 3, 4, 1);
|
||||
test_value(rotgen::matrix<T, 7, 5, O::value>{}.setOnes(7, 5), 7, 5, 1);
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>(9,1).setOnes(9, 3), 9, 3, 1);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 3, O::value>(1,3).setOnes(2, 3), 2, 3, 1);
|
||||
using namespace rotgen;
|
||||
test_value(setOnes<matrix<T, 3, 4, O::value> >(), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 1, 1, O::value> >(), 1, 1, 1);
|
||||
test_value(setOnes<matrix<T, 10, 10, O::value> >(), 10, 10, 1);
|
||||
test_value(setOnes<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4, 1);
|
||||
test_value(setOnes<matrix<T, 7, 5, O::value> >(7, 5), 7, 5, 1);
|
||||
test_value(setOnes<matrix<T, 9,Dynamic> >(9, 3), 9, 3, 1);
|
||||
test_value(setOnes<matrix<T,Dynamic, 3> >(2, 3), 2, 3, 1);
|
||||
|
||||
test_value(rotgen::matrix<T, 3, 4, O::value>::Ones(), 3, 4, 1);
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>::Ones(), 1, 1, 1);
|
||||
test_value(rotgen::matrix<T, 10, 10, O::value>::Ones(), 10, 10, 1);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>::Ones(3, 4), 3, 4, 1);
|
||||
test_value(rotgen::matrix<T, 7, 5, O::value>::Ones(7, 5), 7, 5, 1);
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>::Ones(9, 3), 9, 3, 1);
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 3, O::value>::Ones(2, 3), 2, 3, 1);
|
||||
test_value(setOnes(matrix<T, 3, 4, O::value>{} ), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 1, 1, O::value>{} ), 1, 1, 1);
|
||||
test_value(setOnes(matrix<T, 10, 10, O::value>{} ), 10, 10, 1);
|
||||
test_value(setOnes(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4, 1);
|
||||
test_value(setOnes(matrix<T, 7, 5, O::value>{7, 5} ), 7, 5, 1);
|
||||
test_value(setOnes(matrix<T, 9,Dynamic>{9, 3} ), 9, 3, 1);
|
||||
test_value(setOnes(matrix<T,Dynamic, 3>{2, 3} ), 2, 3, 1);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test constant", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
test_value(rotgen::matrix<T, 3, 8, O::value>{}.setConstant(5.12), 3, 8, T(5.12));
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>{}.setConstant(2.2), 1, 1, T(2.2));
|
||||
test_value(rotgen::matrix<T, 11, 12, O::value>{}.setConstant(13), 11, 12, T(13));
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>(1,1).setConstant(2, 7, 5.6), 2, 7, T(5.6));
|
||||
test_value(rotgen::matrix<T, 2, 2, O::value>{}.setConstant(2, 2, 2.0), 2, 2, T(2.0));
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>(9,1).setConstant(9, 3, 1.1), 9, 3, T(1.1));
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 9, O::value>(1,9).setConstant(5, 9, 42), 5, 9,T(42));
|
||||
using namespace rotgen;
|
||||
test_value(setConstant<matrix<T, 3, 4, O::value> >(T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 1, 1, O::value> >(T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant<matrix<T, 10, 10, O::value> >(T(5.12)), 10, 10, T(5.12));
|
||||
test_value(setConstant<matrix<T,Dynamic,Dynamic, O::value>>(3, 4, T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant<matrix<T, 7, 5, O::value> >(7, 5, T(5.12)), 7, 5, T(5.12));
|
||||
test_value(setConstant<matrix<T, 9,Dynamic> >(9, 3, T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant<matrix<T,Dynamic, 3> >(2, 3, T(5.12)), 2, 3, T(5.12));
|
||||
|
||||
test_value(rotgen::matrix<T, 3, 8, O::value>::Constant(5.12), 3, 8, T(5.12));
|
||||
test_value(rotgen::matrix<T, 1, 1, O::value>::Constant(2.2), 1, 1, T(2.2));
|
||||
test_value(rotgen::matrix<T, 11, 12, O::value>::Constant(13), 11, 12, T(13));
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>::Constant(2, 7, 5.6), 2, 7, T(5.6));
|
||||
test_value(rotgen::matrix<T, 2, 2, O::value>::Constant(2, 2, 2.0), 2, 2, T(2.0));
|
||||
test_value(rotgen::matrix<T, 9,rotgen::Dynamic, O::value>::Constant(9, 3, 1.1), 9, 3, T(1.1));
|
||||
test_value(rotgen::matrix<T,rotgen::Dynamic, 9, O::value>::Constant(5, 9, 42), 5, 9,T(42));
|
||||
test_value(setConstant(matrix<T, 3, 4, O::value>{} , T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 1, 1, O::value>{} , T(5.12)), 1, 1, T(5.12));
|
||||
test_value(setConstant(matrix<T, 10, 10, O::value>{} , T(5.12)), 10, 10, T(5.12));
|
||||
test_value(setConstant(matrix<T,Dynamic,Dynamic, O::value>{3, 4}, T(5.12)), 3, 4, T(5.12));
|
||||
test_value(setConstant(matrix<T, 7, 5, O::value>{7, 5} , T(5.12)), 7, 5, T(5.12));
|
||||
test_value(setConstant(matrix<T, 9,Dynamic>{9, 3} , T(5.12)), 9, 3, T(5.12));
|
||||
test_value(setConstant(matrix<T,Dynamic, 3>{2, 3} , T(5.12)), 2, 3, T(5.12));
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test random", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
test_random(rotgen::matrix<T, 2, 3, O::value>{}.setRandom(), 2, 3);
|
||||
test_random(rotgen::matrix<T, 1, 1, O::value>{}.setRandom(), 1, 1);
|
||||
test_random(rotgen::matrix<T, 11, 17, O::value>{}.setRandom(), 11, 17);
|
||||
test_random(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>{1,1}.setRandom(7, 3), 7, 3);
|
||||
test_random(rotgen::matrix<T, 2, 2, O::value>{}.setRandom(2, 2), 2, 2);
|
||||
test_random(rotgen::matrix<T, 4,rotgen::Dynamic, O::value>{4,1}.setRandom(4, 3), 4, 3);
|
||||
test_random(rotgen::matrix<T,rotgen::Dynamic, 5, O::value>{1,5}.setRandom(5, 5), 5, 5);
|
||||
using namespace rotgen;
|
||||
test_random(setRandom<matrix<T, 3, 4, O::value> >(), 3, 4);
|
||||
test_random(setRandom<matrix<T, 1, 1, O::value> >(), 1, 1);
|
||||
test_random(setRandom<matrix<T, 10, 10, O::value> >(), 10, 10);
|
||||
test_random(setRandom<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_random(setRandom<matrix<T, 7, 5, O::value> >(7, 5), 7, 5);
|
||||
test_random(setRandom<matrix<T, 9,Dynamic> >(9, 3), 9, 3);
|
||||
test_random(setRandom<matrix<T,Dynamic, 3> >(2, 3), 2, 3);
|
||||
|
||||
test_random(rotgen::matrix<T, 2, 3, O::value>::Random(), 2, 3);
|
||||
test_random(rotgen::matrix<T, 1, 1, O::value>::Random(), 1, 1);
|
||||
test_random(rotgen::matrix<T, 11, 17, O::value>::Random(), 11, 17);
|
||||
test_random(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>::Random(7, 3), 7, 3);
|
||||
test_random(rotgen::matrix<T, 2, 2, O::value>::Random(2, 2), 2, 2);
|
||||
test_random(rotgen::matrix<T, 4,rotgen::Dynamic, O::value>::Random(4, 3), 4, 3);
|
||||
test_random(rotgen::matrix<T,rotgen::Dynamic, 5, O::value>::Random(5, 5), 5, 5);
|
||||
test_random(setRandom(matrix<T, 3, 4, O::value>{} ), 3, 4);
|
||||
test_random(setRandom(matrix<T, 1, 1, O::value>{} ), 1, 1);
|
||||
test_random(setRandom(matrix<T, 10, 10, O::value>{} ), 10, 10);
|
||||
test_random(setRandom(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_random(setRandom(matrix<T, 7, 5, O::value>{7, 5} ), 7, 5);
|
||||
test_random(setRandom(matrix<T, 9,Dynamic>{9, 3} ), 9, 3);
|
||||
test_random(setRandom(matrix<T,Dynamic, 3>{2, 3} ), 2, 3);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test identity", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
test_identity(rotgen::matrix<T, 4, 5, O::value>{}.setIdentity(), 4, 5);
|
||||
test_identity(rotgen::matrix<T, 1, 1, O::value>{}.setIdentity(), 1, 1);
|
||||
test_identity(rotgen::matrix<T, 21, 3, O::value>{}.setIdentity(), 21, 3);
|
||||
test_identity(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>{1,1}.setIdentity(2, 7), 2, 7);
|
||||
test_identity(rotgen::matrix<T, 2, 2, O::value>{}.setIdentity(2, 2), 2, 2);
|
||||
test_identity(rotgen::matrix<T, 3,rotgen::Dynamic, O::value>{3,1}.setIdentity(3, 3), 3, 3);
|
||||
test_identity(rotgen::matrix<T,rotgen::Dynamic, 11, O::value>{1,11}.setIdentity(5, 11), 5, 11);
|
||||
using namespace rotgen;
|
||||
test_identity(setIdentity<matrix<T, 3, 4, O::value> >(), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 1, 1, O::value> >(), 1, 1);
|
||||
test_identity(setIdentity<matrix<T, 10, 10, O::value> >(), 10, 10);
|
||||
test_identity(setIdentity<matrix<T,Dynamic,Dynamic, O::value>>(3, 4), 3, 4);
|
||||
test_identity(setIdentity<matrix<T, 7, 5, O::value> >(7, 5), 7, 5);
|
||||
test_identity(setIdentity<matrix<T, 9,Dynamic> >(9, 3), 9, 3);
|
||||
test_identity(setIdentity<matrix<T,Dynamic, 3> >(2, 3), 2, 3);
|
||||
|
||||
test_identity(rotgen::matrix<T, 4, 5, O::value>::Identity(), 4, 5);
|
||||
test_identity(rotgen::matrix<T, 1, 1, O::value>::Identity(), 1, 1);
|
||||
test_identity(rotgen::matrix<T, 21, 3, O::value>::Identity(), 21, 3);
|
||||
test_identity(rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic, O::value>::Identity(2, 7), 2, 7);
|
||||
test_identity(rotgen::matrix<T, 2, 2, O::value>::Identity(2, 2), 2, 2);
|
||||
test_identity(rotgen::matrix<T, 3,rotgen::Dynamic, O::value>::Identity(3, 3), 3, 3);
|
||||
test_identity(rotgen::matrix<T,rotgen::Dynamic, 11, O::value>::Identity(5, 11), 5, 11);
|
||||
test_identity(setIdentity(matrix<T, 3, 4, O::value>{} ), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 1, 1, O::value>{} ), 1, 1);
|
||||
test_identity(setIdentity(matrix<T, 10, 10, O::value>{} ), 10, 10);
|
||||
test_identity(setIdentity(matrix<T,Dynamic,Dynamic, O::value>{3, 4}), 3, 4);
|
||||
test_identity(setIdentity(matrix<T, 7, 5, O::value>{7, 5} ), 7, 5);
|
||||
test_identity(setIdentity(matrix<T, 9,Dynamic>{9, 3} ), 9, 3);
|
||||
test_identity(setIdentity(matrix<T,Dynamic, 3>{2, 3} ), 2, 3);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue