10 #define TEST_ENABLE_TEMPORARY_TRACKING 18 enum { Rows = MatrixType::RowsAtCompileTime,
Cols = MatrixType::ColsAtCompileTime,
19 Options = MatrixType::Options };
32 MatrixType m_original = MatrixType::Random(rows,cols);
33 LeftPermutationVectorType lv;
35 LeftPermutationType lp(lv);
36 RightPermutationVectorType rv;
38 RightPermutationType rp(rv);
39 LeftTranspositionsType lt(lv);
40 RightTranspositionsType rt(rv);
41 MatrixType m_permuted = MatrixType::Random(rows,cols);
54 m_permuted = m_original;
58 LeftPermutationType lpi;
63 VERIFY_IS_APPROX(lv.asPermutation().inverse()*m_permuted*rv.asPermutation().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;
102 Index i = internal::random<Index>(0, rows-1);
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());
154 VectorType
v1(2),
v2(2), op(4), rhs(2);
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
A matrix or vector expression mapping an existing array of data.
#define CALL_SUBTEST_3(FUNC)
#define CALL_SUBTEST_7(FUNC)
Holds strides information for Map.
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
void randomPermutationVector(PermutationVectorType &v, Index size)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
#define VERIFY_EVALUATION_COUNT(XPR, N)
#define VERIFY_IS_APPROX(a, b)
void permutationmatrices(const MatrixType &m)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define CALL_SUBTEST_5(FUNC)
Map< MatrixType > MapType
#define EIGEN_TEST_MAX_SIZE
EIGEN_DECLARE_TEST(permutationmatrices)
#define CALL_SUBTEST_2(FUNC)
internal::nested_eval< T, 1 >::type eval(const T &xpr)
The matrix class, also used for vectors and row-vectors.
Represents a sequence of transpositions (row/column interchange)