From aa768add0bd273763d06edb3ef6800ccb04284ef Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 2 Sep 2015 22:10:39 +0200 Subject: [PATCH] Since there is no reason for evaluators to be nested by reference, let's remove the evaluator<>::nestedType indirection. --- Eigen/src/Core/CoreEvaluators.h | 33 ++++++++----------- Eigen/src/Core/Inverse.h | 2 -- Eigen/src/Core/ProductEvaluators.h | 10 ++---- Eigen/src/Core/Redux.h | 2 +- Eigen/src/Core/ReturnByValue.h | 2 -- Eigen/src/Core/Solve.h | 2 -- Eigen/src/Core/Visitor.h | 2 +- Eigen/src/Geometry/Homogeneous.h | 5 --- .../IterativeLinearSolvers/SolveWithGuess.h | 2 -- Eigen/src/SparseCore/SparseBlock.h | 2 +- Eigen/src/SparseCore/SparseCwiseBinaryOp.h | 16 ++++----- Eigen/src/SparseCore/SparseCwiseUnaryOp.h | 4 +-- Eigen/src/SparseCore/SparseDenseProduct.h | 4 +-- Eigen/src/SparseCore/SparseDiagonalProduct.h | 6 ++-- Eigen/src/SparseCore/SparseProduct.h | 2 -- Eigen/src/SparseCore/SparseTranspose.h | 2 +- Eigen/src/SparseCore/SparseView.h | 4 +-- 17 files changed, 35 insertions(+), 65 deletions(-) diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 9b6a442e5..c362dc3b9 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -89,7 +89,6 @@ template struct evaluator : evaluator { - typedef evaluator nestedType; explicit evaluator(const T& xpr) : evaluator(xpr) {} }; @@ -98,10 +97,6 @@ struct evaluator template struct evaluator_base : public noncopyable { - // TODO Check whether nestedType is really needed: - // As long as evaluator are non-copyable, there is no reason to make it different. - typedef evaluator nestedType; - // FIXME is it really usefull? typedef typename traits::StorageIndex StorageIndex; @@ -307,7 +302,7 @@ struct unary_evaluator, IndexBased> } protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; // -------------------- CwiseNullaryOp -------------------- @@ -411,7 +406,7 @@ struct unary_evaluator, IndexBased > protected: const UnaryOp m_functor; - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; // -------------------- CwiseBinaryOp -------------------- @@ -486,8 +481,8 @@ struct binary_evaluator, IndexBased, IndexBase protected: const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; + evaluator m_lhsImpl; + evaluator m_rhsImpl; }; // -------------------- CwiseUnaryView -------------------- @@ -536,7 +531,7 @@ struct unary_evaluator, IndexBased> protected: const UnaryOp m_unaryOp; - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; // -------------------- Map -------------------- @@ -810,7 +805,7 @@ struct unary_evaluator, IndexBa } protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const variable_if_dynamic m_startRow; const variable_if_dynamic m_startCol; }; @@ -879,9 +874,9 @@ struct evaluator > } protected: - typename evaluator::nestedType m_conditionImpl; - typename evaluator::nestedType m_thenImpl; - typename evaluator::nestedType m_elseImpl; + evaluator m_conditionImpl; + evaluator m_thenImpl; + evaluator m_elseImpl; }; @@ -962,7 +957,7 @@ struct unary_evaluator > protected: const ArgTypeNested m_arg; // FIXME is it OK to store both the argument and its evaluator?? (we have the same situation in evaluator_product) - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const variable_if_dynamic m_rows; const variable_if_dynamic m_cols; }; @@ -1080,7 +1075,7 @@ struct evaluator_wrapper_base } protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; template @@ -1215,7 +1210,7 @@ struct unary_evaluator > } protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; // If we do not reverse rows, then we do not need to know the number of rows; same for columns const variable_if_dynamic m_rows; @@ -1270,7 +1265,7 @@ struct evaluator > } protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const internal::variable_if_dynamicindex m_index; private: @@ -1334,8 +1329,6 @@ struct evaluator > typedef typename ArgType::PlainObject PlainObject; typedef evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : m_result(xpr.rows(), xpr.cols()) { diff --git a/Eigen/src/Core/Inverse.h b/Eigen/src/Core/Inverse.h index d70bffca9..b359e1287 100644 --- a/Eigen/src/Core/Inverse.h +++ b/Eigen/src/Core/Inverse.h @@ -106,8 +106,6 @@ struct unary_evaluator > typedef typename InverseType::PlainObject PlainObject; typedef evaluator Base; - typedef evaluator nestedType; - enum { Flags = Base::Flags | EvalBeforeNestingBit }; unary_evaluator(const InverseType& inv_xpr) diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 2dcd02cbd..d704eedb9 100755 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -32,8 +32,6 @@ struct evaluator > typedef Product XprType; typedef product_evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {} }; @@ -46,8 +44,6 @@ struct evaluator, const Produ typedef CwiseUnaryOp, const Product > XprType; typedef evaluator,const Lhs>, Rhs, DefaultProduct> > Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr.functor().m_other * xpr.nestedExpression().lhs() * xpr.nestedExpression().rhs()) {} @@ -61,8 +57,6 @@ struct evaluator, DiagIndex> > typedef Diagonal, DiagIndex> XprType; typedef evaluator, DiagIndex> > Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(Diagonal, DiagIndex>( Product(xpr.nestedExpression().lhs(), xpr.nestedExpression().rhs()), @@ -735,8 +729,8 @@ protected: m_diagImpl.template packet(id)); } - typename evaluator::nestedType m_diagImpl; - typename evaluator::nestedType m_matImpl; + evaluator m_diagImpl; + evaluator m_matImpl; }; // diagonal * dense diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 67ce3113e..c427a4d58 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -390,7 +390,7 @@ public: const XprType & nestedExpression() const { return m_xpr; } protected: - typename internal::evaluator::nestedType m_evaluator; + internal::evaluator m_evaluator; const XprType &m_xpr; }; diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h index 5cd66ebed..7feb6e01c 100644 --- a/Eigen/src/Core/ReturnByValue.h +++ b/Eigen/src/Core/ReturnByValue.h @@ -100,8 +100,6 @@ struct evaluator > typedef typename internal::traits::ReturnType PlainObject; typedef evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : m_result(xpr.rows(), xpr.cols()) { diff --git a/Eigen/src/Core/Solve.h b/Eigen/src/Core/Solve.h index 911309018..4857a7c42 100644 --- a/Eigen/src/Core/Solve.h +++ b/Eigen/src/Core/Solve.h @@ -119,8 +119,6 @@ struct evaluator > typedef typename SolveType::PlainObject PlainObject; typedef evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit evaluator(const SolveType& solve) : m_result(solve.rows(), solve.cols()) { diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 374972d3e..a4e2cebab 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -79,7 +79,7 @@ public: { return m_evaluator.coeff(row, col); } protected: - typename internal::evaluator::nestedType m_evaluator; + internal::evaluator m_evaluator; const XprType &m_xpr; }; } // end namespace internal diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index abb4c2fd3..e23758d86 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -317,7 +317,6 @@ struct unary_evaluator, IndexBased> typedef Homogeneous XprType; typedef typename XprType::PlainObject PlainObject; typedef evaluator Base; - typedef evaluator nestedType; explicit unary_evaluator(const XprType& op) : Base(), m_temp(op) @@ -388,8 +387,6 @@ struct product_evaluator, ProductTag, Homogeneous typedef typename helper::Xpr RefactoredXpr; typedef evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr) : Base( xpr.lhs().nestedExpression() .lazyProduct( xpr.rhs().template topRows(xpr.lhs().nestedExpression().cols()) ) + ConstantBlock(xpr.rhs().row(xpr.rhs().rows()-1),xpr.lhs().rows(), 1) ) @@ -431,8 +428,6 @@ struct product_evaluator, ProductTag, DenseShape, typedef typename helper::Xpr RefactoredXpr; typedef evaluator Base; - typedef evaluator nestedType; - EIGEN_DEVICE_FUNC explicit product_evaluator(const XprType& xpr) : Base( xpr.lhs().template leftCols(xpr.rhs().nestedExpression().rows()) .lazyProduct( xpr.rhs().nestedExpression() ) + ConstantBlock(xpr.lhs().col(xpr.lhs().cols()-1),1,xpr.rhs().cols()) ) diff --git a/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h b/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h index 4450c9eed..35923be3d 100644 --- a/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +++ b/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h @@ -76,8 +76,6 @@ struct evaluator > typedef SolveWithGuess SolveType; typedef typename SolveType::PlainObject PlainObject; typedef evaluator Base; - - typedef evaluator nestedType; evaluator(const SolveType& solve) : m_result(solve.rows(), solve.cols()) diff --git a/Eigen/src/SparseCore/SparseBlock.h b/Eigen/src/SparseCore/SparseBlock.h index 552bfca48..7df99eca4 100644 --- a/Eigen/src/SparseCore/SparseBlock.h +++ b/Eigen/src/SparseCore/SparseBlock.h @@ -456,7 +456,7 @@ struct unary_evaluator, IteratorBa protected: typedef typename evaluator::InnerIterator EvalIterator; - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const XprType &m_block; }; diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index a4cc24e30..ae2995ced 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -146,8 +146,8 @@ public: protected: const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; + evaluator m_lhsImpl; + evaluator m_rhsImpl; }; // "sparse .* sparse" @@ -227,8 +227,8 @@ public: protected: const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; + evaluator m_lhsImpl; + evaluator m_rhsImpl; }; // "dense .* sparse" @@ -295,8 +295,8 @@ public: protected: const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; + evaluator m_lhsImpl; + evaluator m_rhsImpl; }; // "sparse .* dense" @@ -364,8 +364,8 @@ public: protected: const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; + evaluator m_lhsImpl; + evaluator m_rhsImpl; }; } diff --git a/Eigen/src/SparseCore/SparseCwiseUnaryOp.h b/Eigen/src/SparseCore/SparseCwiseUnaryOp.h index d484be876..469bac36e 100644 --- a/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseUnaryOp.h @@ -40,7 +40,7 @@ struct unary_evaluator, IteratorBased> // typedef typename evaluator::ReverseInnerIterator EvalReverseIterator; const UnaryOp m_functor; - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; template @@ -115,7 +115,7 @@ struct unary_evaluator, IteratorBased> // typedef typename evaluator::ReverseInnerIterator EvalReverseIterator; const ViewOp m_functor; - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; template diff --git a/Eigen/src/SparseCore/SparseDenseProduct.h b/Eigen/src/SparseCore/SparseDenseProduct.h index 1a167445a..67b3c9c1b 100644 --- a/Eigen/src/SparseCore/SparseDenseProduct.h +++ b/Eigen/src/SparseCore/SparseDenseProduct.h @@ -272,8 +272,8 @@ public: protected: const LhsArg m_lhs; - typename evaluator::nestedType m_lhsXprImpl; - typename evaluator::nestedType m_rhsXprImpl; + evaluator m_lhsXprImpl; + evaluator m_rhsXprImpl; }; // sparse * dense outer product diff --git a/Eigen/src/SparseCore/SparseDiagonalProduct.h b/Eigen/src/SparseCore/SparseDiagonalProduct.h index 4dec7d7cc..b3b80e35a 100644 --- a/Eigen/src/SparseCore/SparseDiagonalProduct.h +++ b/Eigen/src/SparseCore/SparseDiagonalProduct.h @@ -39,7 +39,6 @@ struct product_evaluator, ProductTag, Diagonal : public sparse_diagonal_product_evaluator { typedef Product XprType; - typedef evaluator nestedType; enum { CoeffReadCost = Dynamic, Flags = Rhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags typedef sparse_diagonal_product_evaluator Base; @@ -51,7 +50,6 @@ struct product_evaluator, ProductTag, SparseSh : public sparse_diagonal_product_evaluator, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct> { typedef Product XprType; - typedef evaluator nestedType; enum { CoeffReadCost = Dynamic, Flags = Lhs::Flags&RowMajorBit, Alignment = 0 }; // FIXME CoeffReadCost & Flags typedef sparse_diagonal_product_evaluator, Lhs::Flags&RowMajorBit?SDP_AsCwiseProduct:SDP_AsScalarProduct> Base; @@ -84,8 +82,8 @@ public: {} protected: - typename evaluator::nestedType m_sparseXprImpl; - typename evaluator::nestedType m_diagCoeffImpl; + evaluator m_sparseXprImpl; + evaluator m_diagCoeffImpl; }; diff --git a/Eigen/src/SparseCore/SparseProduct.h b/Eigen/src/SparseCore/SparseProduct.h index c2131fd9d..da8919ecc 100644 --- a/Eigen/src/SparseCore/SparseProduct.h +++ b/Eigen/src/SparseCore/SparseProduct.h @@ -69,8 +69,6 @@ struct evaluator > > typedef typename XprType::PlainObject PlainObject; typedef evaluator Base; - typedef evaluator nestedType; - explicit evaluator(const XprType& xpr) : m_result(xpr.rows(), xpr.cols()) { diff --git a/Eigen/src/SparseCore/SparseTranspose.h b/Eigen/src/SparseCore/SparseTranspose.h index d3fc7f102..c2d4ac549 100644 --- a/Eigen/src/SparseCore/SparseTranspose.h +++ b/Eigen/src/SparseCore/SparseTranspose.h @@ -92,7 +92,7 @@ struct unary_evaluator, IteratorBased> explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {} protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; }; } // end namespace internal diff --git a/Eigen/src/SparseCore/SparseView.h b/Eigen/src/SparseCore/SparseView.h index 0a87f01d9..dc054fbd1 100644 --- a/Eigen/src/SparseCore/SparseView.h +++ b/Eigen/src/SparseCore/SparseView.h @@ -114,7 +114,7 @@ struct unary_evaluator, IteratorBased> explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {} protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const XprType &m_view; }; @@ -182,7 +182,7 @@ struct unary_evaluator, IndexBased> explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {} protected: - typename evaluator::nestedType m_argImpl; + evaluator m_argImpl; const XprType &m_view; };