10#ifndef EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
11#define EIGEN_CXX11_TENSOR_TENSOR_TRAITS_H
14#include "./InternalHeaderCheck.h"
19template <
typename Scalar,
int Options>
20class 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 };
44template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
45struct 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;
62template <
typename Scalar_,
typename Dimensions,
int Options_,
typename IndexType_>
63struct 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;
80template <
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
81struct 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;
98template <
typename PlainObjectType_>
99struct 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;
111template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
112struct eval<Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
113 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
116template <
typename Scalar_,
int NumIndices_,
int Options,
typename IndexType_>
117struct eval<const Tensor<Scalar_, NumIndices_, Options, IndexType_>, Eigen::Dense> {
118 typedef const Tensor<Scalar_, NumIndices_, Options, IndexType_> EIGEN_DEVICE_REF type;
121template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
122struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
123 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
126template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
127struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> {
128 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
131template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
132struct eval<TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
133 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
136template <
typename PlainObjectType,
int Options,
template <
class>
class MakePointer>
137struct eval<const TensorMap<PlainObjectType, Options, MakePointer>, Eigen::Dense> {
138 typedef const TensorMap<PlainObjectType, Options, MakePointer> EIGEN_DEVICE_REF type;
141template <
typename PlainObjectType>
142struct eval<TensorRef<PlainObjectType>, Eigen::Dense> {
143 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
146template <
typename PlainObjectType>
147struct eval<const TensorRef<PlainObjectType>, Eigen::Dense> {
148 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
152template <
typename T,
int n = 1,
typename PlainObject =
void>
154 typedef typename ref_selector<T>::type type;
157template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
158struct nested<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
159 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_> EIGEN_DEVICE_REF type;
162template <
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
163struct nested<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> > {
164 typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_> EIGEN_DEVICE_REF type;
167template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
168struct nested<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {
169 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
172template <
typename Scalar_,
typename Dimensions,
int Options,
typename IndexType_>
173struct nested<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > {
174 typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> EIGEN_DEVICE_REF type;
177template <
typename PlainObjectType>
178struct nested<TensorRef<PlainObjectType> > {
179 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
182template <
typename PlainObjectType>
183struct nested<const TensorRef<PlainObjectType> > {
184 typedef const TensorRef<PlainObjectType> EIGEN_DEVICE_REF type;
228enum PaddingType { PADDING_VALID = 1, PADDING_SAME = 2 };
const unsigned int PacketAccessBit
const unsigned int LvalueBit
Namespace containing all symbols from the Eigen library.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index