mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
@@ -372,6 +372,53 @@ bool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \returns DiagonalWrapper.
|
||||
*
|
||||
* Example: \include MatrixBase_diagonalView.cpp
|
||||
* Output: \verbinclude MatrixBase_diagonalView.out
|
||||
*
|
||||
* \sa diagonalView()
|
||||
*/
|
||||
|
||||
/** This is the non-const version of diagonalView() with DiagIndex_ . */
|
||||
template <typename Derived>
|
||||
template <int DiagIndex_>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<Derived, DiagIndex_>> MatrixBase<Derived>::diagonalView() {
|
||||
typedef Diagonal<Derived, DiagIndex_> DiagType;
|
||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
||||
DiagType diag(this->derived());
|
||||
return ReturnType(diag);
|
||||
}
|
||||
|
||||
/** This is the const version of diagonalView() with DiagIndex_ . */
|
||||
template <typename Derived>
|
||||
template <int DiagIndex_>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<const Derived, DiagIndex_>> MatrixBase<Derived>::diagonalView() const {
|
||||
typedef Diagonal<const Derived, DiagIndex_> DiagType;
|
||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
||||
DiagType diag(this->derived());
|
||||
return ReturnType(diag);
|
||||
}
|
||||
|
||||
/** This is the non-const version of diagonalView() with dynamic index. */
|
||||
template <typename Derived>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<Derived, DynamicIndex>> MatrixBase<Derived>::diagonalView(Index index) {
|
||||
typedef Diagonal<Derived, DynamicIndex> DiagType;
|
||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
||||
DiagType diag(this->derived(), index);
|
||||
return ReturnType(diag);
|
||||
}
|
||||
|
||||
/** This is the const version of diagonalView() with dynamic index. */
|
||||
template <typename Derived>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<const Derived, DynamicIndex>> MatrixBase<Derived>::diagonalView(
|
||||
Index index) const {
|
||||
typedef Diagonal<const Derived, DynamicIndex> DiagType;
|
||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
||||
DiagType diag(this->derived(), index);
|
||||
return ReturnType(diag);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <>
|
||||
|
||||
@@ -274,6 +274,17 @@ class MatrixBase : public DenseBase<Derived> {
|
||||
const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
|
||||
bool isUnitary(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
|
||||
|
||||
/* diagonalView */
|
||||
template <int DiagIndex_ = 0>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<Derived, DiagIndex_>> diagonalView();
|
||||
|
||||
template <int DiagIndex_ = 0>
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<const Derived, DiagIndex_>> diagonalView() const;
|
||||
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<Derived, DynamicIndex>> diagonalView(Index index);
|
||||
|
||||
EIGEN_DEVICE_FUNC DiagonalWrapper<Diagonal<const Derived, DynamicIndex>> diagonalView(Index index) const;
|
||||
|
||||
/** \returns true if each coefficients of \c *this and \a other are all exactly equal.
|
||||
* \warning When using floating point scalar values you probably should rather use a
|
||||
* fuzzy comparison such as isApprox()
|
||||
|
||||
Reference in New Issue
Block a user