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) 46 SizeAtCompileTime = Base::SizeAtCompileTime
63 using Base::MaxRowsAtCompileTime;
64 using Base::MaxColsAtCompileTime;
65 using Base::MaxSizeAtCompileTime;
66 using Base::IsVectorAtCompileTime;
68 using Base::IsRowMajor;
75 using Base::lazyAssign;
78 using Base::innerStride;
79 using Base::outerStride;
80 using Base::rowStride;
81 using Base::colStride;
84 using Base::operator=;
89 EIGEN_DEVICE_FUNC
inline Index rows()
const {
return m_rows.value(); }
91 EIGEN_DEVICE_FUNC
inline Index cols()
const {
return m_cols.value(); }
99 EIGEN_DEVICE_FUNC
inline const Scalar*
data()
const {
return m_data; }
105 return m_data[colId * colStride() + rowId * rowStride()];
113 return m_data[index * innerStride()];
120 return this->m_data[colId * colStride() + rowId * rowStride()];
128 return this->m_data[index * innerStride()];
132 template<
int LoadMode>
135 return internal::ploadt<PacketScalar, LoadMode>
136 (m_data + (colId * colStride() + rowId * rowStride()));
140 template<
int LoadMode>
144 return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
149 explicit inline MapBase(
PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
152 checkSanity<Derived>();
159 m_rows(RowsAtCompileTime ==
Dynamic ? vecSize :
Index(RowsAtCompileTime)),
160 m_cols(ColsAtCompileTime ==
Dynamic ? vecSize :
Index(ColsAtCompileTime))
164 eigen_assert(dataPtr == 0 || SizeAtCompileTime ==
Dynamic || SizeAtCompileTime == vecSize);
165 checkSanity<Derived>();
171 : m_data(dataPtr), m_rows(rows), m_cols(cols)
174 || ( rows >= 0 && (RowsAtCompileTime ==
Dynamic || RowsAtCompileTime == rows)
175 && cols >= 0 && (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime == cols)));
176 checkSanity<Derived>();
179 #ifdef EIGEN_MAPBASE_PLUGIN 180 #include EIGEN_MAPBASE_PLUGIN 189 #if EIGEN_MAX_ALIGN_BYTES>0 191 || (cols() * rows() * innerStride() *
sizeof(Scalar)) < internal::traits<Derived>::Alignment ) &&
"data is not aligned");
216 :
public MapBase<Derived, ReadOnlyAccessors>
233 using Base::coeffRef;
235 using Base::innerStride;
236 using Base::outerStride;
237 using Base::rowStride;
238 using Base::colStride;
247 inline const Scalar*
data()
const {
return this->m_data; }
249 inline ScalarWithConstIfNotLvalue*
data() {
return this->m_data; }
254 return this->m_data[col * colStride() + row * rowStride()];
261 return this->m_data[index * innerStride()];
264 template<
int StoreMode>
267 internal::pstoret<Scalar, PacketScalar, StoreMode>
268 (this->m_data + (col * colStride() + row * rowStride()), val);
271 template<
int StoreMode>
275 internal::pstoret<Scalar, PacketScalar, StoreMode>
276 (this->m_data + index * innerStride(), val);
279 EIGEN_DEVICE_FUNC
explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {}
280 EIGEN_DEVICE_FUNC
inline MapBase(PointerType dataPtr,
Index vecSize) : Base(dataPtr, vecSize) {}
281 EIGEN_DEVICE_FUNC
inline MapBase(PointerType dataPtr,
Index rows,
Index cols) : Base(dataPtr, rows, cols) {}
286 ReadOnlyMapBase::Base::operator=(other);
292 using ReadOnlyMapBase::Base::operator=;
295 #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS 299 #endif // EIGEN_MAPBASE_H Base::CoeffReturnType CoeffReturnType
const internal::variable_if_dynamic< Index, ColsAtCompileTime > m_cols
internal::packet_traits< Scalar >::type PacketScalar
Base::PacketScalar PacketScalar
EIGEN_DEVICE_FUNC const Scalar * data() const
EIGEN_DEVICE_FUNC const Scalar & coeff(Index rowId, Index colId) const
void writePacket(Index index, const PacketScalar &val)
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
PacketScalar packet(Index rowId, Index colId) const
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr, Index vecSize)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Base::PointerType PointerType
internal::dense_xpr_base< Derived >::type Base
EIGEN_DEVICE_FUNC void checkSanity(typename internal::enable_if<(internal::traits< T >::Alignment >0), void * >::type=0) const
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue & coeffRef(Index index)
void writePacket(Index row, Index col, const PacketScalar &val)
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Base class for dense Map and Block expression with direct access.
EIGEN_DEVICE_FUNC void checkSanity(typename internal::enable_if< internal::traits< T >::Alignment==0, void * >::type=0) const
internal::conditional< bool(internal::is_lvalue< Derived >::value), Scalar *, const Scalar * >::type PointerType
PacketScalar packet(Index index) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC Derived & operator=(const MapBase &other)
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */.
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr, Index vecSize)
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)
MapBase< Derived, ReadOnlyAccessors > ReadOnlyMapBase
#define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr)
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue * data()
MapBase< Derived, ReadOnlyAccessors > Base
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr, Index rows, Index cols)
internal::traits< Derived >::StorageKind StorageKind
const internal::variable_if_dynamic< Index, RowsAtCompileTime > m_rows
EIGEN_DEVICE_FUNC const Scalar * data() const
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue & coeffRef(Index row, Index col)
EIGEN_DEVICE_FUNC Index cols() const
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr)
Base::StorageIndex StorageIndex
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index index) const
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index rowId, Index colId) const
EIGEN_DEVICE_FUNC MapBase(PointerType dataPtr, Index rows, Index cols)
internal::traits< Derived >::Scalar Scalar
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC Index rows() const
internal::conditional< internal::is_lvalue< Derived >::value, Scalar, const Scalar >::type ScalarWithConstIfNotLvalue
EIGEN_DEVICE_FUNC const Scalar & coeff(Index index) const