Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ > Class Template Reference

A tensor expression mapping an existing array of data. More...

+ Inheritance diagram for Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >:

Public Types

enum  {
  IsAligned ,
  CoordAccess ,
  RawAccess
}
 
typedef TensorBase< TensorMap< PlainObjectType, Options_, MakePointer_ > > Base
 
typedef PlainObjectType::Base::CoeffReturnType CoeffReturnType
 
typedef PlainObjectType::Dimensions Dimensions
 
typedef internal::traits< PlainObjectType >::Index Index
 
typedef Eigen::internal::nested< Self >::type Nested
 
typedef MakePointer_< Scalar >::ConstType PointerConstType
 
typedef MakePointer_< Scalar >::Type PointerType
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::traits< PlainObjectType >::Scalar Scalar
 
typedef TensorMap< PlainObjectType, Options_, MakePointer_ > Self
 
typedef internal::traits< PlainObjectType >::StorageKind StorageKind
 
typedef std::conditional_t< bool(internal::is_lvalue< PlainObjectType >::value), PointerType, PointerConstType > StoragePointerType
 
typedef std::conditional_t< bool(internal::is_lvalue< PlainObjectType >::value), Scalar &, const Scalar & > StorageRefType
 

Public Member Functions

StoragePointerType data ()
 
StoragePointerType data () const
 
Index dimension (Index n) const
 
const Dimensions & dimensions () const
 
StorageRefType operator() ()
 
StorageRefType operator() () const
 
StorageRefType operator() (const array< Index, NumIndices > &indices)
 
StorageRefType operator() (const array< Index, NumIndices > &indices) const
 
