From 41cc1f9033e7a316834b409eb2c6db69fd5de56d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 7 Oct 2015 15:41:22 +0200 Subject: [PATCH] Remove debuging prod() and lazyprod() function, plus some cleaning in noalias assignment --- Eigen/src/Core/AssignEvaluator.h | 6 ------ Eigen/src/Core/Product.h | 23 ----------------------- Eigen/src/Core/ProductEvaluators.h | 19 +++++++++---------- test/evaluators.cpp | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 39 deletions(-) diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index a02104bb0..f4e92a808 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -716,14 +716,8 @@ EIGEN_DEVICE_FUNC void call_assignment(Dst& dst, const Src& src, const Func& fun } // by-pass AssumeAliasing -// FIXME the const version should probably not be needed // When there is no aliasing, we require that 'dst' has been properly resized template class StorageBase, typename Src, typename Func> -EIGEN_DEVICE_FUNC void call_assignment(const NoAlias& dst, const Src& src, const Func& func) -{ - call_assignment_no_alias(dst.expression(), src, func); -} -template class StorageBase, typename Src, typename Func> EIGEN_DEVICE_FUNC void call_assignment(NoAlias& dst, const Src& src, const Func& func) { call_assignment_no_alias(dst.expression(), src, func); diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index b79236f15..fdd2fed3f 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -217,29 +217,6 @@ class ProductImpl }; -/*************************************************************************** -* Implementation of matrix base methods -***************************************************************************/ - - -/** \internal used to test the evaluator only - */ -template -const Product -prod(const Lhs& lhs, const Rhs& rhs) -{ - return Product(lhs,rhs); -} - -/** \internal used to test the evaluator only - */ -template -const Product -lazyprod(const Lhs& lhs, const Rhs& rhs) -{ - return Product(lhs,rhs); -} - } // end namespace Eigen #endif // EIGEN_PRODUCT_H diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 04e5e5e37..6e1be1227 100755 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -177,8 +177,7 @@ struct Assignment > SrcXprType; static void run(DstXprType &dst, const SrcXprType &src, const AssignFunc& func) { - // TODO use operator* instead of prod() once we have made enough progress - call_assignment(dst.noalias(), prod(src.functor().m_other * src.nestedExpression().lhs(), src.nestedExpression().rhs()), func); + call_assignment_no_alias(dst, (src.functor().m_other * src.nestedExpression().lhs())*src.nestedExpression().rhs(), func); } }; @@ -329,28 +328,28 @@ struct generic_product_impl template static inline void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { - // TODO: use the following instead of calling call_assignment, same for the other methods - // dst = lazyprod(lhs,rhs); - call_assignment(dst, lazyprod(lhs,rhs), internal::assign_op()); + // Same as: dst.noalias() = lhs.lazyProduct(rhs); + // but easier on the compiler side + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::assign_op()); } template static inline void addTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { - // dst += lazyprod(lhs,rhs); - call_assignment(dst, lazyprod(lhs,rhs), internal::add_assign_op()); + // dst.noalias() += lhs.lazyProduct(rhs); + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::add_assign_op()); } template static inline void subTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { - // dst -= lazyprod(lhs,rhs); - call_assignment(dst, lazyprod(lhs,rhs), internal::sub_assign_op()); + // dst.noalias() -= lhs.lazyProduct(rhs); + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::sub_assign_op()); } // template // static inline void scaleAndAddTo(Dst& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) -// { dst += alpha * lazyprod(lhs,rhs); } +// { dst.noalias() += alpha * lhs.lazyProduct(rhs); } }; // This specialization enforces the use of a coefficient-based evaluation strategy diff --git a/test/evaluators.cpp b/test/evaluators.cpp index f41968da8..12dc1ffef 100644 --- a/test/evaluators.cpp +++ b/test/evaluators.cpp @@ -2,6 +2,20 @@ #include "main.h" namespace Eigen { + + template + const Product + prod(const Lhs& lhs, const Rhs& rhs) + { + return Product(lhs,rhs); + } + + template + const Product + lazyprod(const Lhs& lhs, const Rhs& rhs) + { + return Product(lhs,rhs); + } template EIGEN_STRONG_INLINE @@ -69,6 +83,14 @@ namespace Eigen { typedef typename DstXprType::Scalar Scalar; call_assignment(dst.const_cast_derived(), src.const_cast_derived(), internal::swap_assign_op()); } + + namespace internal { + template class StorageBase, typename Src, typename Func> + EIGEN_DEVICE_FUNC void call_assignment(const NoAlias& dst, const Src& src, const Func& func) + { + call_assignment_no_alias(dst.expression(), src, func); + } + } }