mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
add a generic mechanism to copy a special matrix to a dense matrix so that
we don't need to add other specialization of MatrixBase::operator=, Matrix::=, and Matrix::Matrix(...)
This commit is contained in:
@@ -50,6 +50,8 @@ class DiagonalBase : public MultiplierBase<Derived>
|
||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
DenseMatrixType toDenseMatrix() const { return derived(); }
|
||||
template<typename DenseDerived>
|
||||
void evalToDense(MatrixBase<DenseDerived> &other) const;
|
||||
|
||||
inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); }
|
||||
inline DiagonalVectorType& diagonal() { return derived().diagonal(); }
|
||||
@@ -63,12 +65,11 @@ class DiagonalBase : public MultiplierBase<Derived>
|
||||
};
|
||||
|
||||
template<typename Derived>
|
||||
template<typename DiagonalDerived>
|
||||
Derived& MatrixBase<Derived>::operator=(const DiagonalBase<DiagonalDerived> &other)
|
||||
template<typename DenseDerived>
|
||||
void DiagonalBase<Derived>::evalToDense(MatrixBase<DenseDerived> &other) const
|
||||
{
|
||||
setZero();
|
||||
diagonal() = other.diagonal();
|
||||
return derived();
|
||||
other.setZero();
|
||||
other.diagonal() = diagonal();
|
||||
}
|
||||
|
||||
/** \class DiagonalMatrix
|
||||
|
||||
Reference in New Issue
Block a user