10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_FIXED_SIZE_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_FIXED_SIZE_H 26 template<
typename Scalar_,
typename Dimensions_,
int Options_,
typename IndexType>
35 typedef Scalar_ Scalar;
37 typedef typename Base::CoeffReturnType CoeffReturnType;
39 static const int Options = Options_;
42 IsAligned = bool(EIGEN_MAX_ALIGN_BYTES>0),
48 typedef Dimensions_ Dimensions;
49 static const std::size_t NumIndices = Dimensions::count;
55 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank()
const {
return NumIndices; }
56 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n)
const {
return m_storage.dimensions()[n]; }
57 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions()
const {
return m_storage.dimensions(); }
58 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size()
const {
return m_storage.size(); }
59 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *data() {
return m_storage.data(); }
60 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar *data()
const {
return m_storage.data(); }
65 inline Self& base() {
return *
this; }
66 inline const Self& base()
const {
return *
this; }
68 #if EIGEN_HAS_VARIADIC_TEMPLATES 69 template<
typename... IndexTypes>
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar& coeff(Index firstIndex, IndexTypes... otherIndices)
const 73 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
81 eigen_internal_assert(checkIndexRange(indices));
82 return m_storage.data()[linearizedIndex(indices)];
86 EIGEN_STRONG_INLINE
const Scalar& coeff(Index index)
const 88 eigen_internal_assert(index >= 0 && index < size());
89 return m_storage.data()[index];
93 EIGEN_STRONG_INLINE
const Scalar& coeff()
const 95 EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
96 return m_storage.data()[0];
100 #if EIGEN_HAS_VARIADIC_TEMPLATES 101 template<
typename... IndexTypes>
102 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index firstIndex, IndexTypes... otherIndices)
105 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
113 eigen_internal_assert(checkIndexRange(indices));
114 return m_storage.data()[linearizedIndex(indices)];
118 EIGEN_STRONG_INLINE Scalar& coeffRef(Index index)
120 eigen_internal_assert(index >= 0 && index < size());
121 return m_storage.data()[index];
125 EIGEN_STRONG_INLINE Scalar& coeffRef()
127 EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
128 return m_storage.data()[0];
131 #if EIGEN_HAS_VARIADIC_TEMPLATES 132 template<
typename... IndexTypes>
133 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar& operator()(Index firstIndex, IndexTypes... otherIndices)
const 136 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
141 EIGEN_STRONG_INLINE
const Scalar& operator()(Index i0, Index i1)
const 144 const Index index = i1 + i0 * m_storage.dimensions()[1];
145 return m_storage.data()[index];
147 const Index index = i0 + i1 * m_storage.dimensions()[0];
148 return m_storage.data()[index];
152 EIGEN_STRONG_INLINE
const Scalar& operator()(Index i0, Index i1, Index i2)
const 155 const Index index = i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0);
156 return m_storage.data()[index];
158 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * i2);
159 return m_storage.data()[index];
163 EIGEN_STRONG_INLINE
const Scalar& operator()(Index i0, Index i1, Index i2, Index i3)
const 166 const Index index = i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0));
167 return m_storage.data()[index];
169 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * i3));
170 return m_storage.data()[index];
174 EIGEN_STRONG_INLINE
const Scalar& operator()(Index i0, Index i1, Index i2, Index i3, Index i4)
const 177 const Index index = i4 + m_storage.dimensions()[4] * (i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0)));
178 return m_storage.data()[index];
180 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * (i3 + m_storage.dimensions()[3] * i4)));
181 return m_storage.data()[index];
190 eigen_assert(checkIndexRange(indices));
191 return coeff(indices);
195 EIGEN_STRONG_INLINE
const Scalar& operator()(Index index)
const 197 eigen_internal_assert(index >= 0 && index < size());
202 EIGEN_STRONG_INLINE
const Scalar& operator()()
const 204 EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
209 EIGEN_STRONG_INLINE
const Scalar& operator[](Index index)
const 212 EIGEN_STATIC_ASSERT(NumIndices == 1, YOU_MADE_A_PROGRAMMING_MISTAKE);
216 #if EIGEN_HAS_VARIADIC_TEMPLATES 217 template<
typename... IndexTypes>
218 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& operator()(Index firstIndex, IndexTypes... otherIndices)
221 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
226 EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1)
229 const Index index = i1 + i0 * m_storage.dimensions()[1];
230 return m_storage.data()[index];
232 const Index index = i0 + i1 * m_storage.dimensions()[0];
233 return m_storage.data()[index];
237 EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2)
240 const Index index = i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0);
241 return m_storage.data()[index];
243 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * i2);
244 return m_storage.data()[index];
248 EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2, Index i3)
251 const Index index = i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0));
252 return m_storage.data()[index];
254 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * i3));
255 return m_storage.data()[index];
259 EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2, Index i3, Index i4)
262 const Index index = i4 + m_storage.dimensions()[4] * (i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0)));
263 return m_storage.data()[index];
265 const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * (i3 + m_storage.dimensions()[3] * i4)));
266 return m_storage.data()[index];
274 eigen_assert(checkIndexRange(indices));
275 return coeffRef(indices);
279 EIGEN_STRONG_INLINE Scalar& operator()(Index index)
281 eigen_assert(index >= 0 && index < size());
282 return coeffRef(index);
286 EIGEN_STRONG_INLINE Scalar& operator()()
288 EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
293 EIGEN_STRONG_INLINE Scalar& operator[](Index index)
296 EIGEN_STATIC_ASSERT(NumIndices == 1, YOU_MADE_A_PROGRAMMING_MISTAKE)
297 return coeffRef(index);
307 EIGEN_STRONG_INLINE TensorFixedSize(
const Self& other)
308 : m_storage(other.m_storage)
312 #if EIGEN_HAS_RVALUE_REFERENCES 313 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorFixedSize(Self&& other)
314 : m_storage(other.m_storage)
319 template<
typename OtherDerived>
324 Assign assign(*
this, other.derived());
327 template<
typename OtherDerived>
332 Assign assign(*
this, other.derived());
337 EIGEN_STRONG_INLINE TensorFixedSize& operator=(
const TensorFixedSize& other)
342 Assign assign(*
this, other);
346 template<
typename OtherDerived>
348 EIGEN_STRONG_INLINE TensorFixedSize& operator=(
const OtherDerived& other)
353 Assign assign(*
this, other);
362 using internal::array_apply_and_reduce;
363 using internal::array_zip_and_reduce;
379 return m_storage.dimensions().IndexOfRowMajor(indices);
381 return m_storage.dimensions().IndexOfColMajor(indices);
389 #endif // EIGEN_CXX11_TENSOR_TENSOR_FIXED_SIZE_H Definition: TensorExecutor.h:27
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: TensorAssign.h:60
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
Definition: EmulateCXX11Meta.h:252
Definition: TensorDeviceDefault.h:17
The fixed sized version of the tensor class.
Definition: TensorFixedSize.h:27
The tensor base class.
Definition: TensorBase.h:827
Definition: EmulateArray.h:21
Definition: EmulateCXX11Meta.h:219
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Definition: EmulateCXX11Meta.h:232
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Definition: ForwardDeclarations.h:17