mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix compilation of product with inverse transpositions (e.g., mat * Transpositions().inverse())
This commit is contained in:
parent
8c7b5158a1
commit
a1292395d6
@ -384,7 +384,7 @@ class Transpose<TranspositionsBase<TranspositionsDerived> >
|
|||||||
const Product<OtherDerived, Transpose, AliasFreeProduct>
|
const Product<OtherDerived, Transpose, AliasFreeProduct>
|
||||||
operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trt)
|
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.
|
/** \returns the \a matrix with the inverse transpositions applied to the rows.
|
||||||
|
@ -19,9 +19,11 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
|
|||||||
enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime,
|
enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime,
|
||||||
Options = MatrixType::Options };
|
Options = MatrixType::Options };
|
||||||
typedef PermutationMatrix<Rows> LeftPermutationType;
|
typedef PermutationMatrix<Rows> LeftPermutationType;
|
||||||
|
typedef Transpositions<Rows> LeftTranspositionsType;
|
||||||
typedef Matrix<int, Rows, 1> LeftPermutationVectorType;
|
typedef Matrix<int, Rows, 1> LeftPermutationVectorType;
|
||||||
typedef Map<LeftPermutationType> MapLeftPerm;
|
typedef Map<LeftPermutationType> MapLeftPerm;
|
||||||
typedef PermutationMatrix<Cols> RightPermutationType;
|
typedef PermutationMatrix<Cols> RightPermutationType;
|
||||||
|
typedef Transpositions<Cols> RightTranspositionsType;
|
||||||
typedef Matrix<int, Cols, 1> RightPermutationVectorType;
|
typedef Matrix<int, Cols, 1> RightPermutationVectorType;
|
||||||
typedef Map<RightPermutationType> MapRightPerm;
|
typedef Map<RightPermutationType> MapRightPerm;
|
||||||
|
|
||||||
@ -35,6 +37,8 @@ template<typename MatrixType> void permutationmatrices(const MatrixType& m)
|
|||||||
RightPermutationVectorType rv;
|
RightPermutationVectorType rv;
|
||||||
randomPermutationVector(rv, cols);
|
randomPermutationVector(rv, cols);
|
||||||
RightPermutationType rp(rv);
|
RightPermutationType rp(rv);
|
||||||
|
LeftTranspositionsType lt(lv);
|
||||||
|
RightTranspositionsType rt(rv);
|
||||||
MatrixType m_permuted = MatrixType::Random(rows,cols);
|
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"
|
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();
|
Matrix<Scalar, Cols, Cols> B = rp.transpose();
|
||||||
VERIFY_IS_APPROX(A, B.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>
|
template<typename T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user