11 #ifndef EIGEN_RESHAPED_H
12 #define EIGEN_RESHAPED_H
50 template <
typename XprType,
int Rows,
int Cols,
int Order>
58 RowsAtCompileTime = Rows,
59 ColsAtCompileTime = Cols,
60 MaxRowsAtCompileTime = Rows,
61 MaxColsAtCompileTime = Cols,
63 ReshapedStorageOrder = (RowsAtCompileTime == 1 && ColsAtCompileTime != 1) ?
RowMajor
64 : (ColsAtCompileTime == 1 && RowsAtCompileTime != 1) ?
ColMajor
66 HasSameStorageOrderAsXprType = (ReshapedStorageOrder == XpxStorageOrder),
67 InnerSize = (ReshapedStorageOrder ==
int(
RowMajor)) ?
int(ColsAtCompileTime) :
int(RowsAtCompileTime),
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>
95 template <
typename XprType,
int Rows,
int Cols,
int Order,
typename StorageKind>
98 template <
typename XprType,
int Rows,
int Cols,
int Order>
99 class Reshaped :
public ReshapedImpl<XprType, Rows, Cols, Order, typename internal::traits<XprType>::StorageKind> {
112 THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
119 :
Impl(xpr, reshapeRows, reshapeCols) {
121 (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime == reshapeCols));
128 template <
typename XprType,
int Rows,
int Cols,
int Order>
131 internal::traits<Reshaped<XprType, Rows, Cols, Order> >::HasDirectAccess> {
141 :
Impl(xpr, reshapeRows, reshapeCols) {}
147 template <
typename XprType,
int Rows,
int Cols,
int Order>
169 : m_xpr(xpr), m_rows(nRows), m_cols(nCols) {}
174 #ifdef EIGEN_PARSED_BY_DOXYGEN
194 template <
typename XprType,
int Rows,
int Cols,
int Order>
211 :
Base(xpr.
data(), nRows, nCols), m_xpr(xpr) {}
230 template <
typename ArgType,
int Rows,
int Cols,
int Order,
bool HasDirectAccess>
233 template <
typename ArgType,
int Rows,
int Cols,
int Order>
235 :
reshaped_evaluator<ArgType, Rows, Cols, Order, traits<Reshaped<ArgType, Rows, Cols, Order> >::HasDirectAccess> {
255 FlagsLinearAccessBit =
262 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit | FlagsDirectAccessBit,
273 template <
typename ArgType,
int Rows,
int Cols,
int Order>
297 const Index nth_elem_idx = colId * m_xpr.rows() + rowId;
298 return RowCol(nth_elem_idx % m_xpr.nestedExpression().rows(), nth_elem_idx / m_xpr.nestedExpression().rows());
300 const Index nth_elem_idx = colId + rowId * m_xpr.cols();
301 return RowCol(nth_elem_idx / m_xpr.nestedExpression().cols(), nth_elem_idx % m_xpr.nestedExpression().cols());
307 const RowCol row_col = index_remap(rowId, colId);
308 return m_argImpl.coeffRef(row_col.first, row_col.second);
312 const RowCol row_col = index_remap(rowId, colId);
313 return m_argImpl.coeffRef(row_col.first, row_col.second);
317 const RowCol row_col = index_remap(rowId, colId);
318 return m_argImpl.coeff(row_col.first, row_col.second);
323 const RowCol row_col = index_remap(Rows == 1 ? 0 : index, Rows == 1 ? index : 0);
324 return m_argImpl.coeffRef(row_col.first, row_col.second);
328 const RowCol row_col = index_remap(Rows == 1 ? 0 : index, Rows == 1 ? index : 0);
329 return m_argImpl.coeffRef(row_col.first, row_col.second);
333 const RowCol row_col = index_remap(Rows == 1 ? 0 : index, Rows == 1 ? index : 0);
334 return m_argImpl.coeff(row_col.first, row_col.second);
338 template<
int LoadMode>
339 inline PacketScalar packet(
Index rowId,
Index colId)
const
341 const RowCol row_col = index_remap(rowId, colId);
342 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second);
346 template<
int LoadMode>
348 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar&
val)
350 const RowCol row_col = index_remap(rowId, colId);
351 m_argImpl.const_cast_derived().template writePacket<Unaligned>
352 (row_col.first, row_col.second,
val);
355 template<
int LoadMode>
357 inline PacketScalar packet(
Index index)
const
359 const RowCol row_col = index_remap(RowsAtCompileTime == 1 ? 0 : index,
360 RowsAtCompileTime == 1 ? index : 0);
361 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second);
364 template<
int LoadMode>
366 inline void writePacket(
Index index,
const PacketScalar&
val)
368 const RowCol row_col = index_remap(RowsAtCompileTime == 1 ? 0 : index,
369 RowsAtCompileTime == 1 ? index : 0);
370 return m_argImpl.template packet<Unaligned>(row_col.first, row_col.second,
val);
378 template <
typename ArgType,
int Rows,
int Cols,
int Order>
381 typename Reshaped<ArgType, Rows, Cols, Order>::PlainObject> {
390 "data is not aligned");
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1149
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1171
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Macro to manually inherit assignment operators. This is necessary, because the implicitly defined ass...
Definition: Macros.h:1126
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
int data[]
Definition: Map_placement_new.cpp:1
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Definition: StaticAssert.h:87
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Definition: StaticAssert.h:101
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:79
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:116
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:111
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:37
Definition: ForwardDeclarations.h:150
internal::ReshapedImpl_dense< XprType, Rows, Cols, Order, internal::traits< Reshaped< XprType, Rows, Cols, Order > >::HasDirectAccess > Impl
Definition: Reshaped.h:134
Impl Base
Definition: Reshaped.h:137
EIGEN_DEVICE_FUNC ReshapedImpl(XprType &xpr, Index reshapeRows, Index reshapeCols)
Definition: Reshaped.h:140
Definition: Reshaped.h:96
Expression of a fixed-size or dynamic-size reshape.
Definition: Reshaped.h:99
EIGEN_DEVICE_FUNC Reshaped(XprType &xpr, Index reshapeRows, Index reshapeCols)
Definition: Reshaped.h:118
Impl Base
Definition: Reshaped.h:104
ReshapedImpl< XprType, Rows, Cols, Order, typename internal::traits< XprType >::StorageKind > Impl
Definition: Reshaped.h:100
EIGEN_DEVICE_FUNC Index rows() const
Definition: Reshaped.h:171
internal::remove_all_t< XprType > NestedExpression
Definition: Reshaped.h:158
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
Definition: Reshaped.h:168
Reshaped< XprType, Rows, Cols, Order > ReshapedType
Definition: Reshaped.h:150
internal::dense_xpr_base< ReshapedType >::type Base
Definition: Reshaped.h:153
internal::ref_selector< XprType >::non_const_type MatrixTypeNested
Definition: Reshaped.h:157
EIGEN_DEVICE_FUNC Index cols() const
Definition: Reshaped.h:172
MatrixTypeNested m_xpr
Definition: Reshaped.h:188
EIGEN_DEVICE_FUNC std::remove_reference_t< XprType > & nestedExpression()
Definition: Reshaped.h:185
const internal::variable_if_dynamic< Index, Cols > m_cols
Definition: Reshaped.h:190
EIGEN_DEVICE_FUNC const internal::remove_all_t< XprType > & nestedExpression() const
Definition: Reshaped.h:182
const internal::variable_if_dynamic< Index, Rows > m_rows
Definition: Reshaped.h:189
Reshaped< XprType, Rows, Cols, Order > ReshapedType
Definition: Reshaped.h:196
EIGEN_DEVICE_FUNC XprType & nestedExpression()
Definition: Reshaped.h:215
EIGEN_DEVICE_FUNC ReshapedImpl_dense(XprType &xpr, Index nRows, Index nCols)
Definition: Reshaped.h:210
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
Definition: Reshaped.h:221
EIGEN_DEVICE_FUNC const internal::remove_all_t< XprTypeNested > & nestedExpression() const
Definition: Reshaped.h:213
internal::ref_selector< XprType >::non_const_type XprTypeNested
Definition: Reshaped.h:197
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
Definition: Reshaped.h:218
XprTypeNested m_xpr
Definition: Reshaped.h:226
MapBase< ReshapedType > Base
Definition: Reshaped.h:200
Definition: Reshaped.h:91
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int PacketAccessBit
Definition: Constants.h:97
const unsigned int LinearAccessBit
Definition: Constants.h:133
const unsigned int DirectAccessBit
Definition: Constants.h:159
const unsigned int LvalueBit
Definition: Constants.h:148
const unsigned int RowMajorBit
Definition: Constants.h:70
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
constexpr int plain_enum_max(A a, B b)
Definition: Meta.h:656
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
const unsigned int HereditaryBits
Definition: Constants.h:198
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
val
Definition: calibrate.py:119
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition: nestbyvalue.cpp:15
Definition: Constants.h:519
Definition: XprHelper.h:558
packet_traits< Scalar >::type PacketScalar
Definition: Reshaped.h:239
reshaped_evaluator< ArgType, Rows, Cols, Order, HasDirectAccess > reshaped_evaluator_type
Definition: Reshaped.h:267
EIGEN_DEVICE_FUNC evaluator(const XprType &xpr)
Definition: Reshaped.h:268
XprType::Scalar Scalar
Definition: Reshaped.h:237
Reshaped< ArgType, Rows, Cols, Order > XprType
Definition: Reshaped.h:236
Definition: CoreEvaluators.h:118
Definition: CoreEvaluators.h:104
Definition: ForwardDeclarations.h:31
Definition: DenseCoeffsBase.h:546
Definition: XprHelper.h:819
Definition: CoreEvaluators.h:999
Definition: GenericPacketMath.h:108
Definition: XprHelper.h:506
std::conditional_t< bool(traits< T >::Flags &NestByRefBit), T &, T > non_const_type
Definition: XprHelper.h:509
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index rowId, Index colId) const
Definition: Reshaped.h:311
std::pair< Index, Index > RowCol
Definition: Reshaped.h:293
EIGEN_DEVICE_FUNC reshaped_evaluator(const XprType &xpr)
Definition: Reshaped.h:286
EIGEN_DEVICE_FUNC const Scalar & coeffRef(Index index) const
Definition: Reshaped.h:327
EIGEN_DEVICE_FUNC RowCol index_remap(Index rowId, Index colId) const
Definition: Reshaped.h:295
const XprType & m_xpr
Definition: Reshaped.h:375
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index rowId, Index colId)
Definition: Reshaped.h:305
XprType::CoeffReturnType CoeffReturnType
Definition: Reshaped.h:291
Reshaped< ArgType, Rows, Cols, Order > XprType
Definition: Reshaped.h:276
EIGEN_DEVICE_FUNC const CoeffReturnType coeff(Index index) const
Definition: Reshaped.h:332
evaluator< ArgType > m_argImpl
Definition: Reshaped.h:374
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const
Definition: Reshaped.h:316
EIGEN_DEVICE_FUNC Scalar & coeffRef(Index index)
Definition: Reshaped.h:321
XprType::Scalar Scalar
Definition: Reshaped.h:290
EIGEN_DEVICE_FUNC reshaped_evaluator(const XprType &xpr)
Definition: Reshaped.h:385
Reshaped< ArgType, Rows, Cols, Order > XprType
Definition: Reshaped.h:382
XprType::Scalar Scalar
Definition: Reshaped.h:383
Definition: Reshaped.h:231
traits< XprType >::StorageKind StorageKind
Definition: Reshaped.h:53
traits< XprType >::XprKind XprKind
Definition: Reshaped.h:54
traits< XprType >::Scalar Scalar
Definition: Reshaped.h:52
Definition: ForwardDeclarations.h:21
Definition: GenericPacketMath.h:134