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::traits<Derived>::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \ 16 YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT) 36 SizeAtCompileTime = Base::SizeAtCompileTime
54 using Base::MaxRowsAtCompileTime;
55 using Base::MaxColsAtCompileTime;
56 using Base::MaxSizeAtCompileTime;
57 using Base::IsVectorAtCompileTime;
59 using Base::IsRowMajor;
66 using Base::lazyAssign;
69 using Base::innerStride;
70 using Base::outerStride;
71 using Base::rowStride;
72 using Base::colStride;
75 using Base::operator=;
77 typedef typename Base::CoeffReturnType CoeffReturnType;
79 inline Index rows()
const {
return m_rows.value(); }
80 inline Index cols()
const {
return m_cols.value(); }
88 inline const Scalar*
data()
const {
return m_data; }
90 inline const Scalar& coeff(Index rowId, Index colId)
const 92 return m_data[colId * colStride() + rowId * rowStride()];
95 inline const Scalar& coeff(Index index)
const 97 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
98 return m_data[index * innerStride()];
101 inline const Scalar& coeffRef(Index rowId, Index colId)
const 103 return this->m_data[colId * colStride() + rowId * rowStride()];
106 inline const Scalar& coeffRef(Index index)
const 108 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
109 return this->m_data[index * innerStride()];
112 template<
int LoadMode>
113 inline PacketScalar packet(Index rowId, Index colId)
const 115 return internal::ploadt<PacketScalar, LoadMode>
116 (m_data + (colId * colStride() + rowId * rowStride()));
119 template<
int LoadMode>
120 inline PacketScalar packet(Index index)
const 122 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
123 return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
126 explicit inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
128 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
132 inline MapBase(PointerType dataPtr, Index vecSize)
134 m_rows(RowsAtCompileTime ==
Dynamic ? vecSize : Index(RowsAtCompileTime)),
135 m_cols(ColsAtCompileTime ==
Dynamic ? vecSize : Index(ColsAtCompileTime))
137 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
138 eigen_assert(vecSize >= 0);
139 eigen_assert(dataPtr == 0 || SizeAtCompileTime ==
Dynamic || SizeAtCompileTime == vecSize);
143 inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols)
144 : m_data(dataPtr), m_rows(nbRows), m_cols(nbCols)
146 eigen_assert( (dataPtr == 0)
147 || ( nbRows >= 0 && (RowsAtCompileTime ==
Dynamic || RowsAtCompileTime == nbRows)
148 && nbCols >= 0 && (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime == nbCols)));
152 #ifdef EIGEN_MAPBASE_PLUGIN 153 #include EIGEN_MAPBASE_PLUGIN 158 void checkSanity()
const 162 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
164 &&
"input pointer is not aligned on a 16 byte boundary");
173 :
public MapBase<Derived, ReadOnlyAccessors>
182 typedef typename Base::Index Index;
190 using Base::coeffRef;
192 using Base::innerStride;
193 using Base::outerStride;
194 using Base::rowStride;
195 using Base::colStride;
203 inline const Scalar* data()
const {
return this->m_data; }
204 inline ScalarWithConstIfNotLvalue* data() {
return this->m_data; }
206 inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col)
208 return this->m_data[col * colStride() + row * rowStride()];
211 inline ScalarWithConstIfNotLvalue& coeffRef(Index index)
213 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
214 return this->m_data[index * innerStride()];
217 template<
int StoreMode>
218 inline void writePacket(Index row, Index col,
const PacketScalar& val)
220 internal::pstoret<Scalar, PacketScalar, StoreMode>
221 (this->m_data + (col * colStride() + row * rowStride()), val);
224 template<
int StoreMode>
225 inline void writePacket(Index index,
const PacketScalar& val)
227 EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
228 internal::pstoret<Scalar, PacketScalar, StoreMode>
229 (this->m_data + index * innerStride(), val);
232 explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {}
233 inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {}
234 inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols) : Base(dataPtr, nbRows, nbCols) {}
236 Derived& operator=(
const MapBase& other)
238 ReadOnlyMapBase::Base::operator=(other);
244 using ReadOnlyMapBase::Base::operator=;
247 #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS 251 #endif // EIGEN_MAPBASE_H Definition: gtest_unittest.cc:5031
Definition: DenseCoeffsBase.h:727
Base class for Map and Block expression with direct access.
Definition: ForwardDeclarations.h:109
Read/write access via member functions.
Definition: Constants.h:312
const Scalar * data() const
Returns a pointer to the first coefficient of the matrix or vector.
Definition: MapBase.h:88
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:81
Definition: XprHelper.h:350
const unsigned int AlignedBit
means the first coefficient packet is guaranteed to be aligned
Definition: Constants.h:147
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
Read-only access via a member function.
Definition: Constants.h:310
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
Definition: ForwardDeclarations.h:17
Definition: XprHelper.h:459
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48