From 27ca9437a1e191f20724492275bf0b1415eee2d6 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 2 Dec 2013 14:05:34 +0100 Subject: Fix usage of Dense versus DenseShape --- Eigen/src/Core/AssignEvaluator.h | 31 ++++++++++++++----------------- Eigen/src/Core/CoreEvaluators.h | 4 ++-- Eigen/src/Core/ProductEvaluators.h | 4 ++-- Eigen/src/Core/util/Constants.h | 12 ++++++++++++ 4 files changed, 30 insertions(+), 21 deletions(-) (limited to 'Eigen') diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 2f18cbc95..2c9f2426b 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -526,6 +526,8 @@ public: Index size() const { return m_dstExpr.size(); } Index innerSize() const { return m_dstExpr.innerSize(); } Index outerSize() const { return m_dstExpr.outerSize(); } + Index rows() const { return m_dstExpr.rows(); } + Index cols() const { return m_dstExpr.cols(); } Index outerStride() const { return m_dstExpr.outerStride(); } // TODO get rid of this one: @@ -534,16 +536,25 @@ public: DstEvaluatorType& dstEvaluator() { return m_dst; } const SrcEvaluatorType& srcEvaluator() const { return m_src; } + /// Assign src(row,col) to dst(row,col) through the assignment functor. void assignCoeff(Index row, Index col) { m_functor.assignCoeff(m_dst.coeffRef(row,col), m_src.coeff(row,col)); } + /// This overload by-passes the source expression, i.e., dst(row,col) ?= value + void assignCoeff(Index row, Index col, const Scalar &value) + { + m_functor.assignCoeff(m_dst.coeffRef(row,col), value); + } + + /// \sa assignCoeff(Index,Index) void assignCoeff(Index index) { m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index)); } + /// \sa assignCoeff(Index,Index) void assignCoeffByOuterInner(Index outer, Index inner) { Index row = rowIndexByOuterInner(outer, inner); @@ -633,29 +644,15 @@ void call_dense_assignment_loop(const DstXprType& dst, const SrcXprType& src) * Part 6 : Generic assignment ***************************************************************************/ - -// An evaluator must define its shape. It can be one of the following: -struct DenseShape {}; -struct DiagonalShape {}; -struct BandShape {}; -struct TriangularShape {}; -struct SelfAdjointShape {}; -struct SparseShape {}; - - // Based on the respective shapes of the destination and source, // the class AssignmentKind determine the kind of assignment mechanism. // AssignmentKind must define a Kind typedef. template struct AssignmentKind; -// AssignmentKind<.,.>::Kind can be one of the following: - struct Dense2Dense {}; - struct Triangular2Triangular {}; -// struct Diagonal2Diagonal {}; // <=> Dense2Dense - struct Sparse2Dense {}; - struct Sparse2Sparse {}; +// Assignement kind defined in this file: +struct Dense2Dense {}; -template<> struct AssignmentKind { typedef Dense2Dense Kind; }; +template<> struct AssignmentKind { typedef Dense2Dense Kind; }; // This is the main assignment class template< typename DstXprType, typename SrcXprType, typename Functor, diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 9460e675f..961b56e55 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -42,14 +42,14 @@ template struct storage_kind_to_shape; template<> struct storage_kind_to_shape { - typedef Dense Shape; + typedef DenseShape Shape; }; // TODO to be moved to SparseCore: /* template<> struct storage_kind_to_shape { - typedef Sparse Shape; + typedef SparseSpape Shape; }; */ diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index e3a893651..51228be5f 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -48,7 +48,7 @@ struct dense_product_impl; // The evaluator for default dense products creates a temporary and call dense_product_impl template -struct product_evaluator, ProductTag, Dense, Dense, typename Lhs::Scalar, typename Rhs::Scalar> +struct product_evaluator, ProductTag, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar> : public evaluator::PlainObject>::type { typedef Product XprType; @@ -217,7 +217,7 @@ template -struct product_evaluator, ProductTag, Dense, Dense, typename Lhs::Scalar, typename Rhs::Scalar > +struct product_evaluator, ProductTag, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar > : evaluator_base > { typedef Product XprType; diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 3178ff06e..14449eb6c 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -440,6 +440,18 @@ 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"; } }; +struct BandShape { static std::string debugName() { return "BandShape"; } }; +struct TriangularShape { static std::string debugName() { return "TriangularShape"; } }; +struct SelfAdjointShape { static std::string debugName() { return "SelfAdjointShape"; } }; +struct SparseShape { static std::string debugName() { return "SparseShape"; } }; +#endif + + } // end namespace Eigen #endif // EIGEN_CONSTANTS_H -- cgit v1.2.3