11 #ifndef EIGEN_MAPBASE_H
12 #define EIGEN_MAPBASE_H
14 #define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) \
15 EIGEN_STATIC_ASSERT((int(internal::evaluator<Derived>::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \
16 YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT)
40 :
public internal::dense_xpr_base<Derived>::type
44 typedef typename internal::dense_xpr_base<Derived>::type
Base;
46 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
47 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
48 InnerStrideAtCompileTime = internal::traits<Derived>::InnerStrideAtCompileTime,
49 SizeAtCompileTime = Base::SizeAtCompileTime
52 typedef typename internal::traits<Derived>::StorageKind
StorageKind;
53 typedef typename internal::traits<Derived>::Scalar
Scalar;
54 typedef typename internal::packet_traits<Scalar>::type
PacketScalar;
56 typedef std::conditional_t<
57 bool(internal::is_lvalue<Derived>::value),
66 using Base::MaxRowsAtCompileTime;
67 using Base::MaxColsAtCompileTime;
68 using Base::MaxSizeAtCompileTime;
69 using Base::IsVectorAtCompileTime;
71 using Base::IsRowMajor;
78 using Base::lazyAssign;
81 using Base::innerStride;
82 using Base::outerStride;
83 using Base::rowStride;
84 using Base::colStride;
87 using Base::operator=;
110 return m_data[colId * colStride() + rowId * rowStride()];
118 return m_data[index * innerStride()];
125 return this->m_data[colId * colStride() + rowId * rowStride()];
133 return this->m_data[index * innerStride()];
137 template<
int LoadMode>
140 return internal::ploadt<PacketScalar, LoadMode>
141 (m_data + (colId * colStride() + rowId * rowStride()));
145 template<
int LoadMode>
149 return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
154 explicit inline MapBase(
PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
157 checkSanity<Derived>();
164 m_rows(RowsAtCompileTime ==
Dynamic ? vecSize :
Index(RowsAtCompileTime)),
165 m_cols(ColsAtCompileTime ==
Dynamic ? vecSize :
Index(ColsAtCompileTime))
169 eigen_assert(dataPtr == 0 || SizeAtCompileTime ==
Dynamic || SizeAtCompileTime == vecSize);
170 checkSanity<Derived>();
176 : m_data(dataPtr), m_rows(
rows), m_cols(
cols)
179 || (
rows >= 0 && (RowsAtCompileTime ==
Dynamic || RowsAtCompileTime ==
rows)
180 &&
cols >= 0 && (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime ==
cols)));
181 checkSanity<Derived>();
184 #ifdef EIGEN_MAPBASE_PLUGIN
185 #include EIGEN_MAPBASE_PLUGIN
194 void checkSanity(std::enable_if_t<(internal::traits<T>::Alignment>0),
void*> = 0)
const
196 #if EIGEN_MAX_ALIGN_BYTES>0
198 const Index minInnerStride = InnerStrideAtCompileTime ==
Dynamic ? 1 :
Index(InnerStrideAtCompileTime);
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");
207 void checkSanity(std::enable_if_t<internal::traits<T>::Alignment==0,
void*> = 0)
const
211 const internal::variable_if_dynamic<Index, RowsAtCompileTime>
m_rows;
212 const internal::variable_if_dynamic<Index, ColsAtCompileTime>
m_cols;
226 :
public MapBase<Derived, ReadOnlyAccessors>
243 using Base::coeffRef;
245 using Base::innerStride;
246 using Base::outerStride;
247 using Base::rowStride;
248 using Base::colStride;
250 typedef std::conditional_t<
251 internal::is_lvalue<Derived>::value,
264 return this->m_data[
col * colStride() +
row * rowStride()];
271 return this->m_data[index * innerStride()];
274 template<
int StoreMode>
277 internal::pstoret<Scalar, PacketScalar, StoreMode>
278 (this->m_data + (
col * colStride() +
row * rowStride()), val);
281 template<
int StoreMode>
285 internal::pstoret<Scalar, PacketScalar, StoreMode>
286 (this->m_data + index * innerStride(), val);
296 ReadOnlyMapBase::Base::operator=(other);
302 using ReadOnlyMapBase::Base::operator=;
308 #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS
RowXpr row(Index i)
This is the const version of row(). */.
ColXpr col(Index i)
This is the const version of col().
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
#define EIGEN_DEVICE_FUNC
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
#define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Base class for dense Map and Block expression with direct access.
const Scalar * data() const
PacketScalar packet(Index rowId, Index colId) const
internal::dense_xpr_base< Derived >::type Base
internal::packet_traits< Scalar >::type PacketScalar
Base::CoeffReturnType CoeffReturnType
const Scalar & coeffRef(Index index) const
const Scalar & coeff(Index rowId, Index colId) const
PacketScalar packet(Index index) const
const internal::variable_if_dynamic< Index, ColsAtCompileTime > m_cols
MapBase(PointerType dataPtr, Index vecSize)
void checkSanity(std::enable_if_t<(internal::traits< T >::Alignment >0), void * >=0) const
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
internal::traits< Derived >::Scalar Scalar
const internal::variable_if_dynamic< Index, RowsAtCompileTime > m_rows
MapBase(PointerType dataPtr, Index rows, Index cols)
const Scalar & coeffRef(Index rowId, Index colId) const
void checkSanity(std::enable_if_t< internal::traits< T >::Alignment==0, void * >=0) const
NumTraits< Scalar >::Real RealScalar
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
MapBase(PointerType dataPtr)
const Scalar & coeff(Index index) const
std::conditional_t< bool(internal::is_lvalue< Derived >::value), Scalar *, const Scalar * > PointerType
internal::traits< Derived >::StorageKind StorageKind
ScalarWithConstIfNotLvalue & coeffRef(Index row, Index col)
Base::PacketScalar PacketScalar
MapBase< Derived, ReadOnlyAccessors > Base
MapBase(PointerType dataPtr)
Base::StorageIndex StorageIndex
void writePacket(Index row, Index col, const PacketScalar &val)
MapBase< Derived, ReadOnlyAccessors > ReadOnlyMapBase
Base::PointerType PointerType
void writePacket(Index index, const PacketScalar &val)
ScalarWithConstIfNotLvalue * data()
MapBase(PointerType dataPtr, Index rows, Index cols)
ScalarWithConstIfNotLvalue & coeffRef(Index index)
Derived & operator=(const MapBase &other)
std::conditional_t< internal::is_lvalue< Derived >::value, Scalar, const Scalar > ScalarWithConstIfNotLvalue
MapBase(PointerType dataPtr, Index vecSize)
const Scalar * data() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.