10 #define TEST_ENABLE_TEMPORARY_TRACKING
18 enum { Rows = MatrixType::RowsAtCompileTime,
Cols = MatrixType::ColsAtCompileTime,
19 Options = MatrixType::Options };
33 LeftPermutationVectorType lv;
35 LeftPermutationType lp(lv);
36 RightPermutationVectorType rv;
38 RightPermutationType rp(rv);
39 LeftTranspositionsType lt(lv);
40 RightTranspositionsType rt(rv);
54 m_permuted = m_original;
58 LeftPermutationType lpi;
63 VERIFY_IS_APPROX(lv.asPermutation().inverse()*m_permuted*rv.asPermutation().inverse(), m_original);
64 VERIFY_IS_APPROX(MapLeftPerm(lv.data(),lv.size()).inverse()*m_permuted*MapRightPerm(rv.data(),rv.size()).inverse(), m_original);
66 VERIFY((lp*lp.inverse()).toDenseMatrix().isIdentity());
67 VERIFY((lv.asPermutation()*lv.asPermutation().inverse()).toDenseMatrix().isIdentity());
68 VERIFY((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv.data(),lv.size()).inverse()).toDenseMatrix().isIdentity());
70 LeftPermutationVectorType lv2;
72 LeftPermutationType lp2(lv2);
75 VERIFY_IS_APPROX((lv.asPermutation()*lv2.asPermutation()).toDenseMatrix().template cast<Scalar>(), lm*lm2);
76 VERIFY_IS_APPROX((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv2.data(),lv2.size())).toDenseMatrix().template cast<Scalar>(), lm*lm2);
78 LeftPermutationType identityp;
79 identityp.setIdentity(
rows);
83 m_permuted = m_original;
87 m_permuted = m_original;
91 m_permuted = m_original;
95 m_permuted = m_original;
104 do j = internal::random<Index>(0,
rows-1);
while(
j==
i);
105 lp2.applyTranspositionOnTheLeft(
i,
j);
107 lm.row(
i).
swap(lm.row(
j));
110 RightPermutationType rp2 = rp;
111 i = internal::random<Index>(0,
cols-1);
112 do j = internal::random<Index>(0,
cols-1);
while(
j==
i);
113 rp2.applyTranspositionOnTheRight(
i,
j);
115 rm.col(
i).swap(rm.col(
j));
126 m_permuted = m_original;
135 m_permuted = m_original;
137 m_permuted = m_original;
138 VERIFY_IS_APPROX(m_permuted = lt.inverse() * m_permuted, lp.inverse() * m_original);
139 m_permuted = m_original;
141 m_permuted = m_original;
142 VERIFY_IS_APPROX(m_permuted = m_permuted * rt.inverse(), m_original * rt.inverse());