Eigen::Diagonal< MatrixType, DiagIndex_ > Class Template Reference

Expression of a diagonal/subdiagonal/superdiagonal in a matrix. More...

#include <Diagonal.h>

+ Inheritance diagram for Eigen::Diagonal< MatrixType, DiagIndex_ >:

Public Types

enum  { DiagIndex = DiagIndex_ }
 
typedef internal::dense_xpr_base< Diagonal >::type Base
 
typedef std::conditional_t< internal::is_lvalue< MatrixType >::value, Scalar, const ScalarScalarWithConstIfNotLvalue
 

Public Member Functions

EIGEN_DEVICE_FUNC Diagonal (MatrixType &matrix, Index a_index=DiagIndex)
 
EIGEN_DEVICE_FUNC Index rows () const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvaluedata ()
 
EIGEN_DEVICE_FUNC const Scalardata () const
 
EIGEN_DEVICE_FUNC ScalarcoeffRef (Index row, Index)
 
EIGEN_DEVICE_FUNC const ScalarcoeffRef (Index row, Index) const
 
EIGEN_DEVICE_FUNC CoeffReturnType coeff (Index row, Index) const
 
EIGEN_DEVICE_FUNC ScalarcoeffRef (Index idx)
 
EIGEN_DEVICE_FUNC const ScalarcoeffRef (Index idx) const
 
EIGEN_DEVICE_FUNC CoeffReturnType coeff (Index idx) const
 
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename MatrixType::Nested > & nestedExpression () const
 
EIGEN_DEVICE_FUNC Index index () const
 

Protected Attributes

internal::ref_selector< MatrixType >::non_const_type m_matrix
 
const internal::variable_if_dynamicindex< Index, DiagIndexm_index
 

Private Member Functions

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index absDiagIndex () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rowOffset () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index colOffset () const EIGEN_NOEXCEPT
 
template<int LoadMode>
MatrixType::PacketReturnType packet (Index) const
 
template<int LoadMode>
MatrixType::PacketReturnType packet (Index, Index) const
 

Detailed Description

template<typename MatrixType, int DiagIndex_>
class Eigen::Diagonal< MatrixType, DiagIndex_ >

Expression of a diagonal/subdiagonal/superdiagonal in a matrix.

Template Parameters
MatrixTypethe type of the object in which we are taking a sub/main/super diagonal
DiagIndexthe index of the sub/super diagonal. The default is 0 and it means the main diagonal. A positive value means a superdiagonal, a negative value means a subdiagonal. You can also use DynamicIndex so the index can be set at runtime.

The matrix is not required to be square.

This class represents an expression of the main diagonal, or any sub/super diagonal of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the time this is the only way it is used.

See also
MatrixBase::diagonal(), MatrixBase::diagonal(Index)

Member Typedef Documentation

◆ Base

template<typename MatrixType , int DiagIndex_>
typedef internal::dense_xpr_base<Diagonal>::type Eigen::Diagonal< MatrixType, DiagIndex_ >::Base

◆ ScalarWithConstIfNotLvalue

template<typename MatrixType , int DiagIndex_>
typedef std::conditional_t<internal::is_lvalue<MatrixType>::value, Scalar, const Scalar> Eigen::Diagonal< MatrixType, DiagIndex_ >::ScalarWithConstIfNotLvalue

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType , int DiagIndex_>
anonymous enum
Enumerator
DiagIndex 
70 { DiagIndex = DiagIndex_ };
@ DiagIndex
Definition: Diagonal.h:70

Constructor & Destructor Documentation

◆ Diagonal()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC Eigen::Diagonal< MatrixType, DiagIndex_ >::Diagonal ( MatrixType matrix,
Index  a_index = DiagIndex 
)
inlineexplicit
75  : m_matrix(matrix), m_index(a_index) {
76  eigen_assert(a_index <= m_matrix.cols() && -a_index <= m_matrix.rows());
77  }
#define eigen_assert(x)
Definition: Macros.h:910
const internal::variable_if_dynamicindex< Index, DiagIndex > m_index
Definition: Diagonal.h:133
internal::ref_selector< MatrixType >::non_const_type m_matrix
Definition: Diagonal.h:132
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85

References eigen_assert.

Member Function Documentation

◆ absDiagIndex()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::absDiagIndex ( ) const
inlineprivate
137  {
138  return m_index.value() > 0 ? m_index.value() : -m_index.value();
139  }
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:189

References Eigen::internal::variable_if_dynamicindex< T, Value >::value().

