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>
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>
197 return ConstTransposeReturnType(derived());
219 template<
typename Derived>
233 bool IsSquare = (MatrixType::RowsAtCompileTime == MatrixType::ColsAtCompileTime) && MatrixType::RowsAtCompileTime!=
Dynamic,
234 bool MatchPacketSize =
237 struct inplace_transpose_selector;
239 template<
typename MatrixType>
242 m.matrix().template triangularView<StrictlyUpper>().swap(
m.matrix().transpose().template triangularView<StrictlyUpper>());
246 template<
typename MatrixType>
247 struct inplace_transpose_selector<
MatrixType,true,true> {
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]);
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);
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>
301 struct inplace_transpose_selector<
MatrixType,false,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
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()");
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