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;
59 VERIFY_IS_APPROX(lv.asPermutation().inverse()*m_permuted*rv.asPermutation().inverse(), m_original);
62 VERIFY((lp*lp.inverse()).toDenseMatrix().isIdentity());
63 VERIFY((lv.asPermutation()*lv.asPermutation().inverse()).toDenseMatrix().isIdentity());
64 VERIFY((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv.data(),lv.size()).
inverse()).toDenseMatrix().isIdentity());
66 LeftPermutationVectorType lv2;
68 LeftPermutationType lp2(lv2);
71 VERIFY_IS_APPROX((lv.asPermutation()*lv2.asPermutation()).toDenseMatrix().template cast<Scalar>(), lm*lm2);
72 VERIFY_IS_APPROX((MapLeftPerm(lv.data(),lv.size())*MapLeftPerm(lv2.data(),lv2.size())).toDenseMatrix().template cast<Scalar>(), lm*lm2);
74 LeftPermutationType identityp;
75 identityp.setIdentity(rows);
79 m_permuted = m_original;
83 m_permuted = m_original;
87 m_permuted = m_original;
91 m_permuted = m_original;
98 Index i = internal::random<Index>(0, rows-1);
100 do j = internal::random<Index>(0, rows-1);
while(j==i);
101 lp2.applyTranspositionOnTheLeft(i, j);
103 lm.row(i).
swap(lm.row(j));
106 RightPermutationType rp2 = rp;
107 i = internal::random<Index>(0, cols-1);
108 do j = internal::random<Index>(0, cols-1);
while(j==i);
109 rp2.applyTranspositionOnTheRight(i, j);
111 rm.col(i).swap(rm.col(j));
122 m_permuted = m_original;
140 VectorType
v1(2),
v2(2), op(4), rhs(2);
166 CALL_SUBTEST_5( bug890<double>() );
EIGEN_DEVICE_FUNC void swap(DenseBase< OtherDerived > &other)
void test_permutationmatrices()
A matrix or vector expression mapping an existing array of data.
Holds strides information for Map.
void randomPermutationVector(PermutationVectorType &v, Index size)
Matrix< SCALARB, Dynamic, Dynamic > B
#define VERIFY_EVALUATION_COUNT(XPR, N)
#define VERIFY_IS_APPROX(a, b)
void permutationmatrices(const MatrixType &m)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Map< MatrixType > MapType
internal::nested_eval< T, 1 >::type eval(const T &xpr)
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
Represents a sequence of transpositions (row/column interchange)