diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index aaccb4e7b..1c66cde8e 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -105,10 +105,10 @@ class PermutationMatrix : public AnyMatrixBase @@ -126,7 +126,31 @@ class PermutationMatrix : public AnyMatrixBase + inline PermutationMatrix operator*(const PermutationMatrix& other) const + { return PermutationMatrix(Product, *this, other); } + protected: IndicesType m_indices; diff --git a/test/permutationmatrices.cpp b/test/permutationmatrices.cpp index 13b01cd83..ec3a8541c 100644 --- a/test/permutationmatrices.cpp +++ b/test/permutationmatrices.cpp @@ -72,6 +72,15 @@ template void permutationmatrices(const MatrixType& m) Matrix rm(rp); VERIFY_IS_APPROX(m_permuted, lm*m_original*rm); + + VERIFY_IS_APPROX(lp.inverse()*m_permuted*rp.inverse(), m_original); + VERIFY((lp*lp.inverse()).toDenseMatrix().isIdentity()); + + LeftPermutationVectorType lv2; + randomPermutationVector(lv2, rows); + LeftPermutationType lp2(lv2); + Matrix lm2(lp2); + VERIFY_IS_APPROX((lp*lp2).toDenseMatrix().template cast(), lm2*lm); } void test_permutationmatrices()