11#ifndef EIGEN_TRANSPOSE_H
12#define EIGEN_TRANSPOSE_H
17template<
typename MatrixType>
23 RowsAtCompileTime = MatrixType::ColsAtCompileTime,
24 ColsAtCompileTime = MatrixType::RowsAtCompileTime,
25 MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
26 MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
29 Flags1 = Flags0 | FlagsLvalueBit,
37template<
typename MatrixType,
typename StorageKind>
class TransposeImpl;
53 :
public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>
95template<typename MatrixType, bool HasDirectAccess = has_direct_access<MatrixType>::ret>
101template<
typename MatrixType>
110template<
typename XprType,
typename StorageKind>
124 using Base::coeffRef;
142 const Scalar*
data()
const {
return derived().nestedExpression().data(); }
148 return derived().nestedExpression().coeffRef(colId, rowId);
154 return derived().nestedExpression().coeffRef(
index);
179template<
typename Derived>
192template<
typename Derived>
219template<
typename Derived>
232template<
typename MatrixType,
233 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
234 bool MatchPacketSize =
239template<
typename MatrixType>
241 static void run(MatrixType& m) {
242 m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
246template<
typename MatrixType>
248 static void run(MatrixType& m) {
249 typedef typename MatrixType::Scalar Scalar;
254 for (
Index i=0; i<PacketSize; ++i)
255 A.
packet[i] = m.template packetByOuterInner<Alignment>(i,0);
257 for (
Index i=0; i<PacketSize; ++i)
258 m.template writePacket<Alignment>(m.rowIndexByOuterInner(i,0), m.colIndexByOuterInner(i,0), A.
packet[i]);
263template <
typename MatrixType, Index Alignment>
265 typedef typename MatrixType::Scalar Scalar;
270 for (; row_start + PacketSize <= m.rows(); row_start += PacketSize) {
271 for (
int col_start = row_start; col_start + PacketSize <= m.cols(); col_start += PacketSize) {
273 if (row_start == col_start) {
274 for (
Index i=0; i<PacketSize; ++i)
275 A.
packet[i] = m.template packetByOuterInner<Alignment>(row_start + i,col_start);
277 for (
Index i=0; i<PacketSize; ++i)
278 m.template writePacket<Alignment>(m.rowIndexByOuterInner(row_start + i, col_start), m.colIndexByOuterInner(row_start + i,col_start), A.
packet[i]);
281 for (
Index i=0; i<PacketSize; ++i) {
282 A.
packet[i] = m.template packetByOuterInner<Alignment>(row_start + i,col_start);
283 B.
packet[i] = m.template packetByOuterInner<Alignment>(col_start + i, row_start);
287 for (
Index i=0; i<PacketSize; ++i) {
288 m.template writePacket<Alignment>(m.rowIndexByOuterInner(row_start + i, col_start), m.colIndexByOuterInner(row_start + i,col_start), B.
packet[i]);
289 m.template writePacket<Alignment>(m.rowIndexByOuterInner(col_start + i, row_start), m.colIndexByOuterInner(col_start + i,row_start), A.
packet[i]);
295 m.matrix().row(
row).head(
row).swap(
296 m.matrix().col(
row).head(
row).transpose());
300template<
typename MatrixType,
bool MatchPacketSize>
302 static void run(MatrixType& m) {
303 typedef typename MatrixType::Scalar Scalar;
304 if (m.rows() == m.cols()) {
307 if ((m.rows() % PacketSize) == 0)
308 BlockedInPlaceTranspose<MatrixType,internal::evaluator<MatrixType>::Alignment>(m);
310 BlockedInPlaceTranspose<MatrixType,Unaligned>(m);
313 m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
316 m = m.transpose().eval();
343template<
typename Derived>
347 &&
"transposeInPlace() called on a non-square non-resizable matrix");
374template<
typename Derived>
377 derived() = adjoint().eval();
380#ifndef EIGEN_NO_DEBUG
386template<
bool DestIsTransposed,
typename OtherDerived>
392template<
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
400template<
typename Scalar,
bool DestIsTransposed,
typename OtherDerived>
403 static bool run(
const Scalar* dest,
const OtherDerived& src)
409template<
typename Scalar,
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
425template<
typename Derived,
typename OtherDerived,
426 bool MightHaveTransposeAliasing
427 = check_transpose_aliasing_compile_time_selector
432 static void run(
const Derived& dst,
const OtherDerived& other)
437 &&
"aliasing detected during transposition, use transposeInPlace() "
438 "or evaluate the rhs into a temporary using .eval()");
443template<
typename Derived,
typename OtherDerived>
446 static void run(
const Derived&,
const OtherDerived&)
451template<
typename Dst,
typename Src>
454 if((!Dst::IsVectorAtCompileTime) && dst.rows()>1 && dst.cols()>1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
This is the const version of row(). */.
Definition: BlockMethods.h:1118
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Just a side note.
Definition: Macros.h:1274
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
Definition: Macros.h:1257
#define EIGEN_NOEXCEPT
Definition: Macros.h:1428
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1293
#define eigen_assert(x)
Definition: Macros.h:1047
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:1241
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:84
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
EIGEN_DEVICE_FUNC void transposeInPlace()
This is the "in place" version of transpose(): it replaces *this by its own transpose.
Definition: Transpose.h:344
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition: Transpose.h:182
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition: Transpose.h:221
EIGEN_DEVICE_FUNC void adjointInPlace()
This is the "in place" version of adjoint(): it replaces *this by its own transpose.
Definition: Transpose.h:375
Expression of the transpose of a matrix.
Definition: Transpose.h:54
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Transpose.h:69
TransposeImpl< MatrixType, typenameinternal::traits< MatrixType >::StorageKind >::Base Base
Definition: Transpose.h:59
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Transpose.h:71
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Definition: Transpose.h:81
internal::remove_all< MatrixType >::type NestedExpression
Definition: Transpose.h:61
internal::ref_selector< MatrixType >::non_const_type m_matrix
Definition: Transpose.h:90
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: Transpose.h:76
internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
Definition: Transpose.h:57
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index nrows, Index ncols)
Definition: Transpose.h:85
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarWithConstIfNotLvalue * data()
Definition: Transpose.h:140
internal::conditional< internal::is_lvalue< MatrixType >::value, Scalar, constScalar >::type ScalarWithConstIfNotLvalue
Definition: Transpose.h:137
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outerStride() const
Definition: Transpose.h:131
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeffRef(Index index) const
Definition: Transpose.h:152
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: Transpose.h:142
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeffRef(Index rowId, Index colId) const
Definition: Transpose.h:146
internal::TransposeImpl_base< MatrixType >::type Base
Definition: Transpose.h:123
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index innerStride() const
Definition: Transpose.h:129
Definition: Transpose.h:113
internal::generic_xpr_base< Transpose< XprType > >::type Base
Definition: Transpose.h:115
type
Definition: core.h:575
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:94
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
EIGEN_DEVICE_FUNC void ptranspose(PacketBlock< Packet8f, 8 > &kernel)
Definition: PacketMath.h:863
void check_for_aliasing(const Dst &dst, const Src &src)
Definition: Transpose.h:452
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T::Scalar * extract_data(const T &m)
Definition: BlasUtil.h:533
void BlockedInPlaceTranspose(MatrixType &m)
Definition: Transpose.h:264
Namespace containing all symbols from the Eigen library.
Definition: Core:141
const unsigned int NestByRefBit
Definition: Constants.h:169
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
Definition: Eigen_Colamd.h:50
The type used to identify a dense storage.
Definition: Constants.h:507
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
Definition: GenericPacketMath.h:1014
Packet packet[N]
Definition: GenericPacketMath.h:1015
dense_xpr_base< Transpose< MatrixType > >::type type
Definition: Transpose.h:104
Definition: Transpose.h:97
dense_xpr_base< Transpose< MatrixType > >::type type
Definition: Transpose.h:98
Definition: BlasUtil.h:403
@ IsTransposed
Definition: BlasUtil.h:409
Definition: Transpose.h:388
@ ret
Definition: Transpose.h:389
static bool run(const Scalar *dest, const CwiseBinaryOp< BinOp, DerivedA, DerivedB > &src)
Definition: Transpose.h:412
Definition: Transpose.h:402
static bool run(const Scalar *dest, const OtherDerived &src)
Definition: Transpose.h:403
static void run(const Derived &, const OtherDerived &)
Definition: Transpose.h:446
Definition: Transpose.h:431
static void run(const Derived &dst, const OtherDerived &other)
Definition: Transpose.h:432
Definition: XprHelper.h:484
Definition: CoreEvaluators.h:91
Definition: XprHelper.h:501
Definition: DenseCoeffsBase.h:659
static void run(MatrixType &m)
Definition: Transpose.h:302
static void run(MatrixType &m)
Definition: Transpose.h:241
static void run(MatrixType &m)
Definition: Transpose.h:248
Definition: Transpose.h:237
Definition: XprHelper.h:660
Definition: DenseCoeffsBase.h:671
Definition: GenericPacketMath.h:107
T type
Definition: GenericPacketMath.h:108
Definition: XprHelper.h:417
T type
Definition: Meta.h:126
T type
Definition: Meta.h:114
remove_reference< MatrixTypeNested >::type MatrixTypeNestedPlain
Definition: Transpose.h:21
ref_selector< MatrixType >::type MatrixTypeNested
Definition: Transpose.h:20
Definition: ForwardDeclarations.h:17