From b868bfb84a4a86231bb338e9bcf08afd882d32dc Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 25 Jun 2014 17:23:52 +0200 Subject: Make operator=(EigenBase<>) uses the new assignment mechanism and introduce a generic EigenBase to EigenBase assignment kind based on the previous evalTo mechanism. --- Eigen/src/Core/DiagonalMatrix.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Eigen/src/Core/DiagonalMatrix.h') diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index ba0042ba4..fc9ecf561 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -44,6 +44,8 @@ class DiagonalBase : public EigenBase EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix() const { return derived(); } + +#ifndef EIGEN_TEST_EVALUATORS template EIGEN_DEVICE_FUNC void evalTo(MatrixBase &other) const; @@ -55,6 +57,7 @@ class DiagonalBase : public EigenBase EIGEN_DEVICE_FUNC void subTo(MatrixBase &other) const { other.diagonal() -= diagonal(); } +#endif // EIGEN_TEST_EVALUATORS EIGEN_DEVICE_FUNC inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); } @@ -122,6 +125,7 @@ class DiagonalBase : public EigenBase #endif }; +#ifndef EIGEN_TEST_EVALUATORS template template void DiagonalBase::evalTo(MatrixBase &other) const @@ -129,6 +133,8 @@ void DiagonalBase::evalTo(MatrixBase &other) const other.setZero(); other.diagonal() = diagonal(); } +#endif // EIGEN_TEST_EVALUATORS + #endif /** \class DiagonalMatrix @@ -376,6 +382,21 @@ struct evaluator_traits > static const int AssumeAliasing = 0; }; +struct Diagonal2Dense {}; + +template<> struct AssignmentKind { typedef Diagonal2Dense Kind; }; + +// Diagonal matrix to Dense assignment +template< typename DstXprType, typename SrcXprType, typename Functor, typename Scalar> +struct Assignment +{ + static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op &/*func*/) + { + dst.setZero(); + dst.diagonal() = src.diagonal(); + } +}; + } // namespace internal #endif // EIGEN_ENABLE_EVALUATORS -- cgit v1.2.3