Eigen::MapBase< Derived, ReadOnlyAccessors > Class Template Reference

Base class for dense Map and Block expression with direct access. More...

+ Inheritance diagram for Eigen::MapBase< Derived, ReadOnlyAccessors >:

Public Types

enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  InnerStrideAtCompileTime ,
  SizeAtCompileTime
}
 
typedef internal::dense_xpr_base< Derived >::type Base
 
typedef Base::CoeffReturnType CoeffReturnType
 
typedef internal::packet_traits< Scalar >::type PacketScalar
 
typedef std::conditional_t< bool(internal::is_lvalue< Derived >::value), Scalar *, const Scalar * > PointerType
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::traits< Derived >::Scalar Scalar
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

Public Member Functions

const Scalarcoeff (Index index) const
 
const Scalarcoeff (Index rowId, Index colId) const
 
const ScalarcoeffRef (Index index) const
 
const ScalarcoeffRef (Index rowId, Index colId) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
const Scalardata () const
 
 MapBase (PointerType dataPtr)
 
 MapBase (PointerType dataPtr, Index rows, Index cols)
 
 MapBase (PointerType dataPtr, Index vecSize)
 
template<int LoadMode>
PacketScalar packet (Index index) const
 
template<int LoadMode>
PacketScalar packet (Index rowId, Index colId) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 

Protected Member Functions

template<typename T >
void checkSanity (std::enable_if_t< internal::traits< T >::Alignment==0, void * >=0) const
 
template<typename T >
void checkSanity (std::enable_if_t<(internal::traits< T >::Alignment >0), void * >=0) const
 

Protected Attributes

const internal::variable_if_dynamic< Index, ColsAtCompileTimem_cols
 
PointerType m_data
 
const internal::variable_if_dynamic< Index, RowsAtCompileTimem_rows
 

Detailed Description

template<typename Derived>
class Eigen::MapBase< Derived, ReadOnlyAccessors >

Base class for dense Map and Block expression with direct access.

This base class provides the const low-level accessors (e.g. coeff, coeffRef) of dense Map and Block objects with direct access. Typical users do not have to directly deal with this class.

This class can be extended by through the macro plugin EIGEN_MAPBASE_PLUGIN. See customizing Eigen for details.

The Derived class has to provide the following two methods describing the memory layout:

Index innerStride() const;
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Index outerStride() const;
See also
class Map, class Block

Definition at line 39 of file MapBase.h.

Member Typedef Documentation

◆ Base

template<typename Derived >
typedef internal::dense_xpr_base<Derived>::type Eigen::MapBase< Derived, ReadOnlyAccessors >::Base

Definition at line 44 of file MapBase.h.

◆ CoeffReturnType

template<typename Derived >
typedef Base::CoeffReturnType Eigen::MapBase< Derived, ReadOnlyAccessors >::CoeffReturnType

Definition at line 89 of file MapBase.h.

◆ PacketScalar

template<typename Derived >
typedef internal::packet_traits<Scalar>::type Eigen::MapBase< Derived, ReadOnlyAccessors >::PacketScalar

Definition at line 54 of file MapBase.h.

◆ PointerType

template<typename Derived >
typedef std::conditional_t< bool(internal::is_lvalue<Derived>::value), Scalar *, const Scalar *> Eigen::MapBase< Derived, ReadOnlyAccessors >::PointerType

Definition at line 60 of file MapBase.h.

◆ RealScalar

template<typename Derived >
typedef NumTraits<Scalar>::Real Eigen::MapBase< Derived, ReadOnlyAccessors >::RealScalar

Definition at line 55 of file MapBase.h.

◆ Scalar

template<typename Derived >
typedef internal::traits<Derived>::Scalar Eigen::MapBase< Derived, ReadOnlyAccessors >::Scalar

Definition at line 53 of file MapBase.h.

◆ StorageKind

template<typename Derived >
typedef internal::traits<Derived>::StorageKind Eigen::MapBase< Derived, ReadOnlyAccessors >::StorageKind

Definition at line 52 of file MapBase.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
InnerStrideAtCompileTime 
SizeAtCompileTime 

Definition at line 45 of file MapBase.h.

45  {
46  RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
47  ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
48  InnerStrideAtCompileTime = internal::traits<Derived>::InnerStrideAtCompileTime,
49  SizeAtCompileTime = Base::SizeAtCompileTime
50  };

Constructor & Destructor Documentation

◆ MapBase() [1/3]

template<typename Derived >
Eigen::MapBase< Derived, ReadOnlyAccessors >::MapBase ( PointerType  dataPtr)
inlineexplicit

Definition at line 154 of file MapBase.h.

155  {
157  checkSanity<Derived>();
158  }
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)
Definition: StaticAssert.h:41
const internal::variable_if_dynamic< Index, ColsAtCompileTime > m_cols
Definition: MapBase.h:212
const internal::variable_if_dynamic< Index, RowsAtCompileTime > m_rows
Definition: MapBase.h:211

◆ MapBase() [2/3]

template<typename Derived >
Eigen::MapBase< Derived, ReadOnlyAccessors >::MapBase ( PointerType  dataPtr,
Index  vecSize 
)
inline

Definition at line 162 of file MapBase.h.

163  : m_data(dataPtr),
166  {
168  eigen_assert(vecSize >= 0);
169  eigen_assert(dataPtr == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == vecSize);
170  checkSanity<Derived>();
171  }
#define eigen_assert(x)
Definition: Macros.h:902
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
const int Dynamic
Definition: Constants.h:24

◆ MapBase() [3/3]

template<typename Derived >
Eigen::MapBase< Derived, ReadOnlyAccessors >::MapBase ( PointerType  dataPtr,
Index  rows,
Index  cols 
)
inline

