kill ei_add_test_multi. Now the macro ei_add_test does all that automatically, by parsing the source file. No risk anymore to specify the wrong number of tests! Also, introduce CALL_SUBTESTX for X=1..10 that allows to port existing code much quicker. And port already the product* and eigensolver* files.

This commit is contained in:
Benoit Jacob
2009-10-19 14:40:35 -04:00
parent 580672ea43
commit 6c1b91678b
17 changed files with 189 additions and 115 deletions

View File

@@ -121,7 +121,7 @@ ei_add_test(product_notemporary ${EI_OFLAG})
ei_add_test(stable_norm)
ei_add_test(bandmatrix)
ei_add_test(cholesky " " "${GSL_LIBRARIES}")
ei_add_test_multi(6 lu ${EI_OFLAG})
ei_add_test(lu ${EI_OFLAG})
ei_add_test(determinant)
ei_add_test(inverse ${EI_OFLAG})
ei_add_test(qr)

View File

@@ -54,8 +54,8 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
void test_eigensolver_complex()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( eigensolver(Matrix4cf()) );
CALL_SUBTEST( eigensolver(MatrixXcd(14,14)) );
CALL_SUBTEST1( eigensolver(Matrix4cf()) );
CALL_SUBTEST2( eigensolver(MatrixXcd(14,14)) );
}
}

View File

@@ -75,18 +75,18 @@ template<typename MatrixType> void eigensolver_verify_assert()
void test_eigensolver_generic()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( eigensolver(Matrix4f()) );
CALL_SUBTEST( eigensolver(MatrixXd(17,17)) );
CALL_SUBTEST1( eigensolver(Matrix4f()) );
CALL_SUBTEST2( eigensolver(MatrixXd(17,17)) );
// some trivial but implementation-wise tricky cases
CALL_SUBTEST( eigensolver(MatrixXd(1,1)) );
CALL_SUBTEST( eigensolver(MatrixXd(2,2)) );
CALL_SUBTEST( eigensolver(Matrix<double,1,1>()) );
CALL_SUBTEST( eigensolver(Matrix<double,2,2>()) );
CALL_SUBTEST2( eigensolver(MatrixXd(1,1)) );
CALL_SUBTEST2( eigensolver(MatrixXd(2,2)) );
CALL_SUBTEST3( eigensolver(Matrix<double,1,1>()) );
CALL_SUBTEST4( eigensolver(Matrix2d()) );
}
CALL_SUBTEST( eigensolver_verify_assert<Matrix3f>() );
CALL_SUBTEST( eigensolver_verify_assert<Matrix3d>() );
CALL_SUBTEST( eigensolver_verify_assert<MatrixXf>() );
CALL_SUBTEST( eigensolver_verify_assert<MatrixXd>() );
CALL_SUBTEST1( eigensolver_verify_assert<Matrix4f>() );
CALL_SUBTEST2( eigensolver_verify_assert<MatrixXd>() );
CALL_SUBTEST4( eigensolver_verify_assert<Matrix2d>() );
CALL_SUBTEST5( eigensolver_verify_assert<MatrixXf>() );
}

View File

@@ -117,17 +117,17 @@ void test_eigensolver_selfadjoint()
{
for(int i = 0; i < g_repeat; i++) {
// very important to test a 3x3 matrix since we provide a special path for it
CALL_SUBTEST( selfadjointeigensolver(Matrix3f()) );
CALL_SUBTEST( selfadjointeigensolver(Matrix4d()) );
CALL_SUBTEST( selfadjointeigensolver(MatrixXf(10,10)) );
CALL_SUBTEST( selfadjointeigensolver(MatrixXd(19,19)) );
CALL_SUBTEST( selfadjointeigensolver(MatrixXcd(17,17)) );
CALL_SUBTEST1( selfadjointeigensolver(Matrix3f()) );
CALL_SUBTEST2( selfadjointeigensolver(Matrix4d()) );
CALL_SUBTEST3( selfadjointeigensolver(MatrixXf(10,10)) );
CALL_SUBTEST4( selfadjointeigensolver(MatrixXd(19,19)) );
CALL_SUBTEST5( selfadjointeigensolver(MatrixXcd(17,17)) );
// some trivial but implementation-wise tricky cases
CALL_SUBTEST( selfadjointeigensolver(MatrixXd(1,1)) );
CALL_SUBTEST( selfadjointeigensolver(MatrixXd(2,2)) );
CALL_SUBTEST( selfadjointeigensolver(Matrix<double,1,1>()) );
CALL_SUBTEST( selfadjointeigensolver(Matrix<double,2,2>()) );
CALL_SUBTEST4( selfadjointeigensolver(MatrixXd(1,1)) );
CALL_SUBTEST4( selfadjointeigensolver(MatrixXd(2,2)) );
CALL_SUBTEST6( selfadjointeigensolver(Matrix<double,1,1>()) );
CALL_SUBTEST7( selfadjointeigensolver(Matrix<double,2,2>()) );
}
}

