diff options
Diffstat (limited to 'test/qr_fullpivoting.cpp')
-rw-r--r-- | test/qr_fullpivoting.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/test/qr_fullpivoting.cpp b/test/qr_fullpivoting.cpp index 70e89c198..f2d8cb33e 100644 --- a/test/qr_fullpivoting.cpp +++ b/test/qr_fullpivoting.cpp @@ -10,16 +10,18 @@ #include "main.h" #include <Eigen/QR> +#include "solverbase.h" template<typename MatrixType> void qr() { - typedef typename MatrixType::Index Index; + STATIC_CHECK(( internal::is_same<typename FullPivHouseholderQR<MatrixType>::StorageIndex,int>::value )); + static const int Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime; Index max_size = EIGEN_TEST_MAX_SIZE; Index min_size = numext::maxi(1,EIGEN_TEST_MAX_SIZE/10); - Index rows = internal::random<Index>(min_size,max_size), - cols = internal::random<Index>(min_size,max_size), - cols2 = internal::random<Index>(min_size,max_size), + Index rows = Rows == Dynamic ? internal::random<Index>(min_size,max_size) : Rows, + cols = Cols == Dynamic ? internal::random<Index>(min_size,max_size) : Cols, + cols2 = Cols == Dynamic ? internal::random<Index>(min_size,max_size) : Cols, rank = internal::random<Index>(1, (std::min)(rows, cols)-1); typedef typename MatrixType::Scalar Scalar; @@ -49,13 +51,10 @@ template<typename MatrixType> void qr() MatrixType tmp; VERIFY_IS_APPROX(tmp.noalias() = qr.matrixQ() * r, (qr.matrixQ() * r).eval()); - MatrixType m2 = MatrixType::Random(cols,cols2); - MatrixType m3 = m1*m2; - m2 = MatrixType::Random(cols,cols2); - m2 = qr.solve(m3); - VERIFY_IS_APPROX(m3, m1*m2); + check_solverbase<MatrixType, MatrixType>(m1, qr, rows, cols, cols2); { + MatrixType m2, m3; Index size = rows; do { m1 = MatrixType::Random(size,size); @@ -94,9 +93,7 @@ template<typename MatrixType> void qr_invertible() VERIFY(qr.isInvertible()); VERIFY(qr.isSurjective()); - m3 = MatrixType::Random(size,size); - m2 = qr.solve(m3); - VERIFY_IS_APPROX(m3, m1*m2); + check_solverbase<MatrixType, MatrixType>(m1, qr, size, size, size); // now construct a matrix with prescribed determinant m1.setZero(); @@ -116,6 +113,8 @@ template<typename MatrixType> void qr_verify_assert() FullPivHouseholderQR<MatrixType> qr; VERIFY_RAISES_ASSERT(qr.matrixQR()) VERIFY_RAISES_ASSERT(qr.solve(tmp)) + VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp)) + VERIFY_RAISES_ASSERT(qr.adjoint().solve(tmp)) VERIFY_RAISES_ASSERT(qr.matrixQ()) VERIFY_RAISES_ASSERT(qr.dimensionOfKernel()) VERIFY_RAISES_ASSERT(qr.isInjective()) @@ -126,11 +125,12 @@ template<typename MatrixType> void qr_verify_assert() VERIFY_RAISES_ASSERT(qr.logAbsDeterminant()) } -void test_qr_fullpivoting() +EIGEN_DECLARE_TEST(qr_fullpivoting) { - for(int i = 0; i < 1; i++) { - // FIXME : very weird bug here -// CALL_SUBTEST(qr(Matrix2f()) ); + for(int i = 0; i < 1; i++) { + 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>() ); |