11 #ifndef EIGEN_DIAGONAL_H
12 #define EIGEN_DIAGONAL_H
38 template<
typename MatrixType,
int DiagIndex>
42 typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
43 typedef std::remove_reference_t<MatrixTypeNested> MatrixTypeNested_;
49 ColsAtCompileTime = 1,
50 MaxRowsAtCompileTime =
int(MatrixType::MaxSizeAtCompileTime) ==
Dynamic ?
Dynamic
52 MatrixType::MaxColsAtCompileTime)
55 MaxColsAtCompileTime = 1,
58 MatrixTypeOuterStride = outer_stride_at_compile_time<
MatrixType>::ret,
59 InnerStrideAtCompileTime = MatrixTypeOuterStride ==
Dynamic ?
Dynamic : MatrixTypeOuterStride+1,
60 OuterStrideAtCompileTime = 0
65 template<
typename MatrixType,
int DiagIndex_>
class Diagonal
66 :
public internal::dense_xpr_base< Diagonal<MatrixType,DiagIndex_> >::type
70 enum { DiagIndex = DiagIndex_ };
71 typedef typename internal::dense_xpr_base<Diagonal>::type
Base;
77 eigen_assert( a_index <= m_matrix.cols() && -a_index <= m_matrix.rows() );
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());
94 return m_matrix.outerStride() + 1;
100 typedef std::conditional_t<
101 internal::is_lvalue<MatrixType>::value,
109 inline const Scalar*
data()
const {
return &(m_matrix.coeffRef(rowOffset(), colOffset())); }
115 return m_matrix.coeffRef(
row+rowOffset(),
row+colOffset());
121 return m_matrix.coeffRef(
row+rowOffset(),
row+colOffset());
127 return m_matrix.coeff(
row+rowOffset(),
row+colOffset());
134 return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
140 return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
146 return m_matrix.coeff(idx+rowOffset(), idx+colOffset());
159 return m_index.value();
163 typename internal::ref_selector<MatrixType>::non_const_type
m_matrix;
164 const internal::variable_if_dynamicindex<Index, DiagIndex>
m_index;
187 template<
typename Derived>
195 template<
typename Derived>
214 template<
typename Derived>
222 template<
typename Derived>
240 template<
typename Derived>
250 template<
typename Derived>
253 inline const Diagonal<const Derived, Index_>
256 return Diagonal<const Derived, Index_>(derived());
RowXpr row(Index i)
This is the const version of row(). */.
#define EIGEN_DEVICE_FUNC
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Matrix< float, 1, Dynamic > MatrixType
internal::traits< Derived >::StorageKind StorageKind
internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
const Scalar & coeffRef(Index row, Index) const
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
internal::dense_xpr_base< Diagonal >::type Base
CoeffReturnType coeff(Index row, Index) const
Scalar & coeffRef(Index row, Index)
MatrixType::PacketReturnType packet(Index, Index) const
const internal::variable_if_dynamicindex< Index, DiagIndex > m_index
const internal::remove_all_t< typename MatrixType::Nested > & nestedExpression() const
EIGEN_CONSTEXPR Index absDiagIndex() const EIGEN_NOEXCEPT
MatrixType::PacketReturnType packet(Index) const
std::conditional_t< internal::is_lvalue< MatrixType >::value, Scalar, const Scalar > ScalarWithConstIfNotLvalue
EIGEN_CONSTEXPR Index rowOffset() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
ScalarWithConstIfNotLvalue * data()
CoeffReturnType coeff(Index idx) const
Scalar & coeffRef(Index idx)
Diagonal(MatrixType &matrix, Index a_index=DiagIndex)
internal::ref_selector< MatrixType >::non_const_type m_matrix
const Scalar & coeffRef(Index idx) const
const Scalar * data() const
EIGEN_CONSTEXPR Index colOffset() const EIGEN_NOEXCEPT
DiagonalReturnType diagonal()
const unsigned int DirectAccessBit
const unsigned int LvalueBit
const unsigned int RowMajorBit
constexpr int plain_enum_min(A a, B b)
constexpr int plain_enum_max(A a, B b)
constexpr int min_size_prefer_fixed(A a, B b)
typename remove_all< T >::type remove_all_t
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::Index Index
The interface type of indices.