diff --git a/Eigen/Core b/Eigen/Core index b6e383210..b9241a730 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -205,7 +205,7 @@ struct Dense {}; #include "src/Core/TriangularMatrix.h" #include "src/Core/SelfAdjointView.h" #include "src/Core/SolveTriangular.h" -#include "src/Core/products/GeneralUnrolled.h" +#include "src/Core/products/CoeffBasedProduct.h" #include "src/Core/products/GeneralBlockPanelKernel.h" #include "src/Core/products/GeneralMatrixVector.h" #include "src/Core/products/GeneralMatrixMatrix.h" diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index 7e2e501b3..9d6cab7f9 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -70,13 +70,13 @@ class NoAlias EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase& other) { other.derived().subTo(m_expression); return m_expression; } - template - EIGEN_STRONG_INLINE ExpressionType& operator+=(const GeneralProduct& other) - { return m_expression.derived() += other.template flagged<0,EvalBeforeAssigningBit|EvalBeforeNestingBit>(); } + template + EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct& other) + { return m_expression.derived() += CoeffBasedProduct(other.lhs(), other.rhs()); } - template - EIGEN_STRONG_INLINE ExpressionType& operator-=(const GeneralProduct& other) - { return m_expression.derived() -= other.template flagged<0,EvalBeforeAssigningBit|EvalBeforeNestingBit>(); } + template + EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct& other) + { return m_expression.derived() -= CoeffBasedProduct(other.lhs(), other.rhs()); } #endif protected: diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 5e531c467..e643b2ea7 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -87,12 +87,12 @@ public: template struct ei_product_type_selector { enum { ret = OuterProduct }; }; template struct ei_product_type_selector<1, 1, Depth> { enum { ret = InnerProduct }; }; template<> struct ei_product_type_selector<1, 1, 1> { enum { ret = InnerProduct }; }; -template<> struct ei_product_type_selector { enum { ret = CoeffBasedProduct }; }; -template<> struct ei_product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProduct }; }; -template<> struct ei_product_type_selector { enum { ret = CoeffBasedProduct }; }; -template<> struct ei_product_type_selector { enum { ret = CoeffBasedProduct }; }; -template<> struct ei_product_type_selector { enum { ret = CoeffBasedProduct }; }; -template<> struct ei_product_type_selector { enum { ret = CoeffBasedProduct }; }; +template<> struct ei_product_type_selector { enum { ret = CoeffBasedProductMode }; }; +template<> struct ei_product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProductMode }; }; +template<> struct ei_product_type_selector { enum { ret = CoeffBasedProductMode }; }; +template<> struct ei_product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; +template<> struct ei_product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; +template<> struct ei_product_type_selector { enum { ret = LazyCoeffBasedProductMode }; }; template<> struct ei_product_type_selector<1, Large,Small> { enum { ret = GemvProduct }; }; template<> struct ei_product_type_selector<1, Large,Large> { enum { ret = GemvProduct }; }; template<> struct ei_product_type_selector<1, Small,Large> { enum { ret = GemvProduct }; }; @@ -134,11 +134,19 @@ struct ProductReturnType }; template -struct ProductReturnType +struct ProductReturnType { typedef typename ei_nested::type >::type LhsNested; typedef typename ei_nested::type >::type RhsNested; - typedef GeneralProduct Type; + typedef CoeffBasedProduct Type; +}; + +template +struct ProductReturnType +{ + typedef typename ei_nested::type >::type LhsNested; + typedef typename ei_nested::type >::type RhsNested; + typedef CoeffBasedProduct Type; }; diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 6eb02f386..9fdb74f1c 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -83,8 +83,7 @@ class ProductBase : public MatrixBase typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; typedef typename ei_cleantype::type _ActualRhsType; - typedef typename ProductReturnType::Type CoeffBaseProductType; - typedef Flagged LazyCoeffBaseProductType; + typedef typename ProductReturnType::Type LazyCoeffBaseProductType; public: typedef typename Base::PlainMatrixType PlainMatrixType; @@ -112,31 +111,28 @@ class ProductBase : public MatrixBase template inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { derived().scaleAndAddTo(dst,alpha); } - EIGEN_DEPRECATED const Flagged lazy() const - { return *this; } - const _LhsNested& lhs() const { return m_lhs; } const _RhsNested& rhs() const { return m_rhs; } const Diagonal diagonal() const - { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs); } Diagonal diagonal() - { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs); } template const Diagonal diagonal() const - { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs); } template Diagonal diagonal() - { return Diagonal(CoeffBaseProductType(m_lhs, m_rhs)); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs); } const Diagonal diagonal(int index) const - { return Diagonal(LazyCoeffBaseProductType(CoeffBaseProductType(m_lhs, m_rhs))).diagonal(index); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } Diagonal diagonal(int index) - { return Diagonal(LazyCoeffBaseProductType(CoeffBaseProductType(m_lhs, m_rhs))).diagonal(index); } + { return LazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } // Implicit convertion to the nested type (trigger the evaluation of the product) operator const PlainMatrixType& () const diff --git a/Eigen/src/Core/products/GeneralCoeffBased.h b/Eigen/src/Core/products/CoeffBasedProduct.h similarity index 88% rename from Eigen/src/Core/products/GeneralCoeffBased.h rename to Eigen/src/Core/products/CoeffBasedProduct.h index 0cca2d417..d947bfc58 100644 --- a/Eigen/src/Core/products/GeneralCoeffBased.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -23,11 +23,14 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . -#ifndef EIGEN_GENERAL_UNROLLED_PRODUCT_H -#define EIGEN_GENERAL_UNROLLED_PRODUCT_H +#ifndef EIGEN_COEFFBASED_PRODUCT_H +#define EIGEN_COEFFBASED_PRODUCT_H /********************************************************************************* -* Specialization of GeneralProduct<> for products with small fixed sizes +* Coefficient based product implementation. +* It is designed for the following use cases: +* - small fixed sizes +* - lazy products *********************************************************************************/ /* Since the all the dimensions of the product are small, here we can rely @@ -42,8 +45,8 @@ struct ei_product_coeff_impl; template struct ei_product_packet_impl; -template -struct ei_traits > +template +struct ei_traits > { typedef DenseStorageMatrix DenseStorageType; typedef typename ei_cleantype::type _LhsNested; @@ -79,14 +82,13 @@ struct ei_traits > RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit), Flags = ((unsigned int)(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits) - | EvalBeforeAssigningBit - | EvalBeforeNestingBit + | NestingFlags | (CanVectorizeLhs || CanVectorizeRhs ? PacketAccessBit : 0) | (LhsFlags & RhsFlags & AlignedBit), - CoeffReadCost = InnerSize == Dynamic ? Dynamic - : InnerSize * (NumTraits::MulCost + LhsCoeffReadCost + RhsCoeffReadCost) - + (InnerSize - 1) * NumTraits::AddCost, + CoeffReadCost = 1000,//InnerSize == Dynamic ? Dynamic +// : InnerSize * (NumTraits::MulCost + LhsCoeffReadCost + RhsCoeffReadCost) +// + (InnerSize - 1) * NumTraits::AddCost, /* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside * of Product. If the Product itself is not a packet-access expression, there is still a chance that the inner @@ -98,25 +100,27 @@ struct ei_traits > }; }; -template class GeneralProduct +template +class CoeffBasedProduct : ei_no_assignment_operator, - public MatrixBase > + public MatrixBase > { public: - typedef MatrixBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(GeneralProduct) + typedef MatrixBase Base; + EIGEN_DENSE_PUBLIC_INTERFACE(CoeffBasedProduct) + typedef typename Base::PlainMatrixType PlainMatrixType; private: - typedef typename ei_traits::_LhsNested _LhsNested; - typedef typename ei_traits::_RhsNested _RhsNested; + typedef typename ei_traits::_LhsNested _LhsNested; + typedef typename ei_traits::_RhsNested _RhsNested; enum { PacketSize = ei_packet_traits::size, - InnerSize = ei_traits::InnerSize, + InnerSize = ei_traits::InnerSize, Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT, - CanVectorizeInner = ei_traits::CanVectorizeInner + CanVectorizeInner = ei_traits::CanVectorizeInner }; typedef ei_product_coeff_impl class GeneralProduct - inline GeneralProduct(const Lhs& lhs, const Rhs& rhs) + inline CoeffBasedProduct(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { // we don't allow taking products of matrices of different real types, as that wouldn't be vectorizable. @@ -171,11 +175,27 @@ template class GeneralProduct +struct ei_nested, N, PlainMatrixType> +{ + typedef PlainMatrixType const& type; +}; /*************************************************************************** * Normal product .coeff() implementation (with meta-unrolling) @@ -386,4 +406,4 @@ struct ei_product_packet_impl class CwiseNullaryOp; template class CwiseUnaryOp; template class CwiseUnaryView; template class CwiseBinaryOp; -template class SelfCwiseBinaryOp; +template class SelfCwiseBinaryOp; template class ProductBase; -template class GeneralProduct; +template class GeneralProduct; +template class CoeffBasedProduct; template class DiagonalBase; template class DiagonalWrapper; diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 56a57b706..619e7664d 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -61,6 +61,7 @@ THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE, YOU_MADE_A_PROGRAMMING_MISTAKE, + EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE, YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR, YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR, UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,