aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/permutationmatrices.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-10-10 21:48:58 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-10-10 21:48:58 +0200
commit76ceae49c18908fd82393ddf3f22b2b3daa88b3a (patch)
treeb1612dbc431a97a67c073eef9c542e73df5e4cae /test/permutationmatrices.cpp
parent2bf1a31d811fef2085bad97f98e2d0095136b636 (diff)
bug #1609: add inplace transposition unit test
Diffstat (limited to 'test/permutationmatrices.cpp')
-rw-r--r--test/permutationmatrices.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/permutationmatrices.cpp b/test/permutationmatrices.cpp
index 71f09be0f..a26b4ad45 100644
--- a/test/permutationmatrices.cpp
+++ b/test/permutationmatrices.cpp
@@ -126,6 +126,16 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
VERIFY_IS_APPROX(m_permuted, lp*m_original*rp.transpose());
VERIFY_IS_APPROX(lt.inverse()*m_permuted*rt.inverse(), m_original);
+
+ // Check inplace transpositions
+ m_permuted = m_original;
+ VERIFY_IS_APPROX(m_permuted = lt * m_permuted, lp * m_original);
+ m_permuted = m_original;
+ VERIFY_IS_APPROX(m_permuted = lt.inverse() * m_permuted, lp.inverse() * m_original);
+ m_permuted = m_original;
+ VERIFY_IS_APPROX(m_permuted = m_permuted * rt, m_original * rt);
+ m_permuted = m_original;
+ VERIFY_IS_APPROX(m_permuted = m_permuted * rt.inverse(), m_original * rt.inverse());
}
template<typename T>
@@ -147,7 +157,7 @@ void bug890()
MapType(v1.data(),2,1,S(1,1)) = P * MapType(rhs.data(),2,1,S(1,1));
VERIFY_IS_APPROX(v1, (P * rhs).eval());
-
+
MapType(v1.data(),2,1,S(1,1)) = P.inverse() * MapType(rhs.data(),2,1,S(1,1));
VERIFY_IS_APPROX(v1, (P.inverse() * rhs).eval());
}
@@ -160,8 +170,8 @@ EIGEN_DECLARE_TEST(permutationmatrices)
CALL_SUBTEST_3( permutationmatrices(Matrix<double,3,3,RowMajor>()) );
CALL_SUBTEST_4( permutationmatrices(Matrix4d()) );
CALL_SUBTEST_5( permutationmatrices(Matrix<double,40,60>()) );
- CALL_SUBTEST_6( permutationmatrices(Matrix<double,Dynamic,Dynamic,RowMajor>(20, 30)) );
- CALL_SUBTEST_7( permutationmatrices(MatrixXcf(15, 10)) );
+ CALL_SUBTEST_6( permutationmatrices(Matrix<double,Dynamic,Dynamic,RowMajor>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
+ CALL_SUBTEST_7( permutationmatrices(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
}
CALL_SUBTEST_5( bug890<double>() );
}