diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-10-07 15:41:22 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-10-07 15:41:22 +0200 |
commit | 41cc1f9033e7a316834b409eb2c6db69fd5de56d (patch) | |
tree | 5333fb18469b559d5db85ce56cc62c49fb440ab6 | |
parent | ca0dd7ae26cfbfdc16f23b46a016f401e3db4e5c (diff) |
Remove debuging prod() and lazyprod() function, plus some cleaning in noalias assignment
-rw-r--r-- | Eigen/src/Core/AssignEvaluator.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 23 | ||||
-rwxr-xr-x | Eigen/src/Core/ProductEvaluators.h | 19 | ||||
-rw-r--r-- | 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<typename Dst, template <typename> class StorageBase, typename Src, typename Func> -EIGEN_DEVICE_FUNC void call_assignment(const NoAlias<Dst,StorageBase>& dst, const Src& src, const Func& func) -{ - call_assignment_no_alias(dst.expression(), src, func); -} -template<typename Dst, template <typename> class StorageBase, typename Src, typename Func> EIGEN_DEVICE_FUNC void call_assignment(NoAlias<Dst,StorageBase>& 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<Lhs,Rhs,Option,Dense> }; -/*************************************************************************** -* Implementation of matrix base methods -***************************************************************************/ - - -/** \internal used to test the evaluator only - */ -template<typename Lhs,typename Rhs> -const Product<Lhs,Rhs> -prod(const Lhs& lhs, const Rhs& rhs) -{ - return Product<Lhs,Rhs>(lhs,rhs); -} - -/** \internal used to test the evaluator only - */ -template<typename Lhs,typename Rhs> -const Product<Lhs,Rhs,LazyProduct> -lazyprod(const Lhs& lhs, const Rhs& rhs) -{ - return Product<Lhs,Rhs,LazyProduct>(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<DstXprType, CwiseUnaryOp<internal::scalar_multiple_op<ScalarBi const Product<Lhs,Rhs,DefaultProduct> > 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<Lhs,Rhs,DenseShape,DenseShape,CoeffBasedProductMode> template<typename Dst> 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<Scalar>()); + // Same as: dst.noalias() = lhs.lazyProduct(rhs); + // but easier on the compiler side + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::assign_op<Scalar>()); } template<typename Dst> 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<Scalar>()); + // dst.noalias() += lhs.lazyProduct(rhs); + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::add_assign_op<Scalar>()); } template<typename Dst> 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<Scalar>()); + // dst.noalias() -= lhs.lazyProduct(rhs); + call_assignment_no_alias(dst, lhs.lazyProduct(rhs), internal::sub_assign_op<Scalar>()); } // template<typename Dst> // 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<typename Lhs,typename Rhs> + const Product<Lhs,Rhs> + prod(const Lhs& lhs, const Rhs& rhs) + { + return Product<Lhs,Rhs>(lhs,rhs); + } + + template<typename Lhs,typename Rhs> + const Product<Lhs,Rhs,LazyProduct> + lazyprod(const Lhs& lhs, const Rhs& rhs) + { + return Product<Lhs,Rhs,LazyProduct>(lhs,rhs); + } template<typename DstXprType, typename SrcXprType> 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<Scalar>()); } + + namespace internal { + template<typename Dst, template <typename> class StorageBase, typename Src, typename Func> + EIGEN_DEVICE_FUNC void call_assignment(const NoAlias<Dst,StorageBase>& dst, const Src& src, const Func& func) + { + call_assignment_no_alias(dst.expression(), src, func); + } + } } |