11#ifndef EIGEN_TRANSPOSE_H
12#define EIGEN_TRANSPOSE_H
17template<
typename MatrixType>
21 typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedPlain;
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>
61 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
64 explicit EIGEN_STRONG_INLINE
Transpose(MatrixType& matrix) : m_matrix(matrix) {}
66 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
Transpose)
68 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
69 Index rows()
const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
71 Index cols()
const EIGEN_NOEXCEPT {
return m_matrix.rows(); }
74 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
75 const typename internal::remove_all<MatrixTypeNested>::type&
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
80 typename internal::remove_reference<MatrixTypeNested>::type&
84 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
86 m_matrix.resize(ncols,nrows);
90 typename internal::ref_selector<MatrixType>::non_const_type m_matrix;
95template<typename MatrixType, bool HasDirectAccess = has_direct_access<MatrixType>::ret>
101template<
typename MatrixType>
110template<
typename XprType,
typename StorageKind>
123 typedef typename internal::TransposeImpl_base<MatrixType>::type Base;
124 using Base::coeffRef;
128 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
129 Index innerStride()
const {
return derived().nestedExpression().innerStride(); }
130 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
131 Index outerStride()
const {
return derived().nestedExpression().outerStride(); }
139 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
141 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
142 const Scalar* data()
const {
return derived().nestedExpression().data(); }
145 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
148 return derived().nestedExpression().coeffRef(
colId,
rowId);
151 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
152 const Scalar& coeffRef(
Index index)
const
154 return derived().nestedExpression().coeffRef(index);
157 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(
TransposeImpl)
179template<
typename Derived>
180EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
192template<
typename Derived>
193EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
219template<
typename Derived>
232template<
typename MatrixType,
233 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
239template<
typename MatrixType>
241 static void run(MatrixType& m) {
246template<
typename MatrixType>
248 static void run(MatrixType& m) {
249 typedef typename MatrixType::Scalar Scalar;
250 typedef typename internal::packet_traits<typename MatrixType::Scalar>::type
Packet;
254 for (
Index i=0; i<PacketSize; ++i)
256 internal::ptranspose(A);
257 for (
Index i=0; i<PacketSize; ++i)
263template <
typename MatrixType, Index Alignment>
264void BlockedInPlaceTranspose(MatrixType& m) {
265 typedef typename MatrixType::Scalar Scalar;
266 typedef typename internal::packet_traits<typename MatrixType::Scalar>::type
Packet;
268 eigen_assert(m.rows() == m.cols());
274 for (
Index i=0; i<PacketSize; ++i)
276 internal::ptranspose(A);
277 for (
Index i=0; i<PacketSize; ++i)
281 for (
Index i=0; i<PacketSize; ++i) {
285 internal::ptranspose(A);
286 internal::ptranspose(B);
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]);
294 for (
Index row = row_start; row < m.rows(); ++row) {
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)
316 m = m.transpose().eval();
343template<
typename Derived>
347 &&
"transposeInPlace() called on a non-square non-resizable matrix");
374template<
typename Derived>
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>
409template<
typename Scalar,
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
436 ::run(extract_data(
dst), other))
437 &&
"aliasing detected during transposition, use transposeInPlace() "
438 "or evaluate the rhs into a temporary using .eval()");
443template<
typename Derived,
typename OtherDerived>
451template<
typename Dst,
typename Src>
452void check_for_aliasing(
const Dst &
dst,
const Src &
src)
454 if((!Dst::IsVectorAtCompileTime) &&
dst.rows()>1 &&
dst.cols()>1)
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:47
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(const DenseBase< OtherDerived > &other)
swaps *this with the expression other.
Definition DenseBase.h:420
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvalReturnType eval() const
Definition DenseBase.h:407
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition Transpose.h:221
@ ColsAtCompileTime
The number of columns at compile-time.
Definition DenseBase.h:106
@ RowsAtCompileTime
The number of rows at compile-time.
Definition DenseBase.h:100
Definition Transpose.h:113
Expression of the transpose of a matrix.
Definition Transpose.h:54
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Definition Transpose.h:81
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition Transpose.h:76
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
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
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Definition Transpose.h:97
Definition BlasUtil.h:403
Definition Transpose.h:431
Definition Transpose.h:388
Definition Transpose.h:402
Definition CoreEvaluators.h:91
Definition XprHelper.h:501
Definition DenseCoeffsBase.h:659
Definition Transpose.h:237
Definition XprHelper.h:660
Definition DenseCoeffsBase.h:671
Definition GenericPacketMath.h:107
Definition ForwardDeclarations.h:17
Definition PacketMath.h:47