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

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

#include <MapBase.h>

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

Public Types

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

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:83
Index outerStride() const;
See also
class Map, class Block

Member Typedef Documentation

◆ Base

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

◆ CoeffReturnType

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

◆ PacketScalar

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

◆ PointerType

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

◆ RealScalar

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

◆ Scalar

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

◆ StorageKind

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

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
InnerStrideAtCompileTime 
SizeAtCompileTime 
44  {
45  RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
46  ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
47  InnerStrideAtCompileTime = internal::traits<Derived>::InnerStrideAtCompileTime,
48  SizeAtCompileTime = Base::SizeAtCompileTime
49  };
@ InnerStrideAtCompileTime
Definition: MapBase.h:47
@ SizeAtCompileTime
Definition: MapBase.h:48
@ RowsAtCompileTime
Definition: MapBase.h:45
@ ColsAtCompileTime
Definition: MapBase.h:46

Constructor & Destructor Documentation

◆ MapBase() [1/3]

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

Constructor for fixed size matrices or vectors

138  checkSanity<Derived>();
139  }
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)
Definition: StaticAssert.h:40
const internal::variable_if_dynamic< Index, ColsAtCompileTime > m_cols
Definition: MapBase.h:197
PointerType m_data
Definition: MapBase.h:195
const internal::variable_if_dynamic< Index, RowsAtCompileTime > m_rows
Definition: MapBase.h:196

References EIGEN_STATIC_ASSERT_FIXED_SIZE.

◆ MapBase() [2/3]

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

Constructor for dynamically sized vectors

143  : m_data(dataPtr),
147  eigen_assert(vecSize >= 0);
148  eigen_assert(dataPtr == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == vecSize);
149  checkSanity<Derived>();
150  }
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
const int Dynamic
Definition: Constants.h:25

References Eigen::Dynamic, eigen_assert, and EIGEN_STATIC_ASSERT_VECTOR_ONLY.

◆ MapBase() [3/3]

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

Constructor for dynamically sized matrices

154  : m_data(dataPtr), m_rows(rows), m_cols(cols) {
155  eigen_assert((dataPtr == 0) || (rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) &&
156  cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
157  checkSanity<Derived>();
158  }
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: MapBase.h:87
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: MapBase.h:89

References cols, Eigen::Dynamic, eigen_assert, and rows.

Member Function Documentation

◆ checkSanity() [1/2]

template<typename Derived >
template<typename T >
EIGEN_DEVICE_FUNC void Eigen::MapBase< Derived, ReadOnlyAccessors >::checkSanity ( std::enable_if_t< internal::traits< T >::Alignment==0, void * >  = 0) const
inlineprotected
188  {
189 #ifndef EIGEN_ALLOW_UNALIGNED_SCALARS
190  // Pointer must be aligned to the Scalar type, otherwise we get UB.
191  eigen_assert((std::uintptr_t(m_data) % alignof(Scalar) == 0) && "data is not scalar-aligned");
192 #endif
193  }
SCALAR Scalar
Definition: bench_gemm.cpp:45

References eigen_assert.

◆ checkSanity() [2/2]

template<typename Derived >
template<typename T >
EIGEN_DEVICE_FUNC void Eigen::MapBase< Derived, ReadOnlyAccessors >::checkSanity ( std::enable_if_t<(internal::traits< T >::Alignment > 0), void * >  = 0) const
inlineprotected
169  {
170 // Temporary macro to allow scalars to not be properly aligned. This is while we sort out failures
171 // in TensorFlow Lite that are currently relying on this UB.
172 #ifndef EIGEN_ALLOW_UNALIGNED_SCALARS
173  // Pointer must be aligned to the Scalar type, otherwise we get UB.
174  eigen_assert((std::uintptr_t(m_data) % alignof(Scalar) == 0) && "data is not scalar-aligned");
175 #endif
176 #if EIGEN_MAX_ALIGN_BYTES > 0
177  // innerStride() is not set yet when this function is called, so we optimistically assume the lowest plausible
178  // value:
179  const Index minInnerStride = InnerStrideAtCompileTime == Dynamic ? 1 : Index(InnerStrideAtCompileTime);
180  EIGEN_ONLY_USED_FOR_DEBUG(minInnerStride);
181  eigen_assert((((std::uintptr_t(m_data) % internal::traits<Derived>::Alignment) == 0) ||
182  (cols() * rows() * minInnerStride * sizeof(Scalar)) < internal::traits<Derived>::Alignment) &&
183  "data is not aligned");
184 #endif
185  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922

References cols, Eigen::Dynamic, eigen_assert, EIGEN_ONLY_USED_FOR_DEBUG, and rows.

◆ coeff() [1/2]

template<typename Derived >
EIGEN_DEVICE_FUNC 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.

105  {
107  return m_data[index * innerStride()];
108  }
#define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
Definition: MapBase.h:14

References EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS.

◆ coeff() [2/2]

template<typename Derived >
EIGEN_DEVICE_FUNC 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.

100  {
101  return m_data[colId * colStride() + rowId * rowStride()];
102  }

◆ coeffRef() [1/2]

template<typename Derived >
EIGEN_DEVICE_FUNC 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.

116  {
118  return this->m_data[index * innerStride()];
119  }

References EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS.

◆ coeffRef() [2/2]

template<typename Derived >
EIGEN_DEVICE_FUNC 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.

111  {
112  return this->m_data[colId * colStride() + rowId * rowStride()];
113  }

◆ cols()

◆ data()

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

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()
97 { return m_data; }

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

◆ packet() [1/2]

template<typename Derived >
template<int LoadMode>
PacketScalar Eigen::MapBase< Derived, ReadOnlyAccessors >::packet ( Index  index) const
inline
129  {
131  return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
132  }

References EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS.

◆ packet() [2/2]

template<typename Derived >
template<int LoadMode>
PacketScalar Eigen::MapBase< Derived, ReadOnlyAccessors >::packet ( Index  rowId,
Index  colId 
) const
inline
123  {
124  return internal::ploadt<PacketScalar, LoadMode>(m_data + (colId * colStride() + rowId * rowStride()));
125  }

◆ rows()

Member Data Documentation

◆ m_cols

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

◆ m_data

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

◆ m_rows

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

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