11 #ifndef EIGEN_RESHAPED_H 12 #define EIGEN_RESHAPED_H 48 template<
typename XprType,
int Rows,
int Cols,
int Order>
57 RowsAtCompileTime = Rows,
59 MaxRowsAtCompileTime = Rows,
60 MaxColsAtCompileTime =
Cols,
62 ReshapedStorageOrder = (RowsAtCompileTime == 1 && ColsAtCompileTime != 1) ?
RowMajor 63 : (ColsAtCompileTime == 1 && RowsAtCompileTime != 1) ?
ColMajor 65 HasSameStorageOrderAsXprType = (ReshapedStorageOrder == XpxStorageOrder),
66 InnerSize = (ReshapedStorageOrder==
int(
RowMajor)) ?
int(ColsAtCompileTime) :
int(RowsAtCompileTime),
67 InnerStrideAtCompileTime = HasSameStorageOrderAsXprType
73 && (Order==int(XpxStorageOrder))
77 && (InnerStrideAtCompileTime == 1)
80 FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ?
LinearAccessBit : 0,
86 Flags = (Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit | FlagsDirectAccessBit)
90 template<
typename XprType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
class ReshapedImpl_dense;
94 template<
typename XprType,
int Rows,
int Cols,
int Order,
typename StorageKind>
class ReshapedImpl;
96 template<
typename XprType,
int Rows,
int Cols,
int Order>
class Reshaped 97 :
public ReshapedImpl<XprType, Rows, Cols, Order, typename internal::traits<XprType>::StorageKind>
121 : Impl(xpr, reshapeRows, reshapeCols)
124 && (ColsAtCompileTime==
Dynamic || ColsAtCompileTime==reshapeCols));
131 template<
typename XprType,
int Rows,
int Cols,
int Order>
141 : Impl(xpr, reshapeRows, reshapeCols) {}
147 template<
typename XprType,
int Rows,
int Cols,
int Order>
167 : m_xpr(xpr), m_rows(Rows), m_cols(
Cols)
174 : m_xpr(xpr), m_rows(nRows), m_cols(nCols)
180 #ifdef EIGEN_PARSED_BY_DOXYGEN 206 template<
typename XprType,
int Rows,
int Cols,
int Order>
208 :
public MapBase<Reshaped<XprType, Rows, Cols, Order> >
222 : Base(xpr.
data()), m_xpr(xpr)
229 : Base(xpr.
data(), nRows, nCols),
246 return m_xpr.innerStride();
262 template<
typename ArgType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
struct reshaped_evaluator;
264 template<
typename ArgType,
int Rows,
int Cols,
int Order>
266 :
reshaped_evaluator<ArgType, Rows, Cols, Order, traits<Reshaped<ArgType,Rows,Cols,Order> >::HasDirectAccess>
291 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit | FlagsDirectAccessBit,
303 template<
typename ArgType,
int Rows,
int Cols,
int Order>
331 const Index nth_elem_idx = colId * m_xpr.rows() + rowId;
332 return RowCol(nth_elem_idx % m_xpr.nestedExpression().rows(),
333 nth_elem_idx / m_xpr.nestedExpression().rows());
337 const Index nth_elem_idx = colId + rowId * m_xpr.cols();
338 return RowCol(nth_elem_idx / m_xpr.nestedExpression().cols(),
339 nth_elem_idx % m_xpr.nestedExpression().cols());
347 const RowCol row_col = index_remap(rowId, colId);
348 return m_argImpl.coeffRef(row_col.first, row_col.second);
354 const RowCol row_col = index_remap(rowId, colId);
355 return m_argImpl.coeffRef(row_col.first, row_col.second);
361 const RowCol row_col = index_remap(rowId, colId);
362 return m_argImpl.coeff(row_col.first, row_col.second);
369 const RowCol row_col = index_remap(Rows == 1 ? 0 : index,
370 Rows == 1 ? index : 0);
371 return m_argImpl.coeffRef(row_col.first, row_col.second);
378 const RowCol row_col = index_remap(Rows == 1 ? 0 : index,
379 Rows == 1 ? index : 0);
380 return m_argImpl.coeffRef(row_col.first, row_col.second);
386 const RowCol row_col = index_remap(Rows == 1 ? 0 : index,
387 Rows == 1 ? index : 0);
388 return m_argImpl.coeff(row_col.first, row_col.second);
392 template<
int LoadMode>
393 inline PacketScalar packet(
Index rowId,
Index colId)
const 395 const RowCol row_col = index_remap(rowId, colId);
396 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second);
400 template<
int LoadMode>
402 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
404 const RowCol row_col = index_remap(rowId, colId);
405 m_argImpl.const_cast_derived().template writePacket<Unaligned>
406 (row_col.first, row_col.second, val);
409 template<
int LoadMode>
411 inline PacketScalar packet(
Index index)
const 413 const RowCol row_col = index_remap(RowsAtCompileTime == 1 ? 0 : index,
414 RowsAtCompileTime == 1 ? index : 0);
415 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second);
418 template<
int LoadMode>
420 inline void writePacket(
Index index,
const PacketScalar& val)
422 const RowCol row_col = index_remap(RowsAtCompileTime == 1 ? 0 : index,
423 RowsAtCompileTime == 1 ? index : 0);
424 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second, val);
434 template<
typename ArgType,
int Rows,
int Cols,
int Order>
437 typename Reshaped<ArgType, Rows, Cols, Order>::PlainObject>
454 #endif // EIGEN_RESHAPED_H
ReshapedImpl< XprType, Rows, Cols, Order, typename internal::traits< XprType >::StorageKind > Impl
traits< XprType >::XprKind XprKind
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const internal::variable_if_dynamic< Index, Cols > m_cols
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index rowId, Index colId) const
EIGEN_DEVICE_FUNC internal::remove_reference< XprType >::type & nestedExpression()
traits< XprType >::StorageKind StorageKind
const unsigned int DirectAccessBit
EIGEN_DEVICE_FUNC Reshaped(XprType &xpr)
const unsigned int LvalueBit
EIGEN_DEVICE_FUNC const internal::remove_all< XprTypeNested >::type & nestedExpression() const
#define EIGEN_PLAIN_ENUM_MAX(a, b)
internal::ReshapedImpl_dense< XprType, Rows, Cols, Order, internal::traits< Reshaped< XprType, Rows, Cols, Order > >::HasDirectAccess > Impl
Namespace containing all symbols from the Eigen library.
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC Index rows() const
reshaped_evaluator< ArgType, Rows, Cols, Order, HasDirectAccess > reshaped_evaluator_type
const unsigned int RowMajorBit
EIGEN_DEVICE_FUNC Reshaped(XprType &xpr, Index reshapeRows, Index reshapeCols)
const unsigned int PacketAccessBit
XprType::CoeffReturnType CoeffReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index index) const
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Reshaped< XprType, Rows, Cols, Order > ReshapedType
EIGEN_DEVICE_FUNC evaluator(const XprType &xpr)
Reshaped< XprType, Rows, Cols, Order > ReshapedType
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
const unsigned int HereditaryBits
internal::ref_selector< XprType >::non_const_type XprTypeNested
EIGEN_DEVICE_FUNC ReshapedImpl(XprType &xpr, Index reshapeRows, Index reshapeCols)
Reshaped< ArgType, Rows, Cols, Order > XprType
internal::dense_xpr_base< ReshapedType >::type Base
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const
packet_traits< Scalar >::type PacketScalar
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC Index cols() const
traits< XprType >::Scalar Scalar
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
EIGEN_DEVICE_FUNC const internal::remove_all< XprType >::type & nestedExpression() const
Reshaped< ArgType, Rows, Cols, Order > XprType
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr)
std::pair< Index, Index > RowCol
MapBase< ReshapedType > Base
EIGEN_CONSTEXPR Index size(const T &x)
#define EIGEN_DEVICE_FUNC
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
EIGEN_DEVICE_FUNC reshaped_evaluator(const XprType &xpr)
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index index)
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index rowId, Index colId)
EIGEN_DEVICE_FUNC const CoeffReturnType coeff(Index index) const
RowCol index_remap(Index rowId, Index colId) const
Expression of a fixed-size or dynamic-size reshape.
evaluator< ArgType > m_argImpl
Reshaped< ArgType, Rows, Cols, Order > XprType
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
const unsigned int LinearAccessBit
EIGEN_DEVICE_FUNC reshaped_evaluator(const XprType &xpr)
const internal::variable_if_dynamic< Index, Rows > m_rows
EIGEN_DEVICE_FUNC XprType & nestedExpression()
An InnerIterator allows to loop over the element of any matrix expression.