| 110 | */ |
| 111 | template<typename _Derived, bool _Conjugated> |
| 112 | class TransposeOp : public CwiseOp<TransposeOp<_Derived, _Conjugated>> |
| 113 | { |
| 114 | public: |
| 115 | typedef CwiseOp<TransposeOp<_Derived, _Conjugated>> Base; |
| 116 | using Type = TransposeOp<_Derived, _Conjugated>; |
| 117 | CUMAT_PUBLIC_API |
| 118 | |
| 119 | enum |
| 120 | { |
| 121 | OriginalFlags = internal::traits<_Derived>::Flags, |
| 122 | IsMatrix = std::is_same< _Derived, Matrix<Scalar, Columns, Rows, Batches, OriginalFlags> >::value, |
| 123 | IsConjugated = _Conjugated && internal::NumTraits<typename internal::traits<_Derived>::Scalar>::IsComplex |
| 124 | }; |
| 125 | |
| 126 | using Base::size; |
| 127 | |
| 128 | protected: |
| 129 | const _Derived matrix_; |
| 130 | |
| 131 | public: |
| 132 | explicit TransposeOp(const MatrixBase<_Derived>& child) |
| 133 | : matrix_(child.derived()) |
| 134 | {} |
| 135 | |
| 136 | __host__ __device__ CUMAT_STRONG_INLINE Index rows() const { return matrix_.cols(); } |
| 137 | __host__ __device__ CUMAT_STRONG_INLINE Index cols() const { return matrix_.rows(); } |
| 138 | __host__ __device__ CUMAT_STRONG_INLINE Index batches() const { return matrix_.batches(); } |
| 139 | |
| 140 | __device__ CUMAT_STRONG_INLINE Scalar coeff(Index row, Index col, Index batch, Index index) const |
| 141 | { //read acces (cwise) |
| 142 | Scalar val = matrix_.coeff(col, row, batch, -1); |
| 143 | val = internal::TransposeFunctor<Scalar>()(val); |
| 144 | val = internal::conjugateCoeff<Scalar, IsConjugated>(val); |
| 145 | return val; |
| 146 | } |
| 147 | __device__ CUMAT_STRONG_INLINE Scalar& coeff(Index row, Index col, Index batch, Index index) |
| 148 | { //write acces (cwise) |
| 149 | //adjoint not allowed here |
| 150 | return matrix_.coeff(col, row, batch, -1); |
| 151 | } |
| 152 | |
| 153 | const _Derived& getUnderlyingMatrix() const |
| 154 | { |
| 155 | return matrix_; |
| 156 | } |
| 157 | |
| 158 | //ASSIGNMENT |
| 159 | template<typename Derived> |
| 160 | CUMAT_STRONG_INLINE Type& operator=(const MatrixBase<Derived>& expr) |
| 161 | { |
| 162 | CUMAT_ASSERT_ARGUMENT(rows() == expr.rows()); |
| 163 | CUMAT_ASSERT_ARGUMENT(cols() == expr.cols()); |
| 164 | CUMAT_ASSERT_ARGUMENT(batches() == expr.batches()); |
| 165 | internal::Assignment<Type, Derived, AssignmentMode::ASSIGN, internal::DenseDstTag, typename internal::traits<Derived>::SrcTag> |
| 166 | ::assign(*this, expr); |
| 167 | //expr.template evalTo<Type, AssignmentMode::ASSIGN>(*this); |
| 168 | return *this; |
| 169 | } |