template<typename... IndexTypes>
StorageRefType operator() (Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
 
template<typename... IndexTypes>
StorageRefType operator() (Index firstIndex, Index secondIndex, IndexTypes... otherIndices) const
 
StorageRefType operator() (Index index)
 
StorageRefType operator() (Index index) const
 
Index rank () const
 
Index size () const
 
 TensorMap (PlainObjectType &tensor)
 
 TensorMap (StoragePointerType dataPtr)
 
 TensorMap (StoragePointerType dataPtr, const array< Index, NumIndices > &dimensions)
 
template<typename Dimensions >
 TensorMap (StoragePointerType dataPtr, const Dimensions &dimensions)
 
template<typename... IndexTypes>
 TensorMap (StoragePointerType dataPtr, Index firstDimension, IndexTypes... otherDimensions)
 

Static Public Attributes

static constexpr int Layout
 
static constexpr Index NumIndices
 
static constexpr int Options
 

Private Attributes

StoragePointerType m_data
 
Dimensions m_dimensions
 

Detailed Description

template<typename PlainObjectType, int Options_, template< class > class MakePointer_>
class Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >

A tensor expression mapping an existing array of data.

template <class> class MakePointer_ is added to convert the host pointer to the device pointer. It is added due to the fact that for our device compiler T* is not allowed. If we wanted to use the same Evaluator functions we have to convert that type to our pointer T. This is done through our MakePointer_ class. By default the Type in the MakePointer_<T> is T* . Therefore, by adding the default value, we managed to convert the type and it does not break any existing code as its default value is T*.

Definition at line 31 of file TensorMap.h.

Member Typedef Documentation

◆ Base

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef TensorBase<TensorMap<PlainObjectType, Options_, MakePointer_> > Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Base

Definition at line 35 of file TensorMap.h.

◆ CoeffReturnType

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef PlainObjectType::Base::CoeffReturnType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::CoeffReturnType

Definition at line 45 of file TensorMap.h.

◆ Dimensions

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef PlainObjectType::Dimensions Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Dimensions

Definition at line 72 of file TensorMap.h.

◆ Index

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef internal::traits<PlainObjectType>::Index Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Index

Definition at line 42 of file TensorMap.h.

◆ Nested

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef Eigen::internal::nested<Self>::type Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Nested

Definition at line 39 of file TensorMap.h.

◆ PointerConstType

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef MakePointer_<Scalar>::ConstType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::PointerConstType

Definition at line 48 of file TensorMap.h.

◆ PointerType

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef MakePointer_<Scalar>::Type Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::PointerType

Definition at line 47 of file TensorMap.h.

◆ RealScalar

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef NumTraits<Scalar>::Real Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::RealScalar

Definition at line 44 of file TensorMap.h.

◆ Scalar

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef internal::traits<PlainObjectType>::Scalar Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Scalar

Definition at line 43 of file TensorMap.h.

◆ Self

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef TensorMap<PlainObjectType, Options_, MakePointer_> Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Self

Definition at line 34 of file TensorMap.h.

◆ StorageKind

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef internal::traits<PlainObjectType>::StorageKind Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::StorageKind

Definition at line 41 of file TensorMap.h.

◆ StoragePointerType

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef std::conditional_t< bool(internal::is_lvalue<PlainObjectType>::value), PointerType, PointerConstType > Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::StoragePointerType

Definition at line 58 of file TensorMap.h.

◆ StorageRefType

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
typedef std::conditional_t< bool(internal::is_lvalue<PlainObjectType>::value), Scalar&, const Scalar& > Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::StorageRefType

Definition at line 67 of file TensorMap.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
anonymous enum
Enumerator
IsAligned 
CoordAccess 
RawAccess 

Definition at line 75 of file TensorMap.h.

75  {
76  IsAligned = ((int(Options_)&Aligned)==Aligned),
77  CoordAccess = true,
78  RawAccess = true
79  };

Constructor & Destructor Documentation

◆ TensorMap() [1/5]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::TensorMap ( StoragePointerType  dataPtr)
inline

Definition at line 82 of file TensorMap.h.

82  : m_data(dataPtr), m_dimensions() {
83  // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
84  EIGEN_STATIC_ASSERT((0 == NumIndices || NumIndices == Dynamic), YOU_MADE_A_PROGRAMMING_MISTAKE)
85  }
#define EIGEN_STATIC_ASSERT(X, MSG)
StoragePointerType m_data
Definition: TensorMap.h:205
static constexpr Index NumIndices
Definition: TensorMap.h:71
Dimensions m_dimensions
Definition: TensorMap.h:206
const int Dynamic

◆ TensorMap() [2/5]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
template<typename... IndexTypes>
Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::TensorMap ( StoragePointerType  dataPtr,
Index  firstDimension,
IndexTypes...  otherDimensions 
)
inline

Definition at line 88 of file TensorMap.h.

88  : m_data(dataPtr), m_dimensions(firstDimension, otherDimensions...) {
89  // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
90  EIGEN_STATIC_ASSERT((sizeof...(otherDimensions) + 1 == NumIndices || NumIndices == Dynamic), YOU_MADE_A_PROGRAMMING_MISTAKE)
91  }

◆ TensorMap() [3/5]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::TensorMap ( StoragePointerType  dataPtr,
const array< Index, NumIndices > &  dimensions 
)
inline

Definition at line 93 of file TensorMap.h.

94  : m_data(dataPtr), m_dimensions(dimensions)
95  { }
const Dimensions & dimensions() const
Definition: TensorMap.h:111

◆ TensorMap() [4/5]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
template<typename Dimensions >
Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::TensorMap ( StoragePointerType  dataPtr,
const Dimensions &  dimensions 
)
inline

Definition at line 98 of file TensorMap.h.

99  : m_data(dataPtr), m_dimensions(dimensions)
100  { }

◆ TensorMap() [5/5]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::TensorMap ( PlainObjectType &  tensor)
inline

Definition at line 102 of file TensorMap.h.

103  : m_data(tensor.data()), m_dimensions(tensor.dimensions())
104  { }

Member Function Documentation

◆ data() [1/2]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StoragePointerType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::data ( )
inline

Definition at line 115 of file TensorMap.h.

115 { return m_data; }

◆ data() [2/2]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StoragePointerType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::data ( ) const
inline

Definition at line 117 of file TensorMap.h.

117 { return m_data; }

◆ dimension()

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Index Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::dimension ( Index  n) const
inline

Definition at line 109 of file TensorMap.h.

109 { return m_dimensions[n]; }
int n

◆ dimensions()

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
const Dimensions& Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::dimensions ( ) const
inline

Definition at line 111 of file TensorMap.h.

111 { return m_dimensions; }

◆ operator()() [1/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( )
inline

Definition at line 174 of file TensorMap.h.

175  {
176  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE)
177  return m_data[0];
178  }

◆ operator()() [2/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( ) const
inline

Definition at line 133 of file TensorMap.h.

134  {
135  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE)
136  return m_data[0];
137  }

◆ operator()() [3/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( const array< Index, NumIndices > &  indices)
inline

Definition at line 161 of file TensorMap.h.

162  {
163  // eigen_assert(checkIndexRange(indices));
164  if (PlainObjectType::Options&RowMajor) {
165  const Index index = m_dimensions.IndexOfRowMajor(indices);
166  return m_data[index];
167  } else {
168  const Index index = m_dimensions.IndexOfColMajor(indices);
169  return m_data[index];
170  }
171  }
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index

◆ operator()() [4/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( const array< Index, NumIndices > &  indices) const
inline

Definition at line 120 of file TensorMap.h.

121  {
122  // eigen_assert(checkIndexRange(indices));
123  if (PlainObjectType::Options&RowMajor) {
124  const Index index = m_dimensions.IndexOfRowMajor(indices);
125  return m_data[index];
126  } else {
127  const Index index = m_dimensions.IndexOfColMajor(indices);
128  return m_data[index];
129  }
130  }

◆ operator()() [5/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
template<typename... IndexTypes>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
)
inline

Definition at line 188 of file TensorMap.h.

189  {
190  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.");
192  const std::size_t NumDims = sizeof...(otherIndices) + 2;
193  if (PlainObjectType::Options&RowMajor) {
194  const Index index = m_dimensions.IndexOfRowMajor(array<Index, NumDims>{{firstIndex, secondIndex, otherIndices...}});
195  return m_data[index];
196  } else {
197  const Index index = m_dimensions.IndexOfColMajor(array<Index, NumDims>{{firstIndex, secondIndex, otherIndices...}});
198  return m_data[index];
199  }
200  }
#define eigen_assert(x)
std::array< T, N > array

◆ operator()() [6/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
template<typename... IndexTypes>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
) const
inline

Definition at line 147 of file TensorMap.h.

148  {
149  EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
151  if (PlainObjectType::Options&RowMajor) {
152  const Index index = m_dimensions.IndexOfRowMajor(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
153  return m_data[index];
154  } else {
155  const Index index = m_dimensions.IndexOfColMajor(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
156  return m_data[index];
157  }
158  }

◆ operator()() [7/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( Index  index)
inline

Definition at line 181 of file TensorMap.h.

182  {
183  eigen_internal_assert(index >= 0 && index < size());
184  return m_data[index];
185  }
#define eigen_internal_assert(x)
Index size() const
Definition: TensorMap.h:113

◆ operator()() [8/8]

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StorageRefType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::operator() ( Index  index) const
inline

Definition at line 140 of file TensorMap.h.

141  {
142  eigen_internal_assert(index >= 0 && index < size());
143  return m_data[index];
144  }

◆ rank()

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Index Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::rank ( ) const
inline

Definition at line 107 of file TensorMap.h.

107 { return m_dimensions.rank(); }

◆ size()

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Index Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::size ( ) const
inline

Definition at line 113 of file TensorMap.h.

113 { return m_dimensions.TotalSize(); }

Member Data Documentation

◆ Layout

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
constexpr int Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Layout
staticconstexpr

Definition at line 74 of file TensorMap.h.

◆ m_data

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
StoragePointerType Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::m_data
private

Definition at line 205 of file TensorMap.h.

◆ m_dimensions

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
Dimensions Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::m_dimensions
private

Definition at line 206 of file TensorMap.h.

◆ NumIndices

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
constexpr Index Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::NumIndices
staticconstexpr

Definition at line 71 of file TensorMap.h.

◆ Options

template<typename PlainObjectType , int Options_, template< class > class MakePointer_>
constexpr int Eigen::TensorMap< PlainObjectType, Options_, MakePointer_ >::Options
staticconstexpr

Definition at line 69 of file TensorMap.h.


The documentation for this class was generated from the following files: