aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2018-04-03 23:06:44 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2018-04-03 23:06:44 +0200
commita1292395d6feefa5d78ed9101c2c85648ba8eea9 (patch)
treef1be49c51f82cdfb825a4164f4f0f0ab719264c4
parent8c7b5158a10af19bb98f2c2b5c57d44fd8899fe8 (diff)
Fix compilation of product with inverse transpositions (e.g., mat * Transpositions().inverse())
-rw-r--r--Eigen/src/Core/Transpositions.h2
-rw-r--r--test/permutationmatrices.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h
index 8798deca5..81a4a5855 100644
--- a/Eigen/src/Core/Transpositions.h
+++ b/Eigen/src/Core/Transpositions.h
@@ -384,7 +384,7 @@ class Transpose<TranspositionsBase<TranspositionsDerived> >
const Product<OtherDerived, Transpose, AliasFreeProduct>
operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trt)
{
- return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt.derived());
+ return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt);
}
/** \returns the \a matrix with the inverse transpositions applied to the rows.
diff --git a/test/permutationmatrices.cpp b/test/permutationmatrices.cpp
index db1266579..0ed7a4b2b 100644
--- a/test/permutationmatrices.cpp
+++ b/test/permutationmatrices.cpp
@@ -19,9 +19,11 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime,
Options = MatrixType::Options };
typedef PermutationMatrix<Rows> LeftPermutationType;
+ typedef Transpositions<Rows> LeftTranspositionsType;
typedef Matrix<int, Rows, 1> LeftPermutationVectorType;
typedef Map<LeftPermutationType> MapLeftPerm;
typedef PermutationMatrix<Cols> RightPermutationType;
+ typedef Transpositions<Cols> RightTranspositionsType;
typedef Matrix<int, Cols, 1> RightPermutationVectorType;
typedef Map<RightPermutationType> MapRightPerm;
@@ -35,6 +37,8 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
RightPermutationVectorType rv;
randomPermutationVector(rv, cols);
RightPermutationType rp(rv);
+ LeftTranspositionsType lt(lv);
+ RightTranspositionsType rt(rv);
MatrixType m_permuted = MatrixType::Random(rows,cols);
VERIFY_EVALUATION_COUNT(m_permuted = lp * m_original * rp, 1); // 1 temp for sub expression "lp * m_original"
@@ -115,6 +119,14 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
Matrix<Scalar, Cols, Cols> B = rp.transpose();
VERIFY_IS_APPROX(A, B.transpose());
}
+
+ m_permuted = m_original;
+ lp = lt;
+ rp = rt;
+ VERIFY_EVALUATION_COUNT(m_permuted = lt * m_permuted * rt, 1);
+ VERIFY_IS_APPROX(m_permuted, lp*m_original*rp);
+
+ VERIFY_IS_APPROX(lt.inverse()*m_permuted*rt.inverse(), m_original);
}
template<typename T>