View File

@@ -153,28 +153,26 @@ template<typename MatrixType> void lu_verify_assert()
void test_lu()
{
for(int i = 0; i < g_repeat; i++) {
#if defined EIGEN_TEST_PART_1
CALL_SUBTEST( lu_non_invertible<Matrix3f>() );
CALL_SUBTEST( lu_verify_assert<Matrix3f>() );
#elif defined EIGEN_TEST_PART_2
CALL_SUBTEST( (lu_non_invertible<Matrix<double, 4, 6> >()) );
CALL_SUBTEST( (lu_verify_assert<Matrix<double, 4, 6> >()) );
#elif defined EIGEN_TEST_PART_3
CALL_SUBTEST( lu_non_invertible<MatrixXf>() );
CALL_SUBTEST( lu_invertible<MatrixXf>() );
CALL_SUBTEST( lu_verify_assert<MatrixXf>() );
#elif defined EIGEN_TEST_PART_4
CALL_SUBTEST( lu_non_invertible<MatrixXd>() );
CALL_SUBTEST( lu_invertible<MatrixXd>() );
CALL_SUBTEST( lu_verify_assert<MatrixXd>() );
#elif defined EIGEN_TEST_PART_5
CALL_SUBTEST( lu_non_invertible<MatrixXcf>() );
CALL_SUBTEST( lu_invertible<MatrixXcf>() );
CALL_SUBTEST( lu_verify_assert<MatrixXcf>() );
#elif defined EIGEN_TEST_PART_6
CALL_SUBTEST( lu_non_invertible<MatrixXcd>() );
CALL_SUBTEST( lu_invertible<MatrixXcd>() );
CALL_SUBTEST( lu_verify_assert<MatrixXcd>() );
#endif
CALL_SUBTEST1( lu_non_invertible<Matrix3f>() );
CALL_SUBTEST1( lu_verify_assert<Matrix3f>() );
CALL_SUBTEST2( (lu_non_invertible<Matrix<double, 4, 6> >()) );
CALL_SUBTEST2( (lu_verify_assert<Matrix<double, 4, 6> >()) );
CALL_SUBTEST3( lu_non_invertible<MatrixXf>() );
CALL_SUBTEST3( lu_invertible<MatrixXf>() );
CALL_SUBTEST3( lu_verify_assert<MatrixXf>() );
CALL_SUBTEST4( lu_non_invertible<MatrixXd>() );
CALL_SUBTEST4( lu_invertible<MatrixXd>() );
CALL_SUBTEST4( lu_verify_assert<MatrixXd>() );
CALL_SUBTEST5( lu_non_invertible<MatrixXcf>() );
CALL_SUBTEST5( lu_invertible<MatrixXcf>() );
CALL_SUBTEST5( lu_verify_assert<MatrixXcf>() );
CALL_SUBTEST6( lu_non_invertible<MatrixXcd>() );
CALL_SUBTEST6( lu_invertible<MatrixXcd>() );
CALL_SUBTEST6( lu_verify_assert<MatrixXcd>() );
}
}

View File

