10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H 23 template<
typename XprType>
24 struct traits<TensorEvalToOp<XprType> >
27 typedef typename XprType::Scalar Scalar;
28 typedef traits<XprType> XprTraits;
29 typedef typename XprTraits::StorageKind StorageKind;
30 typedef typename XprTraits::Index Index;
31 typedef typename XprType::Nested Nested;
32 typedef typename remove_reference<Nested>::type _Nested;
33 static const int NumDimensions = XprTraits::NumDimensions;
34 static const int Layout = XprTraits::Layout;
41 template<
typename XprType>
42 struct eval<TensorEvalToOp<XprType>,
Eigen::Dense>
44 typedef const TensorEvalToOp<XprType>& type;
47 template<
typename XprType>
48 struct nested<TensorEvalToOp<XprType>, 1, typename eval<TensorEvalToOp<XprType> >::type>
50 typedef TensorEvalToOp<XprType> type;
58 template<
typename XprType>
59 class TensorEvalToOp :
public TensorBase<TensorEvalToOp<XprType>, ReadOnlyAccessors>
62 typedef typename Eigen::internal::traits<TensorEvalToOp>::Scalar Scalar;
63 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
64 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
65 typedef typename Eigen::internal::nested<TensorEvalToOp>::type Nested;
66 typedef typename Eigen::internal::traits<TensorEvalToOp>::StorageKind StorageKind;
67 typedef typename Eigen::internal::traits<TensorEvalToOp>::Index Index;
69 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvalToOp(CoeffReturnType* buffer,
const XprType& expr)
70 : m_xpr(expr), m_buffer(buffer) {}
73 const typename internal::remove_all<typename XprType::Nested>::type&
74 expression()
const {
return m_xpr; }
76 EIGEN_DEVICE_FUNC CoeffReturnType* buffer()
const {
return m_buffer; }
79 typename XprType::Nested m_xpr;
80 CoeffReturnType* m_buffer;
85 template<
typename ArgType,
typename Device>
86 struct TensorEvaluator<const TensorEvalToOp<ArgType>, Device>
88 typedef TensorEvalToOp<ArgType> XprType;
89 typedef typename ArgType::Scalar Scalar;
90 typedef typename TensorEvaluator<ArgType, Device>::Dimensions Dimensions;
91 typedef typename XprType::Index Index;
92 typedef typename internal::remove_const<typename XprType::CoeffReturnType>::type CoeffReturnType;
93 typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType;
94 static const int PacketSize = internal::unpacket_traits<PacketReturnType>::size;
97 IsAligned = TensorEvaluator<ArgType, Device>::IsAligned,
98 PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
99 Layout = TensorEvaluator<ArgType, Device>::Layout,
104 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(
const XprType& op,
const Device& device)
105 : m_impl(op.expression(), device), m_device(device), m_buffer(op.buffer())
108 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ~TensorEvaluator() {
111 EIGEN_DEVICE_FUNC
const Dimensions& dimensions()
const {
return m_impl.dimensions(); }
113 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool evalSubExprsIfNeeded(CoeffReturnType* scalar) {
114 EIGEN_UNUSED_VARIABLE(scalar);
115 eigen_assert(scalar == NULL);
116 return m_impl.evalSubExprsIfNeeded(m_buffer);
119 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void evalScalar(Index i) {
120 m_buffer[i] = m_impl.coeff(i);
122 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void evalPacket(Index i) {
123 internal::pstoret<CoeffReturnType, PacketReturnType, Aligned>(m_buffer + i, m_impl.template packet<TensorEvaluator<ArgType, Device>::IsAligned ? Aligned : Unaligned>(i));
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void cleanup() {
130 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const 132 return m_buffer[index];
135 template<
int LoadMode>
136 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index)
const 138 return internal::ploadt<PacketReturnType, LoadMode>(m_buffer + index);
141 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(
bool vectorized)
const {
144 return m_impl.costPerCoeff(vectorized) +
145 TensorOpCost(0,
sizeof(CoeffReturnType), 0, vectorized, PacketSize);
148 EIGEN_DEVICE_FUNC CoeffReturnType* data()
const {
return m_buffer; }
151 TensorEvaluator<ArgType, Device> m_impl;
152 const Device& m_device;
153 CoeffReturnType* m_buffer;
159 #endif // EIGEN_CXX11_TENSOR_TENSOR_EVAL_TO_H Namespace containing all symbols from the Eigen library.
Definition: AdolcForward:45