◆ coeff() [1/2]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC CoeffReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::coeff ( Index  idx) const
inline
121  {
122  return m_matrix.coeff(idx + rowOffset(), idx + colOffset());
123  }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rowOffset() const EIGEN_NOEXCEPT
Definition: Diagonal.h:140
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index colOffset() const EIGEN_NOEXCEPT
Definition: Diagonal.h:143

◆ coeff() [2/2]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC CoeffReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::coeff ( Index  row,
Index   
) const
inline
108  {
109  return m_matrix.coeff(row + rowOffset(), row + colOffset());
110  }
m row(1)

References row().

◆ coeffRef() [1/4]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  idx)
inline
112  {
114  return m_matrix.coeffRef(idx + rowOffset(), idx + colOffset());
115  }
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Definition: StaticAssert.h:87
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52

References EIGEN_STATIC_ASSERT_LVALUE.

◆ coeffRef() [2/4]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC const Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  idx) const
inline
117  {
118  return m_matrix.coeffRef(idx + rowOffset(), idx + colOffset());
119  }

◆ coeffRef() [3/4]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  row,
Index   
)
inline
99  {
101  return m_matrix.coeffRef(row + rowOffset(), row + colOffset());
102  }

References EIGEN_STATIC_ASSERT_LVALUE, and row().

Referenced by foo().

◆ coeffRef() [4/4]

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC const Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  row,
Index   
) const
inline
104  {
105  return m_matrix.coeffRef(row + rowOffset(), row + colOffset());
106  }

References row().

◆ colOffset()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::colOffset ( ) const
inlineprivate
143  {
144  return m_index.value() > 0 ? m_index.value() : 0;
145  }

References Eigen::internal::variable_if_dynamicindex< T, Value >::value().

◆ cols()

◆ data() [1/2]

◆ data() [2/2]

◆ index()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC Index Eigen::Diagonal< MatrixType, DiagIndex_ >::index ( ) const
inline
129 { return m_index.value(); }

◆ innerStride()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::innerStride ( ) const
inline
88  {
89  return m_matrix.outerStride() + 1;
90  }

◆ nestedExpression()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC const internal::remove_all_t<typename MatrixType::Nested>& Eigen::Diagonal< MatrixType, DiagIndex_ >::nestedExpression ( ) const
inline
125  {
126  return m_matrix;
127  }

◆ outerStride()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::outerStride ( ) const
inline
92 { return 0; }

◆ packet() [1/2]

template<typename MatrixType , int DiagIndex_>
template<int LoadMode>
MatrixType::PacketReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::packet ( Index  ) const
private

◆ packet() [2/2]

template<typename MatrixType , int DiagIndex_>
template<int LoadMode>
MatrixType::PacketReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::packet ( Index  ,
Index   
) const
private

◆ rowOffset()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::rowOffset ( ) const
inlineprivate
140  {
141  return m_index.value() > 0 ? 0 : -m_index.value();
142  }

References Eigen::internal::variable_if_dynamicindex< T, Value >::value().

◆ rows()

template<typename MatrixType , int DiagIndex_>
EIGEN_DEVICE_FUNC Index Eigen::Diagonal< MatrixType, DiagIndex_ >::rows ( ) const
inline
81  {
82  return m_index.value() < 0 ? numext::mini<Index>(m_matrix.cols(), m_matrix.rows() + m_index.value())
83  : numext::mini<Index>(m_matrix.rows(), m_matrix.cols() - m_index.value());
84  }
EIGEN_DEVICE_FUNC Index rows() const
Definition: Diagonal.h:81
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Diagonal.h:86
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: MathFunctions.h:920
squared absolute value
Definition: GlobalFunctions.h:87
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83

Referenced by gdb.printers._MatrixEntryIterator::__next__(), gdb.printers.EigenMatrixPrinter::children(), gdb.printers.EigenSparseMatrixPrinter::children(), gdb.printers.EigenMatrixPrinter::to_string(), and gdb.printers.EigenSparseMatrixPrinter::to_string().

Member Data Documentation

◆ m_index

template<typename MatrixType , int DiagIndex_>
const internal::variable_if_dynamicindex<Index, DiagIndex> Eigen::Diagonal< MatrixType, DiagIndex_ >::m_index
protected

◆ m_matrix

template<typename MatrixType , int DiagIndex_>
internal::ref_selector<MatrixType>::non_const_type Eigen::Diagonal< MatrixType, DiagIndex_ >::m_matrix
protected

The documentation for this class was generated from the following file: