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>
86 m_matrix.resize(ncols,nrows);
101 template<
typename MatrixType>
110 template<
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);
179 template<
typename Derived>
192 template<
typename Derived>
219 template<
typename Derived>
233 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
234 bool MatchPacketSize =
239 template<
typename MatrixType>
242 m.matrix().template triangularView<StrictlyUpper>().
swap(m.matrix().transpose().template triangularView<StrictlyUpper>());
246 template<
typename MatrixType>
255 A.
packet[
i] = m.template packetByOuterInner<Alignment>(
i,0);
258 m.template writePacket<Alignment>(m.rowIndexByOuterInner(
i,0), m.colIndexByOuterInner(
i,0), A.
packet[
i]);
263 template <
typename MatrixType, Index Alignment>
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) {
275 A.
packet[
i] = m.template packetByOuterInner<Alignment>(row_start +
i,col_start);
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());
300 template<
typename MatrixType,
bool MatchPacketSize>
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();
343 template<
typename Derived>
347 &&
"transposeInPlace() called on a non-square non-resizable matrix");
374 template<
typename Derived>
380 #ifndef EIGEN_NO_DEBUG 386 template<
bool DestIsTransposed,
typename OtherDerived>
392 template<
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
400 template<
typename Scalar,
bool DestIsTransposed,
typename OtherDerived>
403 static bool run(
const Scalar* dest,
const OtherDerived& src)
409 template<
typename Scalar,
bool DestIsTransposed,
typename BinOp,
typename DerivedA,
typename DerivedB>
425 template<
typename Derived,
typename OtherDerived,
426 bool MightHaveTransposeAliasing
432 static void run(
const Derived& dst,
const OtherDerived&
other)
435 <
typename Derived::Scalar,blas_traits<Derived>::IsTransposed,OtherDerived>
437 &&
"aliasing detected during transposition, use transposeInPlace() " 438 "or evaluate the rhs into a temporary using .eval()");
443 template<
typename Derived,
typename OtherDerived>
446 static void run(
const Derived&,
const OtherDerived&)
451 template<
typename Dst,
typename Src>
454 if((!Dst::IsVectorAtCompileTime) && dst.rows()>1 && dst.cols()>1)
460 #endif // EIGEN_NO_DEBUG 464 #endif // EIGEN_TRANSPOSE_H
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index innerStride() const
internal::packet_traits< Scalar >::type Packet
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
#define EIGEN_STRONG_INLINE
void adjoint(const MatrixType &m)
static bool run(const Scalar *dest, const CwiseBinaryOp< BinOp, DerivedA, DerivedB > &src)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index nrows, Index ncols)
internal::conditional< internal::is_lvalue< MatrixType >::value, Scalar, const Scalar >::type ScalarWithConstIfNotLvalue
remove_reference< MatrixTypeNested >::type MatrixTypeNestedPlain
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _RhsNested & rhs() const
Expression of the transpose of a matrix.
void check_for_aliasing(const Dst &dst, const Src &src)
const unsigned int LvalueBit
internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
internal::TransposeImpl_base< MatrixType >::type Base
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T::Scalar * extract_data(const T &m)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
const unsigned int RowMajorBit
const unsigned int PacketAccessBit
EIGEN_DEVICE_FUNC void transposeInPlace()
dense_xpr_base< Transpose< MatrixType > >::type type
dense_xpr_base< Transpose< MatrixType > >::type type
Generic expression where a coefficient-wise binary operator is applied to two expressions.
EIGEN_DEVICE_FUNC void adjointInPlace()
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
static void run(MatrixType &m)
EIGEN_STRONG_INLINE void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
static void run(const Derived &, const OtherDerived &)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _LhsNested & lhs() const
const unsigned int NestByRefBit
#define EIGEN_DEVICE_FUNC
static void run(MatrixType &m)
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarWithConstIfNotLvalue * data()
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
internal::generic_xpr_base< Transpose< XprType > >::type Base
ref_selector< MatrixType >::type MatrixTypeNested
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< XprTypeNested >::type & nestedExpression() const
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
TransposeImpl< MatrixType, typename internal::traits< MatrixType >::StorageKind >::Base Base
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeffRef(Index index) const
static void run(const Derived &dst, const OtherDerived &other)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outerStride() const
internal::ref_selector< MatrixType >::non_const_type m_matrix
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeffRef(Index rowId, Index colId) const
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
static bool run(const Scalar *dest, const OtherDerived &src)
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
static void run(MatrixType &m)
void BlockedInPlaceTranspose(MatrixType &m)