diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 8c9afd4ee..e8236cbd7 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -397,12 +397,12 @@ class PermutationMatrix : public PermutationBase PermutationMatrix(const Transpose >& other) - : m_indices(other.nestedPermutation().size()) + : m_indices(other.nestedExpression().size()) { eigen_internal_assert(m_indices.size() <= NumTraits::highest()); StorageIndex end = StorageIndex(m_indices.size()); for (StorageIndex i=0; i PermutationMatrix(internal::PermPermProduct_t, const Lhs& lhs, const Rhs& rhs) @@ -635,7 +635,7 @@ class Transpose > return Product(*this, matrix.derived()); } - const PermutationType& nestedPermutation() const { return m_permutation; } + const PermutationType& nestedExpression() const { return m_permutation; } protected: const PermutationType& m_permutation; diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 7f0a9b589..0739528f1 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -53,6 +53,18 @@ template typedef typename Lhs::Scalar Scalar; }; +template +struct product_result_scalar +{ + typedef typename Rhs::Scalar Scalar; +}; + +template + struct product_result_scalar +{ + typedef typename Lhs::Scalar Scalar; +}; + template struct traits > { diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 4c673a6cb..5765857ce 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -915,7 +915,7 @@ struct generic_product_impl, Rhs, PermutationShape, MatrixShape, template static void evalTo(Dest& dst, const Transpose& lhs, const Rhs& rhs) { - permutation_matrix_product::run(dst, lhs.nestedPermutation(), rhs); + permutation_matrix_product::run(dst, lhs.nestedExpression(), rhs); } }; @@ -925,7 +925,7 @@ struct generic_product_impl, MatrixShape, PermutationShape, template static void evalTo(Dest& dst, const Lhs& lhs, const Transpose& rhs) { - permutation_matrix_product::run(dst, rhs.nestedPermutation(), lhs); + permutation_matrix_product::run(dst, rhs.nestedExpression(), lhs); } }; @@ -944,7 +944,7 @@ template struct transposition_matrix_product { template - static inline void evalTo(Dest& dst, const TranspositionType& tr, const MatrixType& mat) + static inline void run(Dest& dst, const TranspositionType& tr, const MatrixType& mat) { typedef typename TranspositionType::StorageIndex StorageIndex; const Index size = tr.size(); @@ -982,13 +982,14 @@ struct generic_product_impl struct generic_product_impl, Rhs, TranspositionsShape, MatrixShape, ProductTag> { template static void evalTo(Dest& dst, const Transpose& lhs, const Rhs& rhs) { - transposition_matrix_product::run(dst, lhs.nestedPermutation(), rhs); + transposition_matrix_product::run(dst, lhs.nestedExpression(), rhs); } }; @@ -998,7 +999,7 @@ struct generic_product_impl, MatrixShape, TranspositionsShap template static void evalTo(Dest& dst, const Lhs& lhs, const Transpose& rhs) { - transposition_matrix_product::run(dst, rhs.nestedPermutation(), lhs); + transposition_matrix_product::run(dst, rhs.nestedExpression(), lhs); } }; diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h index dad4f56c9..65447745f 100644 --- a/Eigen/src/Core/Transpositions.h +++ b/Eigen/src/Core/Transpositions.h @@ -62,7 +62,7 @@ class TranspositionsBase indices() = other.indices(); return derived(); } - + #ifndef EIGEN_PARSED_BY_DOXYGEN /** This is a special case of the templated operator=. Its purpose is to * prevent a default operator= from hiding the templated operator=. @@ -75,7 +75,11 @@ class TranspositionsBase #endif /** \returns the number of transpositions */ - inline Index size() const { return indices().size(); } + Index size() const { return indices().size(); } + /** \returns the number of rows of the equivalent permutation matrix */ + Index rows() const { return indices().size(); } + /** \returns the number of columns of the equivalent permutation matrix */ + Index cols() const { return indices().size(); } /** Direct access to the underlying index vector */ inline const StorageIndex& coeff(Index i) const { return indices().coeff(i); } @@ -143,9 +147,10 @@ class TranspositionsBase namespace internal { template struct traits > + : traits > { typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; - typedef _StorageIndex StorageIndex; + typedef TranspositionsStorage StorageKind; }; } @@ -214,9 +219,11 @@ class Transpositions : public TranspositionsBase struct traits,_PacketAccess> > + : traits > { typedef Map, _PacketAccess> IndicesType; typedef _StorageIndex StorageIndex; + typedef TranspositionsStorage StorageKind; }; } @@ -271,9 +278,9 @@ class Map,P namespace internal { template struct traits > + : traits > { - typedef typename _IndicesType::Scalar StorageIndex; - typedef _IndicesType IndicesType; + typedef TranspositionsStorage StorageKind; }; } @@ -347,8 +354,16 @@ operator*(const TranspositionsBase &transpositions, (transpositions.derived(), matrix.derived()); } +// Template partial specialization for transposed/inverse transpositions -/* Template partial specialization for transposed/inverse transpositions */ +namespace internal { + +template +struct traits > > + : traits +{}; + +} // end namespace internal template class Transpose > @@ -359,7 +374,9 @@ class Transpose > explicit Transpose(const TranspositionType& t) : m_transpositions(t) {} - inline int size() const { return m_transpositions.size(); } + Index size() const { return m_transpositions.size(); } + Index rows() const { return m_transpositions.size(); } + Index cols() const { return m_transpositions.size(); } /** \returns the \a matrix with the inverse transpositions applied to the columns. */ @@ -378,6 +395,8 @@ class Transpose > { return Product(*this, matrix.derived()); } + + const TranspositionType& nestedExpression() const { return m_transpositions; } protected: const TranspositionType& m_transpositions; diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 3e6c75444..8d6089b2d 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -468,6 +468,9 @@ struct Sparse {}; /** The type used to identify a permutation storage. */ struct PermutationStorage {}; +/** The type used to identify a permutation storage. */ +struct TranspositionsStorage {}; + /** The type used to identify a matrix expression */ struct MatrixXpr {};