aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/DiagonalMatrix.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-06-25 17:23:52 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-06-25 17:23:52 +0200
commitb868bfb84a4a86231bb338e9bcf08afd882d32dc (patch)
tree29f019cbbe4f5821fc41c6f2358961fc99c7c7e0 /Eigen/src/Core/DiagonalMatrix.h
parent3b19b466a7609fd381db2c53569d4d1d1621dbfc (diff)
Make operator=(EigenBase<>) uses the new assignment mechanism and introduce a generic EigenBase to EigenBase assignment kind based on the previous evalTo mechanism.
Diffstat (limited to 'Eigen/src/Core/DiagonalMatrix.h')
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h21
1 files changed, 21 insertions, 0 deletions
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<Derived>
EIGEN_DEVICE_FUNC
DenseMatrixType toDenseMatrix() const { return derived(); }
+
+#ifndef EIGEN_TEST_EVALUATORS
template<typename DenseDerived>
EIGEN_DEVICE_FUNC
void evalTo(MatrixBase<DenseDerived> &other) const;
@@ -55,6 +57,7 @@ class DiagonalBase : public EigenBase<Derived>
EIGEN_DEVICE_FUNC
void subTo(MatrixBase<DenseDerived> &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<Derived>
#endif
};
+#ifndef EIGEN_TEST_EVALUATORS
template<typename Derived>
template<typename DenseDerived>
void DiagonalBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const
@@ -129,6 +133,8 @@ void DiagonalBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const
other.setZero();
other.diagonal() = diagonal();
}
+#endif // EIGEN_TEST_EVALUATORS
+
#endif
/** \class DiagonalMatrix
@@ -376,6 +382,21 @@ struct evaluator_traits<DiagonalWrapper<Derived> >
static const int AssumeAliasing = 0;
};
+struct Diagonal2Dense {};
+
+template<> struct AssignmentKind<DenseShape,DiagonalShape> { typedef Diagonal2Dense Kind; };
+
+// Diagonal matrix to Dense assignment
+template< typename DstXprType, typename SrcXprType, typename Functor, typename Scalar>
+struct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Dense, Scalar>
+{
+ static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar> &/*func*/)
+ {
+ dst.setZero();
+ dst.diagonal() = src.diagonal();
+ }
+};
+
} // namespace internal
#endif // EIGEN_ENABLE_EVALUATORS