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;
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
146 const Scalar& coeffRef(
Index rowId,
Index colId)
const
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>
233 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
234 bool MatchPacketSize =
239template<
typename MatrixType>
242 m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
246template<
typename MatrixType>
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)
255 A.packet[i] = m.template packetByOuterInner<Alignment>(i,0);
256 internal::ptranspose(A);
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;
266 typedef typename internal::packet_traits<typename MatrixType::Scalar>::type
Packet;
268 eigen_assert(m.rows() == m.cols());
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);
276 internal::ptranspose(A);
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]);
280 PacketBlock<Packet> B;
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);
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>
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>
346 eigen_assert((rows() == cols() || (RowsAtCompileTime ==
Dynamic && ColsAtCompileTime ==
Dynamic))
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
432 static void run(
const Derived& dst,
const OtherDerived& other)
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>
446 static void run(
const Derived&,
const 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
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()
Definition Transpose.h:344
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition Diagonal.h:65
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition Transpose.h:221
EIGEN_DEVICE_FUNC void adjointInPlace()
Definition Transpose.h:375
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
Definition Constants.h:94
const unsigned int LvalueBit
Definition Constants.h:144
const unsigned int RowMajorBit
Definition Constants.h:66
GLM_FUNC_DECL genType::row_type row(genType const &m, length_t index)
Definition matrix_access.inl:23
Namespace containing all symbols from the Eigen library.
Definition common.h:81
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22
Definition Constants.h:507
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
Definition GenericPacketMath.h:1014
Definition Transpose.h:97
Definition BlasUtil.h:403
Definition Transpose.h:431
Definition Transpose.h:388
Definition Transpose.h:402
Definition XprHelper.h:484
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