Definition at line 175 of file MapBase.h.

176  : m_data(dataPtr), m_rows(rows), m_cols(cols)
177  {
178  eigen_assert( (dataPtr == 0)
179  || ( rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
180  && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
181  checkSanity<Derived>();
182  }
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: MapBase.h:93
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: MapBase.h:96

Member Function Documentation

◆ checkSanity() [1/2]

template<typename Derived >
template<typename T >
void Eigen::MapBase< Derived, ReadOnlyAccessors >::checkSanity ( std::enable_if_t< internal::traits< T >::Alignment==0, void * >  = 0) const
inlineprotected

Definition at line 207 of file MapBase.h.

208  {}

◆ checkSanity() [2/2]

template<typename Derived >
template<typename T >
void Eigen::MapBase< Derived, ReadOnlyAccessors >::checkSanity ( std::enable_if_t<(internal::traits< T >::Alignment >0), void * >  = 0) const
inlineprotected

Definition at line 194 of file MapBase.h.

195  {
196 #if EIGEN_MAX_ALIGN_BYTES>0
197  // innerStride() is not set yet when this function is called, so we optimistically assume the lowest plausible value:
198  const Index minInnerStride = InnerStrideAtCompileTime == Dynamic ? 1 : Index(InnerStrideAtCompileTime);
199  EIGEN_ONLY_USED_FOR_DEBUG(minInnerStride);
200  eigen_assert(( ((std::uintptr_t(m_data) % internal::traits<Derived>::Alignment) == 0)
201  || (cols() * rows() * minInnerStride * sizeof(Scalar)) < internal::traits<Derived>::Alignment ) && "data is not aligned");
202 #endif
203  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:914
internal::traits< Derived >::Scalar Scalar
Definition: MapBase.h:53

◆ coeff() [1/2]

template<typename Derived >
const Scalar& Eigen::MapBase< Derived, ReadOnlyAccessors >::coeff ( Index  index) const
inline

This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.

See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details.

Definition at line 115 of file MapBase.h.

116  {
118  return m_data[index * innerStride()];
119  }
#define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
Definition: MapBase.h:14

◆ coeff() [2/2]

template<typename Derived >
const Scalar& Eigen::MapBase< Derived, ReadOnlyAccessors >::coeff ( Index  rowId,
Index  colId 
) const
inline

This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index,Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.

See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details.

Definition at line 108 of file MapBase.h.

109  {
110  return m_data[colId * colStride() + rowId * rowStride()];
111  }

◆ coeffRef() [1/2]

template<typename Derived >
const Scalar& Eigen::MapBase< Derived, ReadOnlyAccessors >::coeffRef ( Index  index) const
inline

This is the const version of coeffRef(Index) which is thus synonym of coeff(Index). It is provided for convenience.

Definition at line 130 of file MapBase.h.

131  {
133  return this->m_data[index * innerStride()];
134  }

◆ coeffRef() [2/2]

template<typename Derived >
const Scalar& Eigen::MapBase< Derived, ReadOnlyAccessors >::coeffRef ( Index  rowId,
Index  colId 
) const
inline

This is the const version of coeffRef(Index,Index) which is thus synonym of coeff(Index,Index). It is provided for convenience.

Definition at line 123 of file MapBase.h.

124  {
125  return this->m_data[colId * colStride() + rowId * rowStride()];
126  }

◆ cols()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::MapBase< Derived, ReadOnlyAccessors >::cols ( void  ) const
inline

Returns
the number of columns.
See also
rows(), ColsAtCompileTime

Definition at line 96 of file MapBase.h.

96 { return m_cols.value(); }

◆ data()

template<typename Derived >
const Scalar* Eigen::MapBase< Derived, ReadOnlyAccessors >::data ( ) const
inline

Returns a pointer to the first coefficient of the matrix or vector.

Note
When addressing this data, make sure to honor the strides returned by innerStride() and outerStride().
See also
innerStride(), outerStride()

Definition at line 104 of file MapBase.h.

104 { return m_data; }

◆ packet() [1/2]

template<typename Derived >
template<int LoadMode>
PacketScalar Eigen::MapBase< Derived, ReadOnlyAccessors >::packet ( Index  index) const
inline

Definition at line 146 of file MapBase.h.

147  {
149  return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
150  }

◆ packet() [2/2]

template<typename Derived >
template<int LoadMode>
PacketScalar Eigen::MapBase< Derived, ReadOnlyAccessors >::packet ( Index  rowId,
Index  colId 
) const
inline

Definition at line 138 of file MapBase.h.

139  {
140  return internal::ploadt<PacketScalar, LoadMode>
141  (m_data + (colId * colStride() + rowId * rowStride()));
142  }

◆ rows()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::MapBase< Derived, ReadOnlyAccessors >::rows ( void  ) const
inline

Returns
the number of rows.
See also
cols(), RowsAtCompileTime

Definition at line 93 of file MapBase.h.

93 { return m_rows.value(); }

Member Data Documentation

◆ m_cols

template<typename Derived >
const internal::variable_if_dynamic<Index, ColsAtCompileTime> Eigen::MapBase< Derived, ReadOnlyAccessors >::m_cols
protected

Definition at line 212 of file MapBase.h.

◆ m_data

template<typename Derived >
PointerType Eigen::MapBase< Derived, ReadOnlyAccessors >::m_data
protected

Definition at line 210 of file MapBase.h.

◆ m_rows

template<typename Derived >
const internal::variable_if_dynamic<Index, RowsAtCompileTime> Eigen::MapBase< Derived, ReadOnlyAccessors >::m_rows
protected

Definition at line 211 of file MapBase.h.


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