10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H 14 #include "./InternalHeaderCheck.h" 19 template <
typename Scalar,
int Options>
20 class compute_tensor_flags {
22 is_dynamic_size_storage = 1,
24 is_aligned = (((Options &
DontAlign) == 0) && (
25 #if EIGEN_MAX_STATIC_ALIGN_BYTES > 0 26 (!is_dynamic_size_storage)
31 #
if EIGEN_MAX_ALIGN_BYTES > 0
32 is_dynamic_size_storage
37 packet_access_bit = packet_traits<Scalar>::Vectorizable && is_aligned ?
PacketAccessBit : 0
41 enum { ret = packet_access_bit };
44 template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
45 struct traits<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
46 typedef Scalar_ Scalar;
47 typedef Dense StorageKind;
48 typedef IndexType_
Index;
49 static constexpr
int NumDimensions = NumIndices_;
53 Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0 :
LvalueBit)
59 typedef typename MakePointer<Scalar>::Type PointerType;
62 template <
typename Scalar_,
typename Dimensions,
int Options_,
typename IndexType_>
63 struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> > {
64 typedef Scalar_ Scalar;
65 typedef Dense StorageKind;
66 typedef IndexType_
Index;
67 static constexpr
int NumDimensions = array_size<Dimensions>::value;
71 Flags = compute_tensor_flags<Scalar_, Options_>::ret | (is_const<Scalar_>::value ? 0 :
LvalueBit)
77 typedef typename MakePointer<Scalar>::Type PointerType;
80 template <
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
81 struct traits<TensorMap<PlainObjectType, Options_, MakePointer_> > :
public traits<PlainObjectType> {
82 typedef traits<PlainObjectType> BaseTraits;
83 typedef typename BaseTraits::Scalar Scalar;
84 typedef typename BaseTraits::StorageKind StorageKind;
85 typedef typename BaseTraits::Index
Index;
86 static constexpr
int NumDimensions = BaseTraits::NumDimensions;
87 static constexpr
int Layout = BaseTraits::Layout;
88 enum { Options = Options_, Flags = BaseTraits::Flags };
92 typedef MakePointer_<T> MakePointerT;
93 typedef typename MakePointerT::Type Type;
95 typedef typename MakePointer<Scalar>::Type PointerType;
98 template <
typename PlainObjectType_>
99 struct traits<TensorRef<PlainObjectType_> > :
public traits<PlainObjectType_> {
100 typedef PlainObjectType_ PlainObjectType;
101 typedef traits<PlainObjectType> BaseTraits;
102 typedef typename BaseTraits::Scalar Scalar;
103 typedef typename BaseTraits::StorageKind StorageKind;
104 typedef typename BaseTraits::Index
Index;
105 static constexpr
int NumDimensions = BaseTraits::NumDimensions;
106 static constexpr
int Layout = BaseTraits::Layout;
107 enum { Options = BaseTraits::Options, Flags = BaseTraits::Flags };
108 typedef typename BaseTraits::PointerType PointerType;
111 template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
112 struct eval<Tensor<Scalar_, NumIndices_, Options, IndexType_>,
Eigen::Dense> {
113 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
116 template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
117 struct eval<const Tensor<Scalar_, NumIndices_, Options, IndexType_>,
Eigen::Dense> {
118 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
121 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
122 struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>,
Eigen::Dense> {
123 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
126 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
127 struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>,
Eigen::Dense> {
128 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
131 template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
132 struct eval<TensorMap<PlainObjectType, Options, MakePointer>,
Eigen::Dense> {
133 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
136 template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
137 struct eval<const TensorMap<PlainObjectType, Options, MakePointer>,
Eigen::Dense> {
138 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
141 template <
typename PlainObjectType>
142 struct eval<TensorRef<PlainObjectType>,
Eigen::Dense> {
143 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
146 template <
typename PlainObjectType>
147 struct eval<const TensorRef<PlainObjectType>,
Eigen::Dense> {
148 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
152 template <
typename T,
int n = 1,
typename PlainObject =
void>
154 typedef typename ref_selector<T>::type type;
157 template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
158 struct nested<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
159 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_> EIGEN_DEVICE_REF type;
162 template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
163 struct nested<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
164 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_> EIGEN_DEVICE_REF type;
167 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
168 struct nested<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {
169 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
172 template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
173 struct nested<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {
174 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
177 template <
typename PlainObjectType>
178 struct nested<TensorRef<PlainObjectType> > {
179 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
182 template <
typename PlainObjectType>
183 struct nested<const TensorRef<PlainObjectType> > {
184 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
228 enum PaddingType { PADDING_VALID = 1, PADDING_SAME = 2 };
232 #endif // EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
const unsigned int LvalueBit
Namespace containing all symbols from the Eigen library.
const unsigned int PacketAccessBit
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index