49 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
56 typedef typename remove_reference<XprTypeNested>::type
_XprTypeNested;
60 RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows,
61 ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols,
62 MaxRowsAtCompileTime = BlockRows==0 ? 0
63 : RowsAtCompileTime !=
Dynamic ? int(RowsAtCompileTime)
65 MaxColsAtCompileTime = BlockCols==0 ? 0
66 : ColsAtCompileTime !=
Dynamic ? int(ColsAtCompileTime)
70 IsRowMajor = (IsDense&&MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
71 : (IsDense&&MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
73 HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
74 InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
75 InnerStrideAtCompileTime = HasSameStorageOrderAsXprType
78 OuterStrideAtCompileTime = HasSameStorageOrderAsXprType
82 && (InnerStrideAtCompileTime == 1)
84 MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=
Dynamic) && (((OuterStrideAtCompileTime * int(
sizeof(Scalar))) % 16) == 0)) ?
AlignedBit : 0,
92 Flags = Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit
96 template<
typename XprType,
int BlockRows=
Dynamic,
int BlockCols=
Dynamic,
bool InnerPanel =
false,
101 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel,
typename StorageKind>
class BlockImpl;
103 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
class Block 104 :
public BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind>
110 EIGEN_GENERIC_PUBLIC_INTERFACE(
Block)
111 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
Block)
115 inline
Block(XprType& xpr, Index i) : Impl(xpr,i)
117 eigen_assert( (i>=0) && (
118 ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows())
119 ||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols())));
124 inline Block(XprType& xpr, Index a_startRow, Index a_startCol)
125 :
Impl(xpr, a_startRow, a_startCol)
127 EIGEN_STATIC_ASSERT(RowsAtCompileTime!=
Dynamic && ColsAtCompileTime!=
Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
128 eigen_assert(a_startRow >= 0 && BlockRows >= 1 && a_startRow + BlockRows <= xpr.rows()
129 && a_startCol >= 0 && BlockCols >= 1 && a_startCol + BlockCols <= xpr.cols());
135 Index a_startRow, Index a_startCol,
136 Index blockRows, Index blockCols)
137 :
Impl(xpr, a_startRow, a_startCol, blockRows, blockCols)
139 eigen_assert((RowsAtCompileTime==
Dynamic || RowsAtCompileTime==blockRows)
140 && (ColsAtCompileTime==
Dynamic || ColsAtCompileTime==blockCols));
141 eigen_assert(a_startRow >= 0 && blockRows >= 0 && a_startRow <= xpr.rows() - blockRows
142 && a_startCol >= 0 && blockCols >= 0 && a_startCol <= xpr.cols() - blockCols);
148 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
153 typedef typename XprType::Index Index;
156 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
BlockImpl)
157 inline BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {}
158 inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol) : Impl(xpr, a_startRow, a_startCol) {}
159 inline BlockImpl(XprType& xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols)
160 : Impl(xpr, a_startRow, a_startCol, blockRows, blockCols) {}
166 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel,
bool HasDirectAccess>
class BlockImpl_dense
173 EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
174 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)
186 m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
187 m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
188 m_blockRows(BlockRows==1 ? 1 : xpr.rows()),
189 m_blockCols(BlockCols==1 ? 1 : xpr.cols())
195 : m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol),
196 m_blockRows(BlockRows), m_blockCols(BlockCols)
202 Index a_startRow, Index a_startCol,
203 Index blockRows, Index blockCols)
204 : m_xpr(xpr), m_startRow(a_startRow), m_startCol(a_startCol),
205 m_blockRows(blockRows), m_blockCols(blockCols)
208 inline Index rows()
const {
return m_blockRows.value(); }
209 inline Index cols()
const {
return m_blockCols.value(); }
211 inline Scalar& coeffRef(Index rowId, Index colId)
213 EIGEN_STATIC_ASSERT_LVALUE(XprType)
214 return m_xpr.const_cast_derived()
215 .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
218 inline const Scalar& coeffRef(Index rowId, Index colId)
const 220 return m_xpr.derived()
221 .coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
224 EIGEN_STRONG_INLINE
const CoeffReturnType coeff(Index rowId, Index colId)
const 226 return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value());
229 inline Scalar& coeffRef(Index index)
231 EIGEN_STATIC_ASSERT_LVALUE(XprType)
232 return m_xpr.const_cast_derived()
233 .coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
234 m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
237 inline const Scalar& coeffRef(Index index)
const 239 return m_xpr.const_cast_derived()
240 .coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
241 m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
244 inline const CoeffReturnType coeff(Index index)
const 247 .coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
248 m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
251 template<
int LoadMode>
252 inline PacketScalar packet(Index rowId, Index colId)
const 254 return m_xpr.template packet<Unaligned>
255 (rowId + m_startRow.value(), colId + m_startCol.value());
258 template<
int LoadMode>
259 inline void writePacket(Index rowId, Index colId,
const PacketScalar& val)
261 m_xpr.const_cast_derived().template writePacket<Unaligned>
262 (rowId + m_startRow.value(), colId + m_startCol.value(), val);
265 template<
int LoadMode>
266 inline PacketScalar packet(Index index)
const 268 return m_xpr.template packet<Unaligned>
269 (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
270 m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
273 template<
int LoadMode>
274 inline void writePacket(Index index,
const PacketScalar& val)
276 m_xpr.const_cast_derived().template writePacket<Unaligned>
277 (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
278 m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), val);
281 #ifdef EIGEN_PARSED_BY_DOXYGEN 283 inline const Scalar* data()
const;
284 inline Index innerStride()
const;
285 inline Index outerStride()
const;
293 Index startRow()
const 295 return m_startRow.
value();
298 Index startCol()
const 300 return m_startCol.value();
305 const typename XprType::Nested m_xpr;
313 template<
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
315 :
public MapBase<Block<XprType, BlockRows, BlockCols, InnerPanel> >
321 EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
327 : Base(
internal::const_cast_ptr(&xpr.coeffRef(
328 (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0,
329 (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0)),
330 BlockRows==1 ? 1 : xpr.rows(),
331 BlockCols==1 ? 1 : xpr.cols()),
340 :
Base(
internal::const_cast_ptr(&xpr.coeffRef(startRow,startCol))), m_xpr(xpr)
348 Index startRow, Index startCol,
349 Index blockRows, Index blockCols)
350 :
Base(
internal::const_cast_ptr(&xpr.coeffRef(startRow,startCol)), blockRows, blockCols),
365 ? m_xpr.innerStride()
366 : m_xpr.outerStride();
372 return m_outerStride;
381 #ifndef EIGEN_PARSED_BY_DOXYGEN 383 inline BlockImpl_dense(XprType& xpr,
const Scalar* data, Index blockRows, Index blockCols)
384 :
Base(data, blockRows, blockCols), m_xpr(xpr)
394 ? m_xpr.outerStride()
395 : m_xpr.innerStride();
398 typename XprType::Nested m_xpr;
406 #endif // EIGEN_BLOCK_H Definition: DenseCoeffsBase.h:727
Base class for Map and Block expression with direct access.
Definition: ForwardDeclarations.h:109
BlockImpl_dense(XprType &xpr, Index a_startRow, Index a_startCol)
Fixed-size constructor.
Definition: Block.h:194
const Scalar & value() const
Definition: SparseUtil.h:164
const unsigned int DirectAccessBit
Means that the underlying array of coefficients can be directly accessed as a plain strided array...
Definition: Constants.h:142
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition: Constants.h:131
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:81
Definition: XprHelper.h:350
Definition: GenericPacketMath.h:71
const unsigned int AlignedBit
means the first coefficient packet is guaranteed to be aligned
Definition: Constants.h:147
Index outerStride() const
Definition: Block.h:370
BlockImpl_dense(XprType &xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols)
Dynamic-size constructor.
Definition: Block.h:201
BlockImpl_dense(XprType &xpr, Index i)
Column or Row constructor.
Definition: Block.h:180
Definition: ForwardDeclarations.h:25
Block(XprType &xpr, Index a_startRow, Index a_startCol)
Fixed-size constructor.
Definition: Block.h:124
BlockImpl_dense(XprType &xpr, Index startRow, Index startCol)
Fixed-size constructor.
Definition: Block.h:339
Definition: BandTriangularSolver.h:13
Index innerStride() const
Definition: Block.h:362
An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression...
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: DenseCoeffsBase.h:739
BlockImpl_dense(XprType &xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
Dynamic-size constructor.
Definition: Block.h:347
The type used to identify a dense storage.
Definition: Constants.h:428
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
Block(XprType &xpr, Index a_startRow, Index a_startCol, Index blockRows, Index blockCols)
Dynamic-size constructor.
Definition: Block.h:134
const unsigned int LinearAccessBit
Short version: means the expression can be seen as 1D vector.
Definition: Constants.h:117
Definition: ForwardDeclarations.h:17
Definition: XprHelper.h:459
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48