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=;
86 typedef typename Base::CoeffReturnType CoeffReturnType;
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()];
112 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
113 return m_data[index * innerStride()];
120 return this->m_data[colId * colStride() + rowId * rowStride()];
127 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
128 return this->m_data[index * innerStride()];
132 template<
int LoadMode>
133 inline PacketScalar packet(
Index rowId,
Index colId)
const 135 return internal::ploadt<PacketScalar, LoadMode>
136 (m_data + (colId * colStride() + rowId * rowStride()));
140 template<
int LoadMode>
141 inline PacketScalar packet(
Index index)
const 143 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
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)
151 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
152 checkSanity<Derived>();
157 inline MapBase(PointerType dataPtr,
Index vecSize)
159 m_rows(RowsAtCompileTime ==
Dynamic ? vecSize :
Index(RowsAtCompileTime)),
160 m_cols(ColsAtCompileTime ==
Dynamic ? vecSize :
Index(ColsAtCompileTime))
162 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
163 eigen_assert(vecSize >= 0);
164 eigen_assert(dataPtr == 0 || SizeAtCompileTime ==
Dynamic || SizeAtCompileTime == vecSize);
165 checkSanity<Derived>();
170 inline MapBase(PointerType dataPtr,
Index rows,
Index cols)
171 : m_data(dataPtr), m_rows(rows), m_cols(cols)
173 eigen_assert( (dataPtr == 0)
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>
223 typedef typename Base::Scalar Scalar;
225 typedef typename Base::StorageIndex StorageIndex;
226 typedef typename Base::PointerType PointerType;
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; }
252 inline ScalarWithConstIfNotLvalue& coeffRef(
Index row,
Index col)
254 return this->m_data[col * colStride() + row * rowStride()];
258 inline ScalarWithConstIfNotLvalue& coeffRef(
Index index)
260 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
261 return this->m_data[index * innerStride()];
264 template<
int StoreMode>
265 inline void writePacket(
Index row,
Index col,
const PacketScalar& val)
267 internal::pstoret<Scalar, PacketScalar, StoreMode>
268 (this->m_data + (col * colStride() + row * rowStride()), val);
271 template<
int StoreMode>
272 inline void writePacket(
Index index,
const PacketScalar& val)
274 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
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) {}
284 Derived& operator=(
const MapBase& other)
286 ReadOnlyMapBase::Base::operator=(other);
292 using ReadOnlyMapBase::Base::operator=;
295 #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS 299 #endif // EIGEN_MAPBASE_H Definition: ForwardDeclarations.h:114
Read/write access via member functions.
Definition: Constants.h:368
EIGEN_DEVICE_FUNC const Scalar & coeff(Index index) const
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const provi...
Definition: MapBase.h:110
EIGEN_DEVICE_FUNC const Scalar & coeff(Index rowId, Index colId) const
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.
Definition: MapBase.h:103
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
Definition: XprHelper.h:463
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index index) const
This is the const version of coeffRef(Index) which is thus synonym of coeff(Index).
Definition: MapBase.h:125
Read-only access via a member function.
Definition: Constants.h:366
Base class for dense Map and Block expression with direct access.
Definition: MapBase.h:37
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
EIGEN_DEVICE_FUNC const Scalar * data() const
Returns a pointer to the first coefficient of the matrix or vector.
Definition: MapBase.h:99
EIGEN_DEVICE_FUNC Index cols() const
Definition: MapBase.h:91
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Definition: ForwardDeclarations.h:17
Definition: XprHelper.h:630
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index rowId, Index colId) const
This is the const version of coeffRef(Index,Index) which is thus synonym of coeff(Index,Index).
Definition: MapBase.h:118
EIGEN_DEVICE_FUNC Index rows() const
Definition: MapBase.h:89