From 6d4221af76cf1a9abd2be3c65e649883fe7769d5 Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Mon, 23 Jan 2023 22:23:08 +0000 Subject: [PATCH] Revert qr tests --- test/qr_colpivoting.cpp | 102 ++++++++++++++++++--------------------- test/qr_fullpivoting.cpp | 56 +++++++++++---------- 2 files changed, 74 insertions(+), 84 deletions(-) diff --git a/test/qr_colpivoting.cpp b/test/qr_colpivoting.cpp index 27ef33ab9..b0cc000eb 100644 --- a/test/qr_colpivoting.cpp +++ b/test/qr_colpivoting.cpp @@ -13,7 +13,7 @@ #include #include "solverbase.h" -template +template void cod() { Index rows = internal::random(2, EIGEN_TEST_MAX_SIZE); @@ -27,7 +27,7 @@ void cod() { MatrixQType; MatrixType matrix; createRandomPIMatrixOfRank(rank, rows, cols, matrix); - CompleteOrthogonalDecomposition cod(matrix); + CompleteOrthogonalDecomposition cod(matrix); VERIFY(rank == cod.rank()); VERIFY(cols - cod.rank() == cod.dimensionOfKernel()); VERIFY(!cod.isInjective()); @@ -62,14 +62,14 @@ void cod() { VERIFY_IS_APPROX(cod_solution, pinv * rhs); } -template +template void cod_fixedsize() { enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; - typedef CompleteOrthogonalDecomposition, PermutationIndex> COD; + typedef CompleteOrthogonalDecomposition > COD; int rank = internal::random(1, (std::min)(int(Rows), int(Cols)) - 1); Matrix matrix; createRandomPIMatrixOfRank(rank, Rows, Cols, matrix); @@ -95,7 +95,7 @@ void cod_fixedsize() { VERIFY_IS_APPROX(cod_solution, pinv * rhs); } -template void qr() +template void qr() { using std::sqrt; @@ -107,7 +107,7 @@ template void qr() typedef Matrix MatrixQType; MatrixType m1; createRandomPIMatrixOfRank(rank,rows,cols,m1); - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(cols - qr.rank(), qr.dimensionOfKernel()); VERIFY(!qr.isInjective()); @@ -155,7 +155,7 @@ template void qr() } } -template void qr_fixedsize() +template void qr_fixedsize() { using std::sqrt; using std::abs; @@ -165,7 +165,7 @@ template void qr_fixe int rank = internal::random(1, (std::min)(int(Rows), int(Cols))-1); Matrix m1; createRandomPIMatrixOfRank(rank,Rows,Cols,m1); - ColPivHouseholderQR, PermutationIndex> qr(m1); + ColPivHouseholderQR > qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(Cols - qr.rank(), qr.dimensionOfKernel()); VERIFY_IS_EQUAL(qr.isInjective(), (rank == Rows)); @@ -204,7 +204,7 @@ template void qr_fixe // for rank-revealing QR. See // http://www.netlib.org/lapack/lawnspdf/lawn176.pdf // page 3 for more detail. -template void qr_kahan_matrix() +template void qr_kahan_matrix() { using std::sqrt; using std::abs; @@ -224,7 +224,7 @@ template void qr_kahan_matrix() pow_s_i *= s; } m1 = (m1 + m1.transpose()).eval(); - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); MatrixType r = qr.matrixQR().template triangularView(); RealScalar threshold = @@ -244,7 +244,7 @@ template void qr_kahan_matrix() } } -template void qr_invertible() +template void qr_invertible() { using std::log; using std::abs; @@ -263,7 +263,7 @@ template void qr_invertible() m1 += a * a.adjoint(); } - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); check_solverbase(m1, qr, size, size, size); @@ -280,11 +280,11 @@ template void qr_invertible() VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant()); } -template void qr_verify_assert() +template void qr_verify_assert() { MatrixType tmp; - ColPivHouseholderQR qr; + ColPivHouseholderQR qr; VERIFY_RAISES_ASSERT(qr.matrixQR()) VERIFY_RAISES_ASSERT(qr.solve(tmp)) VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp)) @@ -300,11 +300,11 @@ template void qr_verify_assert() VERIFY_RAISES_ASSERT(qr.logAbsDeterminant()) } -template void cod_verify_assert() +template void cod_verify_assert() { MatrixType tmp; - CompleteOrthogonalDecomposition cod; + CompleteOrthogonalDecomposition cod; VERIFY_RAISES_ASSERT(cod.matrixQTZ()) VERIFY_RAISES_ASSERT(cod.solve(tmp)) VERIFY_RAISES_ASSERT(cod.transpose().solve(tmp)) @@ -320,58 +320,50 @@ template void cod_verify_assert( VERIFY_RAISES_ASSERT(cod.logAbsDeterminant()) } - - EIGEN_DECLARE_TEST(qr_colpivoting) { - #if defined(EIGEN_USE_LAPACKE) - typedef lapack_int PermutationIndex; - #else - typedef int PermutationIndex; - #endif - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( (qr)() ); - CALL_SUBTEST_2( (qr)() ); - CALL_SUBTEST_3( (qr)() ); - CALL_SUBTEST_4(( (qr_fixedsize, PermutationIndex, 4>)() )); - CALL_SUBTEST_5(( (qr_fixedsize, PermutationIndex, 3>)() )); - CALL_SUBTEST_5(( (qr_fixedsize, PermutationIndex, 1>)() )); + CALL_SUBTEST_1( qr() ); + CALL_SUBTEST_2( qr() ); + CALL_SUBTEST_3( qr() ); + CALL_SUBTEST_4(( qr_fixedsize, 4 >() )); + CALL_SUBTEST_5(( qr_fixedsize, 3 >() )); + CALL_SUBTEST_5(( qr_fixedsize, 1 >() )); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( (cod)() ); - CALL_SUBTEST_2( (cod)() ); - CALL_SUBTEST_3( (cod)() ); - CALL_SUBTEST_4(( (cod_fixedsize, PermutationIndex, 4>)() )); - CALL_SUBTEST_5(( (cod_fixedsize, PermutationIndex, 3>)() )); - CALL_SUBTEST_5(( (cod_fixedsize, PermutationIndex, 1>)() )); + CALL_SUBTEST_1( cod() ); + CALL_SUBTEST_2( cod() ); + CALL_SUBTEST_3( cod() ); + CALL_SUBTEST_4(( cod_fixedsize, 4 >() )); + CALL_SUBTEST_5(( cod_fixedsize, 3 >() )); + CALL_SUBTEST_5(( cod_fixedsize, 1 >() )); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( (qr_invertible)() ); - CALL_SUBTEST_2( (qr_invertible)() ); - CALL_SUBTEST_6( (qr_invertible)() ); - CALL_SUBTEST_3( (qr_invertible)() ); + CALL_SUBTEST_1( qr_invertible() ); + CALL_SUBTEST_2( qr_invertible() ); + CALL_SUBTEST_6( qr_invertible() ); + CALL_SUBTEST_3( qr_invertible() ); } - CALL_SUBTEST_7( (qr_verify_assert) ()); - CALL_SUBTEST_8( (qr_verify_assert)()); - CALL_SUBTEST_1( (qr_verify_assert)()); - CALL_SUBTEST_2( (qr_verify_assert)()); - CALL_SUBTEST_6( (qr_verify_assert)()); - CALL_SUBTEST_3( (qr_verify_assert)()); + CALL_SUBTEST_7(qr_verify_assert()); + CALL_SUBTEST_8(qr_verify_assert()); + CALL_SUBTEST_1(qr_verify_assert()); + CALL_SUBTEST_2(qr_verify_assert()); + CALL_SUBTEST_6(qr_verify_assert()); + CALL_SUBTEST_3(qr_verify_assert()); - CALL_SUBTEST_7( (cod_verify_assert)()); - CALL_SUBTEST_8( (cod_verify_assert)()); - CALL_SUBTEST_1( (cod_verify_assert)()); - CALL_SUBTEST_2( (cod_verify_assert)()); - CALL_SUBTEST_6( (cod_verify_assert)()); - CALL_SUBTEST_3( (cod_verify_assert)()); + CALL_SUBTEST_7(cod_verify_assert()); + CALL_SUBTEST_8(cod_verify_assert()); + CALL_SUBTEST_1(cod_verify_assert()); + CALL_SUBTEST_2(cod_verify_assert()); + CALL_SUBTEST_6(cod_verify_assert()); + CALL_SUBTEST_3(cod_verify_assert()); // Test problem size constructors - CALL_SUBTEST_9((ColPivHouseholderQR(10, 20))); + CALL_SUBTEST_9(ColPivHouseholderQR(10, 20)); - CALL_SUBTEST_1( (qr_kahan_matrix)() ); - CALL_SUBTEST_2( (qr_kahan_matrix)() ); + CALL_SUBTEST_1( qr_kahan_matrix() ); + CALL_SUBTEST_2( qr_kahan_matrix() ); } diff --git a/test/qr_fullpivoting.cpp b/test/qr_fullpivoting.cpp index c0f44ae2e..bd408811a 100644 --- a/test/qr_fullpivoting.cpp +++ b/test/qr_fullpivoting.cpp @@ -12,7 +12,7 @@ #include #include "solverbase.h" -template void qr() +template void qr() { static const int Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime; @@ -27,7 +27,7 @@ template void qr() typedef Matrix MatrixQType; MatrixType m1; createRandomPIMatrixOfRank(rank,rows,cols,m1); - FullPivHouseholderQR qr(m1); + FullPivHouseholderQR qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(cols - qr.rank(), qr.dimensionOfKernel()); VERIFY(!qr.isInjective()); @@ -66,7 +66,7 @@ template void qr() } } -template void qr_invertible() +template void qr_invertible() { using std::log; using std::abs; @@ -87,7 +87,7 @@ template void qr_invertible() m1 += a * a.adjoint(); } - FullPivHouseholderQR qr(m1); + FullPivHouseholderQR qr(m1); VERIFY(qr.isInjective()); VERIFY(qr.isInvertible()); VERIFY(qr.isSurjective()); @@ -107,11 +107,11 @@ template void qr_invertible() VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant()); } -template void qr_verify_assert() +template void qr_verify_assert() { MatrixType tmp; - FullPivHouseholderQR qr; + FullPivHouseholderQR qr; VERIFY_RAISES_ASSERT(qr.matrixQR()) VERIFY_RAISES_ASSERT(qr.solve(tmp)) VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp)) @@ -129,35 +129,33 @@ template void qr_verify_assert() EIGEN_DECLARE_TEST(qr_fullpivoting) { - typedef int PermutationIndex; - for(int i = 0; i < 1; i++) { - CALL_SUBTEST_5( (qr()) ); - CALL_SUBTEST_6( (qr()) ); - CALL_SUBTEST_8( (qr()) ); - CALL_SUBTEST_1( (qr()) ); - CALL_SUBTEST_2( (qr()) ); - CALL_SUBTEST_3( (qr()) ); + CALL_SUBTEST_5( qr() ); + CALL_SUBTEST_6( qr() ); + CALL_SUBTEST_8( qr() ); + CALL_SUBTEST_1( qr() ); + CALL_SUBTEST_2( qr() ); + CALL_SUBTEST_3( qr() ); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( (qr_invertible()) ); - CALL_SUBTEST_2( (qr_invertible()) ); - CALL_SUBTEST_4( (qr_invertible()) ); - CALL_SUBTEST_3( (qr_invertible()) ); + CALL_SUBTEST_1( qr_invertible() ); + CALL_SUBTEST_2( qr_invertible() ); + CALL_SUBTEST_4( qr_invertible() ); + CALL_SUBTEST_3( qr_invertible() ); } - CALL_SUBTEST_5( (qr_verify_assert()) ); - CALL_SUBTEST_6( (qr_verify_assert()) ); - CALL_SUBTEST_1( (qr_verify_assert()) ); - CALL_SUBTEST_2( (qr_verify_assert()) ); - CALL_SUBTEST_4( (qr_verify_assert()) ); - CALL_SUBTEST_3( (qr_verify_assert()) ); + CALL_SUBTEST_5(qr_verify_assert()); + CALL_SUBTEST_6(qr_verify_assert()); + CALL_SUBTEST_1(qr_verify_assert()); + CALL_SUBTEST_2(qr_verify_assert()); + CALL_SUBTEST_4(qr_verify_assert()); + CALL_SUBTEST_3(qr_verify_assert()); // Test problem size constructors - CALL_SUBTEST_7( (FullPivHouseholderQR(10, 20))); - CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(10, 20))); - CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(Matrix::Random()))); - CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(20, 10))); - CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(Matrix::Random()))); + CALL_SUBTEST_7(FullPivHouseholderQR(10, 20)); + CALL_SUBTEST_7((FullPivHouseholderQR >(10,20))); + CALL_SUBTEST_7((FullPivHouseholderQR >(Matrix::Random()))); + CALL_SUBTEST_7((FullPivHouseholderQR >(20,10))); + CALL_SUBTEST_7((FullPivHouseholderQR >(Matrix::Random()))); }