11 #ifndef EIGEN_TRANSPOSE_H 12 #define EIGEN_TRANSPOSE_H 17 template<
typename MatrixType>
23 RowsAtCompileTime = MatrixType::ColsAtCompileTime,
24 ColsAtCompileTime = MatrixType::RowsAtCompileTime,
25 MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
26 MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
29 Flags1 = Flags0 | FlagsLvalueBit,
37 template<
typename MatrixType,
typename StorageKind>
class TransposeImpl;
53 :
public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>
64 explicit inline Transpose(MatrixType& matrix) : m_matrix(matrix) {}
66 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
68 EIGEN_DEVICE_FUNC
inline Index rows()
const {
return m_matrix.cols(); }
69 EIGEN_DEVICE_FUNC
inline Index cols()
const {
return m_matrix.rows(); }
83 m_matrix.resize(ncols,nrows);
92 template<typename MatrixType, bool HasDirectAccess = has_direct_access<MatrixType>::ret>
98 template<
typename MatrixType>
107 template<
typename XprType,
typename StorageKind>
120 typedef typename internal::TransposeImpl_base<MatrixType>::type Base;
121 using Base::coeffRef;
125 EIGEN_DEVICE_FUNC
inline Index innerStride()
const {
return derived().nestedExpression().innerStride(); }
126 EIGEN_DEVICE_FUNC
inline Index outerStride()
const {
return derived().nestedExpression().outerStride(); }
134 EIGEN_DEVICE_FUNC
inline ScalarWithConstIfNotLvalue* data() {
return derived().nestedExpression().data(); }
135 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const {
return derived().nestedExpression().data(); }
139 inline const Scalar& coeffRef(
Index rowId,
Index colId)
const 141 return derived().nestedExpression().coeffRef(colId, rowId);
145 inline const Scalar& coeffRef(
Index index)
const 147 return derived().nestedExpression().coeffRef(index);
170 template<
typename Derived>
182 template<
typename Derived>
208 template<
typename Derived>
221 template<
typename MatrixType,
222 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
223 bool MatchPacketSize =
228 template<
typename MatrixType>
230 static void run(MatrixType& m) {
231 m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
236 template<
typename MatrixType>
238 static void run(MatrixType& m) {
239 typedef typename MatrixType::Scalar Scalar;
244 for (
Index i=0; i<PacketSize; ++i)
245 A.packet[i] = m.template packetByOuterInner<Alignment>(i,0);
246 internal::ptranspose(A);
247 for (
Index i=0; i<PacketSize; ++i)
248 m.template writePacket<Alignment>(m.rowIndexByOuterInner(i,0), m.colIndexByOuterInner(i,0), A.packet[i]);
252 template<
typename MatrixType,
bool MatchPacketSize>
254 static void run(MatrixType& m) {
255 if (m.rows()==m.cols())
256 m.matrix().template triangularView<StrictlyUpper>().swap(m.matrix().transpose());
258 m = m.transpose().eval();
283 template<
typename Derived>
286 eigen_assert((rows() == cols() || (RowsAtCompileTime ==
Dynamic && ColsAtCompileTime ==
Dynamic))
287 &&
"transposeInPlace() called on a non-square non-resizable matrix");
314 template<
typename Derived>
317 derived() = adjoint().eval();
320 #ifndef EIGEN_NO_DEBUG 326 template<
bool DestIsTransposed,
typename OtherDerived>
332 template<
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
340 template<
typename Scalar,
bool DestIsTransposed,
typename OtherDerived>
343 static bool run(
const Scalar* dest,
const OtherDerived& src)
349 template<
typename Scalar,
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
365 template<
typename Derived,
typename OtherDerived,
366 bool MightHaveTransposeAliasing
372 static void run(
const Derived& dst,
const OtherDerived& other)
375 <
typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived>
376 ::run(extract_data(dst), other))
377 &&
"aliasing detected during transposition, use transposeInPlace() " 378 "or evaluate the rhs into a temporary using .eval()");
383 template<
typename Derived,
typename OtherDerived>
386 static void run(
const Derived&,
const OtherDerived&)
391 template<
typename Dst,
typename Src>
392 void check_for_aliasing(
const Dst &dst,
const Src &src)
399 #endif // EIGEN_NO_DEBUG 403 #endif // EIGEN_TRANSPOSE_H Definition: Transpose.h:37
Definition: DenseCoeffsBase.h:654
Definition: Transpose.h:370
Definition: BlasUtil.h:269
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition: Transpose.h:210
Expression of the transpose of a matrix.
Definition: Transpose.h:52
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition: Constants.h:139
Definition: CoreEvaluators.h:90
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition: Transpose.h:172
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:89
EIGEN_DEVICE_FUNC const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
EIGEN_DEVICE_FUNC const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: Transpose.h:74
Definition: XprHelper.h:463
Definition: GenericPacketMath.h:96
Definition: Transpose.h:93
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: XprHelper.h:396
Definition: Transpose.h:327
EIGEN_DEVICE_FUNC void adjointInPlace()
This is the "in place" version of adjoint(): it replaces *this by its own transpose.
Definition: Transpose.h:315
Definition: GenericPacketMath.h:539
Definition: PacketMath.h:48
Definition: BandTriangularSolver.h:13
EIGEN_DEVICE_FUNC internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Definition: Transpose.h:79
Definition: DenseCoeffsBase.h:666
Definition: Transpose.h:341
The type used to identify a dense storage.
Definition: Constants.h:491
Definition: XprHelper.h:481
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
EIGEN_DEVICE_FUNC void transposeInPlace()
This is the "in place" version of transpose(): it replaces *this by its own transpose.
Definition: Transpose.h:284
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Definition: Transpose.h:226
Definition: ForwardDeclarations.h:17
Definition: XprHelper.h:630
EIGEN_DEVICE_FUNC const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132