diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 355f3bdc8..b4662907e 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -56,8 +56,9 @@ struct traits > typename Rhs::Scalar ) >::type Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; + typedef typename cwise_promote_storage_type::StorageKind, + typename traits::StorageKind, + BinaryOp>::ret StorageKind; typedef typename promote_index_type::Index, typename traits::Index>::type Index; typedef typename Lhs::Nested LhsNested; @@ -98,8 +99,9 @@ template class CwiseBinaryOp : internal::no_assignment_operator, public CwiseBinaryOpImpl< BinaryOp, LhsType, RhsType, - typename internal::promote_storage_type::StorageKind, - typename internal::traits::StorageKind>::ret> + typename internal::cwise_promote_storage_type::StorageKind, + typename internal::traits::StorageKind, + BinaryOp>::ret> { public: @@ -108,8 +110,9 @@ class CwiseBinaryOp : internal::no_assignment_operator, typedef typename CwiseBinaryOpImpl< BinaryOp, LhsType, RhsType, - typename internal::promote_storage_type::StorageKind, - typename internal::traits::StorageKind>::ret>::Base Base; + typename internal::cwise_promote_storage_type::StorageKind, + typename internal::traits::StorageKind, + BinaryOp>::ret>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp) typedef typename internal::nested::type LhsNested; diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 4399e1d64..658473397 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -465,22 +465,6 @@ class Map, struct PermutationStorage {}; -#ifdef EIGEN_TEST_EVALUATORS - -// storage type of product of permutation wrapper with dense - -namespace internal { - -template<> struct promote_storage_type -{ typedef Dense ret; }; - -template<> struct promote_storage_type -{ typedef Dense ret; }; - -} // end namespace internal - -#endif // EIGEN_TEST_EVALUATORS - template class TranspositionsWrapper; namespace internal { template diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index e381ac46a..cb4d4c924 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -62,8 +62,9 @@ struct traits > typedef MatrixXpr XprKind; typedef typename product_result_scalar::Scalar Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; + typedef typename product_promote_storage_type::StorageKind, + typename traits::StorageKind, + internal::product_type::ret>::ret StorageKind; typedef typename promote_index_type::Index, typename traits::Index>::type Index; @@ -94,8 +95,9 @@ struct traits > template class Product : public ProductImpl<_Lhs,_Rhs,Option, - typename internal::promote_storage_type::StorageKind, - typename internal::traits<_Rhs>::StorageKind>::ret> + typename internal::product_promote_storage_type::StorageKind, + typename internal::traits<_Rhs>::StorageKind, + internal::product_type<_Lhs,_Rhs>::ret>::ret> { public: @@ -104,8 +106,9 @@ class Product : public ProductImpl<_Lhs,_Rhs,Option, typedef typename ProductImpl< Lhs, Rhs, Option, - typename internal::promote_storage_type::ret>::Base Base; + typename internal::product_promote_storage_type::ret>::ret>::Base Base; EIGEN_GENERIC_PUBLIC_INTERFACE(Product) typedef typename internal::nested::type LhsNested; diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 3b2246fd8..4a54f5f81 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -27,8 +27,9 @@ struct traits > typedef typename remove_all<_Lhs>::type Lhs; typedef typename remove_all<_Rhs>::type Rhs; typedef typename scalar_product_traits::ReturnType Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; + typedef typename product_promote_storage_type::StorageKind, + typename traits::StorageKind, + 0>::ret StorageKind; typedef typename promote_index_type::Index, typename traits::Index>::type Index; enum { diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index 85e8ac2c7..76806fd62 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -42,8 +42,9 @@ struct traits > typedef typename remove_all::type _LhsNested; typedef typename remove_all::type _RhsNested; typedef typename scalar_product_traits::ReturnType Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits<_RhsNested>::StorageKind>::ret StorageKind; + typedef typename product_promote_storage_type::StorageKind, + typename traits<_RhsNested>::StorageKind, + 0>::ret StorageKind; typedef typename promote_index_type::Index, typename traits<_RhsNested>::Index>::type Index; diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 131f5d793..4b55b3a9a 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -449,8 +449,6 @@ struct MatrixXpr {}; /** The type used to identify an array expression */ struct ArrayXpr {}; - -#ifdef EIGEN_ENABLE_EVALUATORS // An evaluator must define its shape. By default, it can be one of the following: struct DenseShape { static std::string debugName() { return "DenseShape"; } }; struct DiagonalShape { static std::string debugName() { return "DiagonalShape"; } }; @@ -459,8 +457,6 @@ struct TriangularShape { static std::string debugName() { return "TriangularSha struct SelfAdjointShape { static std::string debugName() { return "SelfAdjointShape"; } }; struct PermutationShape { static std::string debugName() { return "PermutationShape"; } }; struct SparseShape { static std::string debugName() { return "SparseShape"; } }; -#endif - } // end namespace Eigen diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 19adbefd7..70f2c566f 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -231,6 +231,10 @@ template struct plain_matrix_type { typedef typename plain_matrix_type_dense::XprKind>::type type; }; +template struct plain_matrix_type +{ + typedef typename T::PlainObject type; +}; template struct plain_matrix_type_dense { @@ -273,6 +277,11 @@ template struct eval // > type; }; +template struct eval +{ + typedef typename plain_matrix_type::type type; +}; + // for matrices, no need to evaluate, just use a const reference to avoid a useless copy template struct eval, Dense> @@ -515,12 +524,51 @@ template struct cast_return_type const XprType&,CastType>::type type; }; -template struct promote_storage_type; +/** \internal Specify the "storage kind" of applying a coefficient-wise + * binary operations between two expressions of kinds A and B respectively. + * The template parameter Functor permits to specialize the resulting storage kind wrt to + * the functor. + * The default rules are as follows: + * \code + * A op A -> A + * A op dense -> dense + * dense op B -> dense + * A * dense -> A + * dense * B -> B + * \endcode + */ +template struct cwise_promote_storage_type; -template struct promote_storage_type -{ - typedef A ret; -}; +template struct cwise_promote_storage_type { typedef A ret; }; +template struct cwise_promote_storage_type { typedef Dense ret; }; +template struct cwise_promote_storage_type > { typedef Dense ret; }; +template struct cwise_promote_storage_type { typedef Dense ret; }; +template struct cwise_promote_storage_type { typedef Dense ret; }; +template struct cwise_promote_storage_type > { typedef A ret; }; +template struct cwise_promote_storage_type > { typedef B ret; }; + +/** \internal Specify the "storage kind" of multiplying an expression of kind A with kind B. + * The template parameter ProductTag permits to specialize the resulting storage kind wrt to + * some compile-time properties of the product: GemmProduct, GemvProduct, OuterProduct, InnerProduct. + * The default rules are as follows: + * \code + * K * K -> K + * dense * K -> dense + * K * dense -> dense + * diag * K -> K + * K * diag -> K + * \endcode + */ +template struct product_promote_storage_type; + +template struct product_promote_storage_type { typedef A ret;}; +template struct product_promote_storage_type { typedef Dense ret;}; +template struct product_promote_storage_type { typedef Dense ret; }; +template struct product_promote_storage_type { typedef Dense ret; }; +template struct product_promote_storage_type { typedef A ret; }; +template struct product_promote_storage_type { typedef B ret; }; +template struct product_promote_storage_type { typedef Dense ret; }; +template struct product_promote_storage_type { typedef Dense ret; }; /** \internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type. * \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType. diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index dcb095dcf..68ea6cb11 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -31,12 +31,6 @@ namespace Eigen { namespace internal { -template<> struct promote_storage_type -{ typedef Sparse ret; }; - -template<> struct promote_storage_type -{ typedef Sparse ret; }; - template::StorageKind, typename _RhsStorageMode = typename traits::StorageKind>