11#ifndef EIGEN_RESHAPED_H
12#define EIGEN_RESHAPED_H
48template<
typename XprType,
int Rows,
int Cols,
int Order>
57 RowsAtCompileTime = Rows,
58 ColsAtCompileTime = Cols,
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
70 OuterStrideAtCompileTime =
Dynamic,
73 && (Order==int(XpxStorageOrder))
77 && (InnerStrideAtCompileTime == 1)
80 FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ?
LinearAccessBit : 0,
86 Flags = (Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit | FlagsDirectAccessBit)
90template<
typename XprType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
class ReshapedImpl_dense;
94template<
typename XprType,
int Rows,
int Cols,
int Order,
typename StorageKind>
class ReshapedImpl;
96template<
typename XprType,
int Rows,
int Cols,
int Order>
class Reshaped
97 :
public ReshapedImpl<XprType, Rows, Cols, Order, typename internal::traits<XprType>::StorageKind>
103 EIGEN_GENERIC_PUBLIC_INTERFACE(
Reshaped)
104 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
Reshaped)
112 EIGEN_STATIC_ASSERT(RowsAtCompileTime!=
Dynamic && ColsAtCompileTime!=
Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
113 eigen_assert(Rows * Cols ==
xpr.rows() *
xpr.cols());
131template<
typename XprType,
int Rows,
int Cols,
int Order>
147template<
typename XprType,
int Rows,
int Cols,
int Order>
159 typedef typename internal::remove_all<XprType>::type NestedExpression;
167 : m_xpr(
xpr), m_rows(Rows), m_cols(Cols)
177 EIGEN_DEVICE_FUNC
Index rows()
const {
return m_rows; }
178 EIGEN_DEVICE_FUNC
Index cols()
const {
return m_cols; }
180 #ifdef EIGEN_PARSED_BY_DOXYGEN
182 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const;
183 EIGEN_DEVICE_FUNC
inline Index innerStride()
const;
184 EIGEN_DEVICE_FUNC
inline Index outerStride()
const;
189 const typename internal::remove_all<XprType>::type&
194 typename internal::remove_reference<XprType>::type&
199 MatrixTypeNested m_xpr;
206template<
typename XprType,
int Rows,
int Cols,
int Order>
208 :
public MapBase<Reshaped<XprType, Rows, Cols, Order> >
234 const typename internal::remove_all<XprTypeNested>::type& nestedExpression()
const
240 XprType& nestedExpression() {
return m_xpr; }
243 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
246 return m_xpr.innerStride();
250 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
262template<
typename ArgType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
struct reshaped_evaluator;
264template<
typename ArgType,
int Rows,
int Cols,
int Order>
266 :
reshaped_evaluator<ArgType, Rows, Cols, Order, traits<Reshaped<ArgType,Rows,Cols,Order> >::HasDirectAccess>
269 typedef typename XprType::Scalar Scalar;
271 typedef typename packet_traits<Scalar>::type PacketScalar;
291 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit | FlagsDirectAccessBit,
299 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
303template<
typename ArgType,
int Rows,
int Cols,
int Order>
319 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
322 typedef typename XprType::Scalar Scalar;
323 typedef typename XprType::CoeffReturnType CoeffReturnType;
325 typedef std::pair<Index, Index> RowCol;
332 return RowCol(
nth_elem_idx % m_xpr.nestedExpression().rows(),
338 return RowCol(
nth_elem_idx / m_xpr.nestedExpression().cols(),
346 EIGEN_STATIC_ASSERT_LVALUE(
XprType)
366 inline Scalar& coeffRef(
Index index)
368 EIGEN_STATIC_ASSERT_LVALUE(
XprType)
369 const RowCol
row_col = index_remap(Rows == 1 ? 0 : index,
370 Rows == 1 ? index : 0);
376 inline const Scalar& coeffRef(
Index index)
const
378 const RowCol
row_col = index_remap(Rows == 1 ? 0 : index,
379 Rows == 1 ? index : 0);
384 inline const CoeffReturnType coeff(
Index index)
const
386 const RowCol
row_col = index_remap(Rows == 1 ? 0 : index,
387 Rows == 1 ? index : 0);
392 template<
int LoadMode>
400 template<
int LoadMode>
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);
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);
434template<
typename ArgType,
int Rows,
int Cols,
int Order>
437 typename Reshaped<ArgType, Rows, Cols, Order>::PlainObject>
440 typedef typename XprType::Scalar Scalar;
An InnerIterator allows to loop over the element of any matrix expression.
Definition CoreIterators.h:34
Definition ForwardDeclarations.h:112
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Expression of a fixed-size or dynamic-size reshape.
Definition Reshaped.h:98
EIGEN_DEVICE_FUNC Reshaped(XprType &xpr, Index reshapeRows, Index reshapeCols)
Dynamic-size constructor.
Definition Reshaped.h:119
EIGEN_DEVICE_FUNC Reshaped(XprType &xpr)
Fixed-size constructor.
Definition Reshaped.h:109
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
Dynamic-size constructor.
Definition Reshaped.h:173
EIGEN_DEVICE_FUNC const internal::remove_all< XprType >::type & nestedExpression() const
Definition Reshaped.h:190
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr)
Fixed-size constructor.
Definition Reshaped.h:166
EIGEN_DEVICE_FUNC internal::remove_reference< XprType >::type & nestedExpression()
Definition Reshaped.h:195
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
Dynamic-size constructor.
Definition Reshaped.h:228
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr)
Fixed-size constructor.
Definition Reshaped.h:221
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
Definition Reshaped.h:251
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
Definition Reshaped.h:244
Definition XprHelper.h:130
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:321
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition Constants.h:94
const unsigned int LinearAccessBit
Short version: means the expression can be seen as 1D vector.
Definition Constants.h:130
const unsigned int DirectAccessBit
Means that the underlying array of coefficients can be directly accessed as a plain strided array.
Definition Constants.h:155
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition Constants.h:144
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
The type used to identify a dense storage.
Definition Constants.h:507
Definition XprHelper.h:484
Definition CoreEvaluators.h:111
Definition CoreEvaluators.h:91
Definition ForwardDeclarations.h:26
Definition DenseCoeffsBase.h:659
Definition XprHelper.h:660
Definition CoreEvaluators.h:885
Definition GenericPacketMath.h:107
Definition Reshaped.h:262
Definition ForwardDeclarations.h:17
Definition GenericPacketMath.h:133