@@ -170,6 +170,66 @@ namespace Eigen
g_test_stack.pop_back(); \
} while (0)
#ifdef EIGEN_TEST_PART_1
#define CALL_SUBTEST1(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST1(FUNC)
#endif
#ifdef EIGEN_TEST_PART_2
#define CALL_SUBTEST2(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST2(FUNC)
#endif
#ifdef EIGEN_TEST_PART_3
#define CALL_SUBTEST3(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST3(FUNC)
#endif
#ifdef EIGEN_TEST_PART_4
#define CALL_SUBTEST4(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST4(FUNC)
#endif
#ifdef EIGEN_TEST_PART_5
#define CALL_SUBTEST5(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST5(FUNC)
#endif
#ifdef EIGEN_TEST_PART_6
#define CALL_SUBTEST6(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST6(FUNC)
#endif
#ifdef EIGEN_TEST_PART_7
#define CALL_SUBTEST7(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST7(FUNC)
#endif
#ifdef EIGEN_TEST_PART_8
#define CALL_SUBTEST8(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST8(FUNC)
#endif
#ifdef EIGEN_TEST_PART_9
#define CALL_SUBTEST9(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST9(FUNC)
#endif
#ifdef EIGEN_TEST_PART_10
#define CALL_SUBTEST10(FUNC) CALL_SUBTEST(FUNC)
#else
#define CALL_SUBTEST10(FUNC)
#endif
namespace Eigen {
template<typename T> inline typename NumTraits<T>::Real test_precision();

View File

@@ -119,8 +119,8 @@ template<typename MatrixType> void product_extra(const MatrixType& m)
void test_product_extra()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( product_extra(MatrixXf(ei_random<int>(2,320), ei_random<int>(2,320))) );
CALL_SUBTEST( product_extra(MatrixXcf(ei_random<int>(50,50), ei_random<int>(50,50))) );
CALL_SUBTEST( product_extra(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(ei_random<int>(2,50), ei_random<int>(2,50))) );
CALL_SUBTEST1( product_extra(MatrixXf(ei_random<int>(2,320), ei_random<int>(2,320))) );
CALL_SUBTEST2( product_extra(MatrixXcf(ei_random<int>(50,50), ei_random<int>(50,50))) );
CALL_SUBTEST3( product_extra(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(ei_random<int>(2,50), ei_random<int>(2,50))) );
}
}

View File

@@ -27,13 +27,14 @@
void test_product_large()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) );
CALL_SUBTEST( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST1( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST2( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST3( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) );
CALL_SUBTEST4( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) );
CALL_SUBTEST5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) );
}
#if defined EIGEN_TEST_PART_6
{
// test a specific issue in DiagonalProduct
int N = 1000000;
@@ -48,4 +49,5 @@ void test_product_large()
MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
VERIFY_IS_APPROX((a = a * b), (c * b).eval());
}
#endif
}

View File

@@ -117,8 +117,8 @@ void test_product_notemporary()
int s;
for(int i = 0; i < g_repeat; i++) {
s = ei_random<int>(16,320);
CALL_SUBTEST( product_notemporary(MatrixXf(s, s)) );
CALL_SUBTEST1( product_notemporary(MatrixXf(s, s)) );
s = ei_random<int>(16,120);
CALL_SUBTEST( product_notemporary(MatrixXcd(s,s)) );
CALL_SUBTEST2( product_notemporary(MatrixXcd(s,s)) );
}
}

View File

@@ -78,13 +78,13 @@ template<typename MatrixType> void product_selfadjoint(const MatrixType& m)
void test_product_selfadjoint()
{
for(int i = 0; i < g_repeat ; i++) {
CALL_SUBTEST( product_selfadjoint(Matrix<float, 1, 1>()) );
CALL_SUBTEST( product_selfadjoint(Matrix<float, 2, 2>()) );
CALL_SUBTEST( product_selfadjoint(Matrix3d()) );
CALL_SUBTEST( product_selfadjoint(MatrixXcf(4, 4)) );
CALL_SUBTEST( product_selfadjoint(MatrixXcd(21,21)) );
CALL_SUBTEST( product_selfadjoint(MatrixXd(14,14)) );
CALL_SUBTEST( product_selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(17,17)) );
CALL_SUBTEST( product_selfadjoint(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(19, 19)) );
CALL_SUBTEST1( product_selfadjoint(Matrix<float, 1, 1>()) );
CALL_SUBTEST2( product_selfadjoint(Matrix<float, 2, 2>()) );
CALL_SUBTEST3( product_selfadjoint(Matrix3d()) );
CALL_SUBTEST4( product_selfadjoint(MatrixXcf(4, 4)) );
CALL_SUBTEST5( product_selfadjoint(MatrixXcd(21,21)) );
CALL_SUBTEST6( product_selfadjoint(MatrixXd(14,14)) );
CALL_SUBTEST7( product_selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(17,17)) );
CALL_SUBTEST8( product_selfadjoint(Matrix<std::complex<double>,Dynamic,Dynamic,RowMajor>(19, 19)) );
}
}

View File

