26 template<
typename MatrixType,
int NumBlocks>
27 struct traits<BlockTranspose<MatrixType,NumBlocks> >
30 typedef typename MatrixType::Scalar Scalar;
31 typedef typename traits<MatrixType>::StorageKind StorageKind;
32 typedef typename traits<MatrixType>::XprKind XprKind;
33 typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
34 typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
36 RowsAtCompileTime = NumBlocks==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic
38 : MatrixType::ColsAtCompileTime / NumBlocks,
39 ColsAtCompileTime = NumBlocks==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic
41 : NumBlocks * MatrixType::RowsAtCompileTime,
43 MaxRowsAtCompileTime = RowsAtCompileTime,
44 MaxColsAtCompileTime = ColsAtCompileTime,
45 IsRowMajor = MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1 ? 1
46 : MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1 ? 0
47 : (MatrixType::Flags & RowMajorBit) ? 1 : 0,
50 Flags = IsRowMajor ? RowMajorBit : 0
56 :
public internal::dense_xpr_base< BlockTranspose<MatrixType,NumBlocks> >::type
58 typedef typename internal::traits<BlockTranspose>::MatrixTypeNested MatrixTypeNested;
59 typedef typename internal::traits<BlockTranspose>::_MatrixTypeNested _MatrixTypeNested;
62 typedef typename internal::dense_xpr_base<BlockTranspose>::type Base;
64 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
66 template<
typename OriginalMatrixType>
69 : m_matrix(a_matrix), m_numBlocks(NumBlocks)
71 EIGEN_STATIC_ASSERT((internal::is_same<
typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
72 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
73 eigen_assert(NumBlocks!=Dynamic);
76 template<
typename OriginalMatrixType>
78 inline BlockTranspose(
const OriginalMatrixType& a_matrix, Index numBlocks)
79 : m_matrix(a_matrix), m_numBlocks(numBlocks)
81 EIGEN_STATIC_ASSERT((internal::is_same<
typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
82 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
86 inline Index rows()
const {
return m_matrix.cols() / m_numBlocks.value(); }
90 inline Index cols()
const {
return m_matrix.rows() * m_numBlocks.value(); }
93 inline Index numBlocks()
const {
return m_numBlocks.value(); }
113 const _MatrixTypeNested& nestedExpression()
const
119 MatrixTypeNested m_matrix;
120 const internal::variable_if_dynamic<Index, NumBlocks> m_numBlocks;
124 template<
typename ArgType,
int NumBlocks>
126 : evaluator_base<BlockTranspose<ArgType, NumBlocks> >
129 typedef typename XprType::CoeffReturnType CoeffReturnType;
131 Factor = (NumBlocks==Dynamic) ? Dynamic : NumBlocks*NumBlocks
133 typedef typename internal::nested_eval<ArgType,Factor>::type ArgTypeNested;
134 typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
137 CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
138 LinearAccessMask = XprType::IsVectorAtCompileTime ? LinearAccessBit : 0,
139 Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits|LinearAccessMask) & ~RowMajorBit) | (traits<XprType>::Flags & RowMajorBit),
141 Alignment = evaluator<ArgTypeNestedCleaned>::Alignment
144 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& xpr)
145 : m_arg(xpr.nestedExpression()),
147 m_rows(xpr.nestedExpression().rows()),
148 m_cols(xpr.nestedExpression().cols()),
149 m_str(m_cols.value() / xpr.numBlocks())
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
153 CoeffReturnType coeff(Index rowId, Index colId)
const
155 const Index r = colId % m_rows.value();
156 const Index c = (colId/m_rows.value()) * m_str + rowId;
157 return m_argImpl.coeff(r, c);
160 template<
int LoadMode,
typename PacketType>
162 PacketType packet(Index rowId, Index colId)
const
164 const Index r = colId % m_rows.value();
165 const Index c = (colId/m_rows.value()) * m_str + rowId;
166 return m_argImpl.template packet<LoadMode>(r, c);
171 evaluator<ArgTypeNestedCleaned> m_argImpl;
172 const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
173 const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
182 template<
typename Derived>
183 const typename MatrixBase<Derived>::BlockTransposeReturnType
184 MatrixBase<Derived>::blockTranspose(Index numBlocks)
const
186 return BlockTranspose<Derived,Dynamic>(derived(),numBlocks);
Expression of block-wise transposition of a tiled matrix.
Definition: BlockTranspose.h:55