From 5c84dd56654b0bc3e6bc09773cc86438b27af005 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 19 Jun 2015 16:37:04 +0200 Subject: Fix permutation/transposiitons products wrt nested_eval --- Eigen/src/Core/ProductEvaluators.h | 48 +++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'Eigen/src/Core/ProductEvaluators.h') diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index c12ebb5a0..3cf7c0e16 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -842,17 +842,19 @@ struct product_evaluator, ProductTag, DenseShape, * Internal helper class implementing the product between a permutation matrix and a matrix. * This class is specialized for DenseShape below and for SparseShape in SparseCore/SparsePermutation.h */ -template +template struct permutation_matrix_product; -template -struct permutation_matrix_product +template +struct permutation_matrix_product { + typedef typename nested_eval::type MatrixType; typedef typename remove_all::type MatrixTypeCleaned; template - static inline void run(Dest& dst, const PermutationType& perm, const MatrixType& mat) + static inline void run(Dest& dst, const PermutationType& perm, const ExpressionType& xpr) { + MatrixType mat(xpr); const Index n = Side==OnTheLeft ? mat.rows() : mat.cols(); // FIXME we need an is_same for expression that is not sensitive to constness. For instance // is_same_xpr, Block >::value should be true. @@ -893,7 +895,7 @@ struct permutation_matrix_product = - Block + Block (mat, ((Side==OnTheRight) ^ Transposed) ? perm.indices().coeff(i) : i); } } @@ -951,26 +953,30 @@ struct generic_product_impl, MatrixShape, PermutationShape, * \class transposition_matrix_product * Internal helper class implementing the product between a permutation matrix and a matrix. */ -template +template struct transposition_matrix_product { - template - static inline void run(Dest& dst, const TranspositionType& tr, const MatrixType& mat) - { - typedef typename TranspositionType::StorageIndex StorageIndex; - const Index size = tr.size(); - StorageIndex j = 0; + typedef typename nested_eval::type MatrixType; + typedef typename remove_all::type MatrixTypeCleaned; + + template + static inline void run(Dest& dst, const TranspositionType& tr, const ExpressionType& xpr) + { + MatrixType mat(xpr); + typedef typename TranspositionType::StorageIndex StorageIndex; + const Index size = tr.size(); + StorageIndex j = 0; - if(!(is_same::value && extract_data(dst) == extract_data(mat))) - dst = mat; + if(!(is_same::value && extract_data(dst) == extract_data(mat))) + dst = mat; - for(Index k=(Transposed?size-1:0) ; Transposed?k>=0:k=0:k -- cgit v1.2.3