@@ -28,16 +28,18 @@
void test_product_small()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( product(Matrix<float, 3, 2>()) );
CALL_SUBTEST( product(Matrix<int, 3, 5>()) );
CALL_SUBTEST( product(Matrix3d()) );
CALL_SUBTEST( product(Matrix4d()) );
CALL_SUBTEST( product(Matrix4f()) );
CALL_SUBTEST1( product(Matrix<float, 3, 2>()) );
CALL_SUBTEST2( product(Matrix<int, 3, 5>()) );
CALL_SUBTEST3( product(Matrix3d()) );
CALL_SUBTEST4( product(Matrix4d()) );
CALL_SUBTEST5( product(Matrix4f()) );
}
#ifdef EIGEN_TEST_PART_6
{
// test compilation of (outer_product) * vector
Vector3f v = Vector3f::Random();
VERIFY_IS_APPROX( (v * v.transpose()) * v, (v * v.transpose()).eval() * v);
}
#endif
}

View File

@@ -108,10 +108,10 @@ void test_product_symm()
{
for(int i = 0; i < g_repeat ; i++)
{
CALL_SUBTEST(( symm<float,Dynamic,Dynamic>(ei_random<int>(10,320),ei_random<int>(10,320)) ));
CALL_SUBTEST(( symm<std::complex<double>,Dynamic,Dynamic>(ei_random<int>(10,320),ei_random<int>(10,320)) ));
CALL_SUBTEST1(( symm<float,Dynamic,Dynamic>(ei_random<int>(10,320),ei_random<int>(10,320)) ));
CALL_SUBTEST2(( symm<std::complex<double>,Dynamic,Dynamic>(ei_random<int>(10,320),ei_random<int>(10,320)) ));
CALL_SUBTEST(( symm<float,Dynamic,1>(ei_random<int>(10,320)) ));
CALL_SUBTEST(( symm<std::complex<double>,Dynamic,1>(ei_random<int>(10,320)) ));
CALL_SUBTEST3(( symm<float,Dynamic,1>(ei_random<int>(10,320)) ));
CALL_SUBTEST4(( symm<std::complex<double>,Dynamic,1>(ei_random<int>(10,320)) ));
}
}

View File

@@ -75,8 +75,8 @@ void test_product_syrk()
{
int s;
s = ei_random<int>(10,320);
CALL_SUBTEST( syrk(MatrixXf(s, s)) );
CALL_SUBTEST1( syrk(MatrixXf(s, s)) );
s = ei_random<int>(10,320);
CALL_SUBTEST( syrk(MatrixXcd(s, s)) );
CALL_SUBTEST2( syrk(MatrixXcd(s, s)) );
}
}

View File

@@ -63,7 +63,7 @@ void test_product_trmm()
{
for(int i = 0; i < g_repeat ; i++)
{
trmm<float>(ei_random<int>(1,320),ei_random<int>(1,320));
trmm<std::complex<double> >(ei_random<int>(1,320),ei_random<int>(1,320));
CALL_SUBTEST1((trmm<float>(ei_random<int>(1,320),ei_random<int>(1,320))));
CALL_SUBTEST2((trmm<std::complex<double> >(ei_random<int>(1,320),ei_random<int>(1,320))));
}
}

View File

@@ -82,11 +82,11 @@ template<typename MatrixType> void trmv(const MatrixType& m)
void test_product_trmv()
{
for(int i = 0; i < g_repeat ; i++) {
CALL_SUBTEST( trmv(Matrix<float, 1, 1>()) );
CALL_SUBTEST( trmv(Matrix<float, 2, 2>()) );
CALL_SUBTEST( trmv(Matrix3d()) );
CALL_SUBTEST( trmv(Matrix<std::complex<float>,23, 23>()) );
CALL_SUBTEST( trmv(MatrixXcd(17,17)) );
CALL_SUBTEST( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(19, 19)) );
CALL_SUBTEST1( trmv(Matrix<float, 1, 1>()) );
CALL_SUBTEST2( trmv(Matrix<float, 2, 2>()) );
CALL_SUBTEST3( trmv(Matrix3d()) );
CALL_SUBTEST4( trmv(Matrix<std::complex<float>,23, 23>()) );
CALL_SUBTEST5( trmv(MatrixXcd(17,17)) );
CALL_SUBTEST6( trmv(Matrix<float,Dynamic,Dynamic,RowMajor>(19, 19)) );
}
}

View File

@@ -59,7 +59,7 @@ void test_product_trsm()
{
for(int i = 0; i < g_repeat ; i++)
{
trsm<float>(ei_random<int>(1,320),ei_random<int>(1,320));
trsm<std::complex<double> >(ei_random<int>(1,320),ei_random<int>(1,320));
CALL_SUBTEST1((trsm<float>(ei_random<int>(1,320),ei_random<int>(1,320))));
CALL_SUBTEST2((trsm<std::complex<double> >(ei_random<int>(1,320),ei_random<int>(1,320))));
}
}