Revert qr tests

This commit is contained in:
Charles Schlosser
2023-01-23 22:23:08 +00:00
committed by Rasmus Munk Larsen
parent 7f58bc98b1
commit 6d4221af76
2 changed files with 74 additions and 84 deletions

View File

@@ -12,7 +12,7 @@
#include <Eigen/QR>
#include "solverbase.h"
template<typename MatrixType, typename PermutationIndex> void qr()
template<typename MatrixType> void qr()
{
static const int Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime;
@@ -27,7 +27,7 @@ template<typename MatrixType, typename PermutationIndex> void qr()
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> MatrixQType;
MatrixType m1;
createRandomPIMatrixOfRank(rank,rows,cols,m1);
FullPivHouseholderQR<MatrixType, PermutationIndex> qr(m1);
FullPivHouseholderQR<MatrixType> qr(m1);
VERIFY_IS_EQUAL(rank, qr.rank());
VERIFY_IS_EQUAL(cols - qr.rank(), qr.dimensionOfKernel());
VERIFY(!qr.isInjective());
@@ -66,7 +66,7 @@ template<typename MatrixType, typename PermutationIndex> void qr()
}
}
template<typename MatrixType, typename PermutationIndex> void qr_invertible()
template<typename MatrixType> void qr_invertible()
{
using std::log;
using std::abs;
@@ -87,7 +87,7 @@ template<typename MatrixType, typename PermutationIndex> void qr_invertible()
m1 += a * a.adjoint();
}
FullPivHouseholderQR<MatrixType, PermutationIndex> qr(m1);
FullPivHouseholderQR<MatrixType> qr(m1);
VERIFY(qr.isInjective());
VERIFY(qr.isInvertible());
VERIFY(qr.isSurjective());
@@ -107,11 +107,11 @@ template<typename MatrixType, typename PermutationIndex> void qr_invertible()
VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant());
}
template<typename MatrixType, typename PermutationIndex> void qr_verify_assert()
template<typename MatrixType> void qr_verify_assert()
{
MatrixType tmp;
FullPivHouseholderQR<MatrixType, PermutationIndex> qr;
FullPivHouseholderQR<MatrixType> qr;
VERIFY_RAISES_ASSERT(qr.matrixQR())
VERIFY_RAISES_ASSERT(qr.solve(tmp))
VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp))
@@ -129,35 +129,33 @@ template<typename MatrixType, typename PermutationIndex> void qr_verify_assert()
EIGEN_DECLARE_TEST(qr_fullpivoting)
{
typedef int PermutationIndex;
for(int i = 0; i < 1; i++) {
CALL_SUBTEST_5( (qr<Matrix3f, PermutationIndex>()) );
CALL_SUBTEST_6( (qr<Matrix3d, PermutationIndex>()) );
CALL_SUBTEST_8( (qr<Matrix2f, PermutationIndex>()) );
CALL_SUBTEST_1( (qr<MatrixXf, PermutationIndex>()) );
CALL_SUBTEST_2( (qr<MatrixXd, PermutationIndex>()) );
CALL_SUBTEST_3( (qr<MatrixXcd, PermutationIndex>()) );
CALL_SUBTEST_5( qr<Matrix3f>() );
CALL_SUBTEST_6( qr<Matrix3d>() );
CALL_SUBTEST_8( qr<Matrix2f>() );
CALL_SUBTEST_1( qr<MatrixXf>() );
CALL_SUBTEST_2( qr<MatrixXd>() );
CALL_SUBTEST_3( qr<MatrixXcd>() );
}
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_1( (qr_invertible<MatrixXf, PermutationIndex>()) );
CALL_SUBTEST_2( (qr_invertible<MatrixXd, PermutationIndex>()) );
CALL_SUBTEST_4( (qr_invertible<MatrixXcf, PermutationIndex>()) );
CALL_SUBTEST_3( (qr_invertible<MatrixXcd, PermutationIndex>()) );
CALL_SUBTEST_1( qr_invertible<MatrixXf>() );
CALL_SUBTEST_2( qr_invertible<MatrixXd>() );
CALL_SUBTEST_4( qr_invertible<MatrixXcf>() );
CALL_SUBTEST_3( qr_invertible<MatrixXcd>() );
}
CALL_SUBTEST_5( (qr_verify_assert<Matrix3f, PermutationIndex>()) );
CALL_SUBTEST_6( (qr_verify_assert<Matrix3d, PermutationIndex>()) );
CALL_SUBTEST_1( (qr_verify_assert<MatrixXf, PermutationIndex>()) );
CALL_SUBTEST_2( (qr_verify_assert<MatrixXd, PermutationIndex>()) );
CALL_SUBTEST_4( (qr_verify_assert<MatrixXcf, PermutationIndex>()) );
CALL_SUBTEST_3( (qr_verify_assert<MatrixXcd, PermutationIndex>()) );
CALL_SUBTEST_5(qr_verify_assert<Matrix3f>());
CALL_SUBTEST_6(qr_verify_assert<Matrix3d>());
CALL_SUBTEST_1(qr_verify_assert<MatrixXf>());
CALL_SUBTEST_2(qr_verify_assert<MatrixXd>());
CALL_SUBTEST_4(qr_verify_assert<MatrixXcf>());
CALL_SUBTEST_3(qr_verify_assert<MatrixXcd>());
// Test problem size constructors
CALL_SUBTEST_7( (FullPivHouseholderQR<MatrixXf,PermutationIndex>(10, 20)));
CALL_SUBTEST_7( (FullPivHouseholderQR<Matrix<float, 10, 20>, PermutationIndex>(10, 20)));
CALL_SUBTEST_7( (FullPivHouseholderQR<Matrix<float, 10, 20>, PermutationIndex>(Matrix<float,10,20>::Random())));
CALL_SUBTEST_7( (FullPivHouseholderQR<Matrix<float, 20, 10>, PermutationIndex>(20, 10)));
CALL_SUBTEST_7( (FullPivHouseholderQR<Matrix<float, 20, 10>, PermutationIndex>(Matrix<float,20,10>::Random())));
CALL_SUBTEST_7(FullPivHouseholderQR<MatrixXf>(10, 20));
CALL_SUBTEST_7((FullPivHouseholderQR<Matrix<float,10,20> >(10,20)));
CALL_SUBTEST_7((FullPivHouseholderQR<Matrix<float,10,20> >(Matrix<float,10,20>::Random())));
CALL_SUBTEST_7((FullPivHouseholderQR<Matrix<float,20,10> >(20,10)));
CALL_SUBTEST_7((FullPivHouseholderQR<Matrix<float,20,10> >(Matrix<float,20,10>::Random())));
}