10#ifndef EIGEN_CXX11_TENSOR_TENSOR_MAP_H
11#define EIGEN_CXX11_TENSOR_TENSOR_MAP_H
29template<
typename PlainObjectType,
int Options_,
template <
class>
class MakePointer_>
class TensorMap :
public TensorBase<TensorMap<PlainObjectType, Options_, MakePointer_> >
85#if EIGEN_HAS_VARIADIC_TEMPLATES
110 EIGEN_STRONG_INLINE TensorMap(
StoragePointerType dataPtr,
Index dim1,
Index dim2,
Index dim3,
Index dim4,
Index dim5) : m_data(dataPtr), m_dimensions(dim1, dim2, dim3, dim4, dim5) {
119 template <
typename Dimensions>
145 if (PlainObjectType::Options&
RowMajor) {
146 const Index index = m_dimensions.IndexOfRowMajor(indices);
147 return m_data[index];
149 const Index index = m_dimensions.IndexOfColMajor(indices);
150 return m_data[index];
165 return m_data[index];
168#if EIGEN_HAS_VARIADIC_TEMPLATES
174 if (PlainObjectType::Options&
RowMajor) {
176 return m_data[index];
178 const Index index = m_dimensions.IndexOfColMajor(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
179 return m_data[index];
186 if (PlainObjectType::Options&
RowMajor) {
187 const Index index = i1 + i0 * m_dimensions[1];
188 return m_data[index];
190 const Index index = i0 + i1 * m_dimensions[0];
191 return m_data[index];
197 if (PlainObjectType::Options&
RowMajor) {
198 const Index index = i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0);
199 return m_data[index];
201 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * i2);
202 return m_data[index];
208 if (PlainObjectType::Options&
RowMajor) {
209 const Index index = i3 + m_dimensions[3] * (i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0));
210 return m_data[index];
212 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * (i2 + m_dimensions[2] * i3));
213 return m_data[index];
219 if (PlainObjectType::Options&
RowMajor) {
220 const Index index = i4 + m_dimensions[4] * (i3 + m_dimensions[3] * (i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0)));
221 return m_data[index];
223 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * (i2 + m_dimensions[2] * (i3 + m_dimensions[3] * i4)));
224 return m_data[index];
233 if (PlainObjectType::Options&
RowMajor) {
234 const Index index = m_dimensions.IndexOfRowMajor(indices);
235 return m_data[index];
237 const Index index = m_dimensions.IndexOfColMajor(indices);
238 return m_data[index];
253 return m_data[index];
256#if EIGEN_HAS_VARIADIC_TEMPLATES
260 static_assert(
sizeof...(otherIndices) + 2 ==
NumIndices ||
NumIndices ==
Dynamic,
"Number of indices used to access a tensor coefficient must be equal to the rank of the tensor.");
262 const std::size_t NumDims =
sizeof...(otherIndices) + 2;
263 if (PlainObjectType::Options&
RowMajor) {
265 return m_data[index];
267 const Index index = m_dimensions.IndexOfColMajor(array<Index, NumDims>{{firstIndex, secondIndex, otherIndices...}});
268 return m_data[index];
275 if (PlainObjectType::Options&
RowMajor) {
276 const Index index = i1 + i0 * m_dimensions[1];
277 return m_data[index];
279 const Index index = i0 + i1 * m_dimensions[0];
280 return m_data[index];
286 if (PlainObjectType::Options&
RowMajor) {
287 const Index index = i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0);
288 return m_data[index];
290 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * i2);
291 return m_data[index];
297 if (PlainObjectType::Options&
RowMajor) {
298 const Index index = i3 + m_dimensions[3] * (i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0));
299 return m_data[index];
301 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * (i2 + m_dimensions[2] * i3));
302 return m_data[index];
308 if (PlainObjectType::Options&
RowMajor) {
309 const Index index = i4 + m_dimensions[4] * (i3 + m_dimensions[3] * (i2 + m_dimensions[2] * (i1 + m_dimensions[1] * i0)));
310 return m_data[index];
312 const Index index = i0 + m_dimensions[0] * (i1 + m_dimensions[1] * (i2 + m_dimensions[2] * (i3 + m_dimensions[3] * i4)));
313 return m_data[index];
int n
Definition BiCGSTAB_simple.cpp:1
#define eigen_internal_assert(x)
Definition Macros.h:1043
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition StaticAssert.h:127
#define EIGEN_TENSOR_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition TensorMacros.h:94
The tensor base class.
Definition TensorBase.h:973
A tensor expression mapping an existing array of data.
Definition TensorMap.h:30
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const
Definition TensorMap.h:129
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2)
Definition TensorMap.h:284
PlainObjectType::Dimensions Dimensions
Definition TensorMap.h:70
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2) const
Definition TensorMap.h:195
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(const array< Index, NumIndices > &indices)
Definition TensorMap.h:230
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2, Index i3) const
Definition TensorMap.h:206
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2, Index i3)
Definition TensorMap.h:295
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(PlainObjectType &tensor)
Definition TensorMap.h:124
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1) const
Definition TensorMap.h:184
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index dim1, Index dim2, Index dim3, Index dim4, Index dim5)
Definition TensorMap.h:110
Eigen::internal::nested< Self >::type Nested
Definition TensorMap.h:37
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition TensorMap.h:133
MakePointer_< Scalar >::ConstType PointerConstType
Definition TensorMap.h:46
MakePointer_< Scalar >::Type PointerType
Definition TensorMap.h:45
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(const array< Index, NumIndices > &indices) const
Definition TensorMap.h:142
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StoragePointerType data() const
Definition TensorMap.h:139
internal::conditional< bool(internal::is_lvalue< PlainObjectType >::value), Scalar &, constScalar & >::type StorageRefType
Definition TensorMap.h:65
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index dim1, Index dim2)
Definition TensorMap.h:98
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
Definition TensorMap.h:135
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1)
Definition TensorMap.h:273
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StoragePointerType data()
Definition TensorMap.h:137
TensorMap< PlainObjectType, Options_, MakePointer_ > Self
Definition TensorMap.h:32
internal::traits< PlainObjectType >::StorageKind StorageKind
Definition TensorMap.h:39
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2, Index i3, Index i4) const
Definition TensorMap.h:217
internal::traits< PlainObjectType >::Scalar Scalar
Definition TensorMap.h:41
PlainObjectType::Base::CoeffReturnType CoeffReturnType
Definition TensorMap.h:43
@ Layout
Definition TensorMap.h:74
@ CoordAccess
Definition TensorMap.h:75
@ RawAccess
Definition TensorMap.h:76
@ IsAligned
Definition TensorMap.h:73
TensorBase< TensorMap< PlainObjectType, Options_, MakePointer_ > > Base
Definition TensorMap.h:33
internal::conditional< bool(internal::is_lvalue< PlainObjectType >::value), PointerType, PointerConstType >::type StoragePointerType
Definition TensorMap.h:56
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()() const
Definition TensorMap.h:155
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr)
Definition TensorMap.h:80
static const Index NumIndices
Definition TensorMap.h:69
NumTraits< Scalar >::Real RealScalar
Definition TensorMap.h:42
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()()
Definition TensorMap.h:243
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index index)
Definition TensorMap.h:250
internal::traits< PlainObjectType >::Index Index
Definition TensorMap.h:40
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index index) const
Definition TensorMap.h:162
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageRefType operator()(Index i0, Index i1, Index i2, Index i3, Index i4)
Definition TensorMap.h:306
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, const array< Index, NumIndices > &dimensions)
Definition TensorMap.h:115
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(Index n) const
Definition TensorMap.h:131
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index dim1, Index dim2, Index dim3, Index dim4)
Definition TensorMap.h:106
static const int Options
Definition TensorMap.h:67
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index dim1, Index dim2, Index dim3)
Definition TensorMap.h:102
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index firstDimension)
Definition TensorMap.h:93
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, const Dimensions &dimensions)
Definition TensorMap.h:120
Definition EmulateArray.h:21
Definition TensorRef.h:81
@ Aligned
Definition Constants.h:240
@ RowMajor
Definition Constants.h:321
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
Definition XprHelper.h:660
Definition ForwardDeclarations.h:17