From 6f3f8578979b8af3d29abc8bfc17e7995bf54143 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 5 Feb 2010 23:44:24 +0100 Subject: [PATCH] make noalias works for coefficient based products --- Eigen/src/Core/DenseBase.h | 3 +++ Eigen/src/Core/Flagged.h | 14 ++++++++++++++ Eigen/src/Core/NoAlias.h | 8 ++++++++ Eigen/src/Core/ProductBase.h | 2 -- Eigen/src/Core/util/Constants.h | 2 ++ Eigen/src/Core/util/ForwardDeclarations.h | 1 + 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index a2165b52f..9ef9108e4 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -233,6 +233,9 @@ template class DenseBase CommaInitializer operator<< (const Scalar& s); + template + const Flagged flagged() const; + template CommaInitializer operator<< (const DenseBase& other); diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h index af00a68be..7f42a1e73 100644 --- a/Eigen/src/Core/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -118,4 +118,18 @@ template clas ExpressionTypeNested m_matrix; }; +/** \returns an expression of *this with added and removed flags + * + * This is mostly for internal use. + * + * \sa class Flagged + */ +template +template +inline const Flagged +DenseBase::flagged() const +{ + return derived(); +} + #endif // EIGEN_FLAGGED_H diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index bfea5c91d..e09fd0091 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -69,6 +69,14 @@ class NoAlias template 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 GeneralProduct& other) + { return m_expression.derived() -= other.template flagged<0,EvalBeforeAssigningBit|EvalBeforeNestingBit>(); } #endif protected: diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index ef986baaa..5c51ea27c 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -25,8 +25,6 @@ #ifndef EIGEN_PRODUCTBASE_H #define EIGEN_PRODUCTBASE_H -enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct }; - /** \class ProductBase * */ diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 6ae103e66..c747d970b 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -267,4 +267,6 @@ namespace Architecture enum DenseStorageMatrix {}; enum DenseStorageArray {}; +enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct }; + #endif // EIGEN_CONSTANTS_H diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index b6bba04e6..ac7824dc1 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -51,6 +51,7 @@ template class CwiseUnaryView; template class CwiseBinaryOp; template class SelfCwiseBinaryOp; template class ProductBase; +template class GeneralProduct; template class DiagonalBase; template class DiagonalWrapper;