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

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

Inherits internal::dense_xpr_base::type.

Public Types

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

Public Member Functions

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

Protected Attributes

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

Private Member Functions

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

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)

Definition at line 65 of file Diagonal.h.

Member Typedef Documentation

◆ Base

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

Definition at line 71 of file Diagonal.h.

◆ ScalarWithConstIfNotLvalue

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

Definition at line 104 of file Diagonal.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType , int DiagIndex_>
anonymous enum
Enumerator
DiagIndex 

Definition at line 70 of file Diagonal.h.

70 { DiagIndex = DiagIndex_ };

Constructor & Destructor Documentation

◆ Diagonal()

template<typename MatrixType , int DiagIndex_>
Eigen::Diagonal< MatrixType, DiagIndex_ >::Diagonal ( MatrixType matrix,
Index  a_index = DiagIndex 
)
inlineexplicit

Definition at line 75 of file Diagonal.h.

75  : m_matrix(matrix), m_index(a_index)
76  {
77  eigen_assert( a_index <= m_matrix.cols() && -a_index <= m_matrix.rows() );
78  }
#define eigen_assert(x)
Definition: Macros.h:902
const internal::variable_if_dynamicindex< Index, DiagIndex > m_index
Definition: Diagonal.h:164
internal::ref_selector< MatrixType >::non_const_type m_matrix
Definition: Diagonal.h:163

Member Function Documentation

◆ absDiagIndex()

template<typename MatrixType , int DiagIndex_>
EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::absDiagIndex ( ) const
inlineprivate

Definition at line 169 of file Diagonal.h.

169 { return m_index.value()>0 ? m_index.value() : -m_index.value(); }

◆ coeff() [1/2]

template<typename MatrixType , int DiagIndex_>
CoeffReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::coeff ( Index  idx) const
inline

Definition at line 144 of file Diagonal.h.

145  {
146  return m_matrix.coeff(idx+rowOffset(), idx+colOffset());
147  }
EIGEN_CONSTEXPR Index rowOffset() const EIGEN_NOEXCEPT
Definition: Diagonal.h:171
EIGEN_CONSTEXPR Index colOffset() const EIGEN_NOEXCEPT
Definition: Diagonal.h:173

◆ coeff() [2/2]

template<typename MatrixType , int DiagIndex_>
CoeffReturnType Eigen::Diagonal< MatrixType, DiagIndex_ >::coeff ( Index  row,
Index   
) const
inline

Definition at line 125 of file Diagonal.h.

126  {
127  return m_matrix.coeff(row+rowOffset(), row+colOffset());
128  }
RowXpr row(Index i)
This is the const version of row(). *‍/.

◆ coeffRef() [1/4]

template<typename MatrixType , int DiagIndex_>
Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  idx)
inline

Definition at line 131 of file Diagonal.h.

132  {
134  return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
135  }
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Definition: StaticAssert.h:96
Matrix< float, 1, Dynamic > MatrixType

◆ coeffRef() [2/4]

template<typename MatrixType , int DiagIndex_>
const Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  idx) const
inline

Definition at line 138 of file Diagonal.h.

139  {
140  return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
141  }

◆ coeffRef() [3/4]

template<typename MatrixType , int DiagIndex_>
Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  row,
Index   
)
inline

Definition at line 112 of file Diagonal.h.

113  {
115  return m_matrix.coeffRef(row+rowOffset(), row+colOffset());
116  }

◆ coeffRef() [4/4]

template<typename MatrixType , int DiagIndex_>
const Scalar& Eigen::Diagonal< MatrixType, DiagIndex_ >::coeffRef ( Index  row,
Index   
) const
inline

Definition at line 119 of file Diagonal.h.

120  {
121  return m_matrix.coeffRef(row+rowOffset(), row+colOffset());
122  }

◆ colOffset()

template<typename MatrixType , int DiagIndex_>
EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::colOffset ( ) const
inlineprivate

Definition at line 173 of file Diagonal.h.

173 { return m_index.value()>0 ? m_index.value() : 0; }

◆ cols()

template<typename MatrixType , int DiagIndex_>
EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::cols ( void  ) const
inline

Definition at line 90 of file Diagonal.h.

90 { return 1; }

◆ data() [1/2]

template<typename MatrixType , int DiagIndex_>
ScalarWithConstIfNotLvalue* Eigen::Diagonal< MatrixType, DiagIndex_ >::data ( )
inline

Definition at line 107 of file Diagonal.h.

107 { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }

◆ data() [2/2]

template<typename MatrixType , int DiagIndex_>
const Scalar* Eigen::Diagonal< MatrixType, DiagIndex_ >::data ( ) const
inline

Definition at line 109 of file Diagonal.h.

109 { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }

◆ index()

template<typename MatrixType , int DiagIndex_>
Index Eigen::Diagonal< MatrixType, DiagIndex_ >::index ( ) const
inline

Definition at line 157 of file Diagonal.h.

158  {
159  return m_index.value();
160  }

◆ innerStride()

template<typename MatrixType , int DiagIndex_>
EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::innerStride ( ) const
inline

Definition at line 93 of file Diagonal.h.

93  {
94  return m_matrix.outerStride() + 1;
95  }

◆ nestedExpression()

template<typename MatrixType , int DiagIndex_>
const internal::remove_all_t<typename MatrixType::Nested>& Eigen::Diagonal< MatrixType, DiagIndex_ >::nestedExpression ( ) const
inline

Definition at line 151 of file Diagonal.h.

152  {
153  return m_matrix;
154  }

◆ outerStride()

template<typename MatrixType , int DiagIndex_>
EIGEN_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::outerStride ( ) const
inline

Definition at line 98 of file Diagonal.h.

98 { 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_CONSTEXPR Index Eigen::Diagonal< MatrixType, DiagIndex_ >::rowOffset ( ) const
inlineprivate

Definition at line 171 of file Diagonal.h.

171 { return m_index.value()>0 ? 0 : -m_index.value(); }

◆ rows()

template<typename MatrixType , int DiagIndex_>
Index Eigen::Diagonal< MatrixType, DiagIndex_ >::rows ( void  ) const
inline

Definition at line 83 of file Diagonal.h.

84  {
85  return m_index.value()<0 ? numext::mini<Index>(m_matrix.cols(),m_matrix.rows()+m_index.value())
86  : numext::mini<Index>(m_matrix.rows(),m_matrix.cols()-m_index.value());
87  }
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Diagonal.h:90
Index rows() const
Definition: Diagonal.h:83
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82

Member Data Documentation

◆ m_index

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

Definition at line 164 of file Diagonal.h.

◆ m_matrix

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

Definition at line 163 of file Diagonal.h.


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