10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H 38 template<
typename XprType>
39 struct traits<TensorLayoutSwapOp<XprType> > :
public traits<XprType>
41 typedef typename XprType::Scalar Scalar;
42 typedef traits<XprType> XprTraits;
43 typedef typename XprTraits::StorageKind StorageKind;
44 typedef typename XprTraits::Index Index;
45 typedef typename XprType::Nested Nested;
46 typedef typename remove_reference<Nested>::type _Nested;
47 static const int NumDimensions = traits<XprType>::NumDimensions;
48 static const int Layout = (traits<XprType>::Layout == ColMajor) ? RowMajor : ColMajor;
51 template<
typename XprType>
52 struct eval<TensorLayoutSwapOp<XprType>,
Eigen::Dense>
54 typedef const TensorLayoutSwapOp<XprType>& type;
57 template<
typename XprType>
58 struct nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType> >::type>
60 typedef TensorLayoutSwapOp<XprType> type;
67 template<
typename XprType>
68 class TensorLayoutSwapOp :
public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors>
71 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Scalar Scalar;
72 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
73 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
74 typedef typename Eigen::internal::nested<TensorLayoutSwapOp>::type Nested;
75 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::StorageKind StorageKind;
76 typedef typename Eigen::internal::traits<TensorLayoutSwapOp>::Index Index;
78 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp(
const XprType& expr)
82 const typename internal::remove_all<typename XprType::Nested>::type&
83 expression()
const {
return m_xpr; }
86 EIGEN_STRONG_INLINE TensorLayoutSwapOp& operator = (
const TensorLayoutSwapOp& other)
88 typedef TensorAssignOp<TensorLayoutSwapOp, const TensorLayoutSwapOp> Assign;
89 Assign assign(*
this, other);
90 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
94 template<
typename OtherDerived>
96 EIGEN_STRONG_INLINE TensorLayoutSwapOp& operator = (
const OtherDerived& other)
98 typedef TensorAssignOp<TensorLayoutSwapOp, const OtherDerived> Assign;
99 Assign assign(*
this, other);
100 internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
105 typename XprType::Nested m_xpr;
110 template<
typename ArgType,
typename Device>
111 struct TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
113 typedef TensorLayoutSwapOp<ArgType> XprType;
114 typedef typename XprType::Index Index;
115 static const int NumDims = internal::array_size<typename TensorEvaluator<ArgType, Device>::Dimensions>::value;
116 typedef DSizes<Index, NumDims> Dimensions;
119 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
120 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
121 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) == static_cast<int>(ColMajor)) ? RowMajor : ColMajor,
123 RawAccess = TensorEvaluator<ArgType, Device>::RawAccess
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
127 : m_impl(op.expression(), device)
129 for(
int i = 0; i < NumDims; ++i) {
130 m_dimensions[i] = m_impl.dimensions()[NumDims-1-i];
134 typedef typename XprType::Scalar Scalar;
135 typedef typename XprType::CoeffReturnType CoeffReturnType;
136 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
138 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_dimensions; }
140 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(CoeffReturnType* data) {
141 return m_impl.evalSubExprsIfNeeded(data);
143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void cleanup() {
147 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const 149 return m_impl.coeff(index);
152 template<
int LoadMode>
153 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const 155 return m_impl.template packet<LoadMode>(index);
158 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
159 return m_impl.costPerCoeff(vectorized);
162 EIGEN_DEVICE_FUNC Scalar* data()
const {
return m_impl.data(); }
164 const TensorEvaluator<ArgType, Device>& impl()
const {
return m_impl; }
167 TensorEvaluator<ArgType, Device> m_impl;
168 Dimensions m_dimensions;
173 template<
typename ArgType,
typename Device>
174 struct TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>
175 :
public TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>
177 typedef TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device> Base;
178 typedef TensorLayoutSwapOp<ArgType> XprType;
181 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
182 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
183 Layout = (
static_cast<int>(TensorEvaluator<ArgType, Device>::Layout) == static_cast<int>(ColMajor)) ? RowMajor : ColMajor,
187 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
191 typedef typename XprType::Index Index;
192 typedef typename XprType::Scalar Scalar;
193 typedef typename XprType::CoeffReturnType CoeffReturnType;
194 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
196 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(Index index)
198 return this->m_impl.coeffRef(index);
200 template <
int StoreMode> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
201 void writePacket(Index index,
const PacketReturnType& x)
203 this->m_impl.template writePacket<StoreMode>(index, x);
209 #endif // EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H Namespace containing all symbols from the Eigen library.
Definition: AdolcForward:45