Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ > Class Template Reference

The tensor class. More...

+ Inheritance diagram for Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >:

Classes

struct  isOfNormalIndex
 

Public Types

enum  {
  IsAligned ,
  CoordAccess ,
  RawAccess
}
 
typedef TensorBase< Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > Base
 
typedef Base::CoeffReturnType CoeffReturnType
 
typedef DSizes< Index, NumIndices_ > Dimensions
 
typedef internal::traits< Self >::Index Index
 
typedef Eigen::internal::nested< Self >::type Nested
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Scalar_ Scalar
 
typedef Tensor< Scalar_, NumIndices_, Options_, IndexType_ > Self
 
typedef internal::traits< Self >::StorageKind StorageKind
 

Public Member Functions

Selfbase ()
 
const Selfbase () const
 
const Scalarcoeff () const
 
const Scalarcoeff (const array< Index, NumIndices > &indices) const
 
template<typename CustomIndices >
const Scalarcoeff (CustomIndices &indices) const
 
template<typename... IndexTypes>
const Scalarcoeff (Index firstIndex, Index secondIndex, IndexTypes... otherIndices) const
 
const Scalarcoeff (Index index) const
 
ScalarcoeffRef ()
 
ScalarcoeffRef (const array< Index, NumIndices > &indices)
 
template<typename CustomIndices >
ScalarcoeffRef (CustomIndices &indices)
 
template<typename... IndexTypes>
ScalarcoeffRef (Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
 
ScalarcoeffRef (Index index)
 
Scalardata ()
 
const Scalardata () const
 
Index dimension (std::size_t n) const
 
const Dimensionsdimensions () const
 
Scalaroperator() ()
 
const Scalaroperator() () const
 
Scalaroperator() (const array< Index, NumIndices > &indices)
 
const Scalaroperator() (const array< Index, NumIndices > &indices) const
 
template<typename CustomIndices >
Scalaroperator() (CustomIndices &indices)
 
template<typename CustomIndices >
const Scalaroperator() (CustomIndices &indices) const
 
template<typename... IndexTypes>
Scalaroperator() (Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
 
template<typename... IndexTypes>
const Scalaroperator() (Index firstIndex, Index secondIndex, IndexTypes... otherIndices) const
 
Scalaroperator() (Index index)
 
const Scalaroperator() (Index index) const
 
template<typename OtherDerived >
Tensoroperator= (const OtherDerived &other)
 
Tensoroperator= (const Tensor &other)
 
Tensoroperator= (Self &&other)
 
Scalaroperator[] (Index index)
 
const Scalaroperator[] (Index index) const
 
Index rank () const
 
void resize ()
 
void resize (const array< Index, NumIndices > &dimensions)
 
void resize (const DSizes< Index, NumIndices > &dimensions)
 
template<typename FirstType , typename... OtherTypes>
void resize (const Eigen::IndexList< FirstType, OtherTypes... > &dimensions)
 
template<typename std::ptrdiff_t... Indices>
void resize (const Sizes< Indices... > &dimensions)
 
template<typename CustomDimension >
void resize (CustomDimension &dimensions)
 
template<typename... IndexTypes>
void resize (Index firstDimension, IndexTypes... otherDimensions)
 
Index size () const
 
 Tensor ()
 
 Tensor (const array< Index, NumIndices > &dimensions)
 
 Tensor (const Self &other)
 
template<typename OtherDerived >
 Tensor (const TensorBase< OtherDerived, ReadOnlyAccessors > &other)
 
template<typename OtherDerived >
 Tensor (const TensorBase< OtherDerived, WriteAccessors > &other)
 
template<typename... IndexTypes>
 Tensor (Index firstDimension, IndexTypes... otherDimensions)
 
 Tensor (Self &&other)
 

Static Public Attributes

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

Protected Member Functions

bool checkIndexRange (const array< Index, NumIndices > &indices) const
 
Index linearizedIndex (const array< Index, NumIndices > &indices) const
 

Protected Attributes

TensorStorage< Scalar, Dimensions, Optionsm_storage
 

Detailed Description

template<typename Scalar_, int NumIndices_, int Options_, typename IndexType_>
class Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >

The tensor class.

The Tensor class is the work-horse for all dense tensors within Eigen.

The Tensor class encompasses only dynamic-size objects so far.

The first two template parameters are required:

Template Parameters
Scalar_Numeric type, e.g. float, double, int or std::complex<float>. User defined scalar types are supported as well (see here).
NumIndices_Number of indices (i.e. rank of the tensor)

The remaining template parameters are optional – in most cases you don't have to worry about them.

Template Parameters
Options_A combination of either RowMajor or ColMajor, and of either AutoAlign or DontAlign. The former controls storage order, and defaults to column-major. The latter controls alignment, which is required for vectorization. It defaults to aligning tensors. Note that tensors currently do not support any operations that profit from vectorization. Support for such operations (i.e. adding two tensors etc.) is planned.

You can access elements of tensors using normal subscripting:

Eigen::Tensor<double, 4> t(10, 10, 10, 10);
t(0, 1, 2, 3) = 42.0;
The tensor class.
Definition: Tensor.h:67

This class can be extended with the help of the plugin mechanism described on the page Extending MatrixBase (and other classes) by defining the preprocessor symbol EIGEN_TENSOR_PLUGIN, EIGEN_TENSORBASE_PLUGIN, and EIGEN_READONLY_TENSORBASE_PLUGIN.

Some notes:

Relation to other parts of Eigen:
The midterm development goal for this class is to have a similar hierarchy as Eigen uses for matrices, so that taking blocks or using tensors in expressions is easily possible, including an interface with the vector/matrix code by providing .asMatrix() and .asVector() (or similar) methods for rank 2 and 1 tensors. However, currently, the Tensor class does not provide any of these features and is only available as a stand-alone class that just allows for coefficient access. Also, when fixed-size tensors are implemented, the number of template arguments is likely to change dramatically.

Storage orders

Definition at line 66 of file Tensor.h.

Member Typedef Documentation

◆ Base

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Base

Definition at line 70 of file Tensor.h.

◆ CoeffReturnType

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef Base::CoeffReturnType Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::CoeffReturnType

Definition at line 76 of file Tensor.h.

◆ Dimensions

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef DSizes<Index, NumIndices_> Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Dimensions

Definition at line 87 of file Tensor.h.

◆ Index

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef internal::traits<Self>::Index Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Index

Definition at line 73 of file Tensor.h.

◆ Nested

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef Eigen::internal::nested<Self>::type Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Nested

Definition at line 71 of file Tensor.h.

◆ RealScalar

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef NumTraits<Scalar>::Real Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::RealScalar

Definition at line 75 of file Tensor.h.

◆ Scalar

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef Scalar_ Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Scalar

Definition at line 74 of file Tensor.h.

◆ Self

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef Tensor<Scalar_, NumIndices_, Options_, IndexType_> Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Self

Definition at line 69 of file Tensor.h.

◆ StorageKind

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
typedef internal::traits<Self>::StorageKind Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::StorageKind

Definition at line 72 of file Tensor.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
anonymous enum
Enumerator
IsAligned 
CoordAccess 
RawAccess 

Definition at line 78 of file Tensor.h.

78  {
79  IsAligned = (EIGEN_MAX_ALIGN_BYTES>0) && !(Options_&DontAlign),
80  CoordAccess = true,
81  RawAccess = true
82  };
#define EIGEN_MAX_ALIGN_BYTES
@ CoordAccess
Definition: Tensor.h:80

Constructor & Destructor Documentation

◆ Tensor() [1/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( )
inline

Definition at line 271 of file Tensor.h.

272  : m_storage()
273  {
274  }
TensorStorage< Scalar, Dimensions, Options > m_storage
Definition: Tensor.h:90

◆ Tensor() [2/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( const Self other)
inline

Definition at line 277 of file Tensor.h.

278  : Base(other), m_storage(other.m_storage)
279  {
280  }
TensorBase< Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > Base
Definition: Tensor.h:70

◆ Tensor() [3/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( Index  firstDimension,
IndexTypes...  otherDimensions 
)
inline

Definition at line 283 of file Tensor.h.

284  : m_storage(firstDimension, otherDimensions...)
285  {
286  // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
287  EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
288  }
#define EIGEN_STATIC_ASSERT(X, MSG)
static constexpr int NumIndices
Definition: Tensor.h:86

◆ Tensor() [4/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( const array< Index, NumIndices > &  dimensions)
inlineexplicit

Normal Dimension

Definition at line 291 of file Tensor.h.

293  {
295  }
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
const Dimensions & dimensions() const
Definition: Tensor.h:103
constexpr auto array_prod(const array< T, N > &arr) -> decltype(array_reduce< product_op, T, N >(arr, static_cast< T >(1)))

◆ Tensor() [5/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename OtherDerived >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( const TensorBase< OtherDerived, ReadOnlyAccessors > &  other)
inline

Definition at line 299 of file Tensor.h.

300  {
301  typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
302  Assign assign(*this, other.derived());
303  resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
304  internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
305  }
void resize()
Definition: Tensor.h:385

◆ Tensor() [6/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename OtherDerived >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( const TensorBase< OtherDerived, WriteAccessors > &  other)
inline

Definition at line 309 of file Tensor.h.

310  {
311  typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
312  Assign assign(*this, other.derived());
313  resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
314  internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
315  }

◆ Tensor() [7/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Tensor ( Self &&  other)
inline

Definition at line 318 of file Tensor.h.

319  : m_storage(std::move(other.m_storage))
320  {
321  }

Member Function Documentation

◆ base() [1/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Self& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::base ( )
inline

Definition at line 111 of file Tensor.h.

111 { return *this; }

◆ base() [2/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Self& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::base ( ) const
inline

Definition at line 112 of file Tensor.h.

112 { return *this; }

◆ checkIndexRange()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
bool Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::checkIndexRange ( const array< Index, NumIndices > &  indices) const
inlineprotected

Definition at line 438 of file Tensor.h.

439  {
442  using internal::greater_equal_zero_op;
443  using internal::logical_and_op;
444  using internal::lesser_op;
445 
446  return
447  // check whether the indices are all >= 0
448  array_apply_and_reduce<logical_and_op, greater_equal_zero_op>(indices) &&
449  // check whether the indices fit in the dimensions
450  array_zip_and_reduce<logical_and_op, lesser_op>(indices, m_storage.dimensions());
451  }
const FixedDimensions dimensions() const
Definition: TensorStorage.h:61
constexpr auto array_apply_and_reduce(array< A, N > a) -> decltype(h_array_apply_and_reduce< Reducer, Op, A, N >(a, typename gen_numeric_list< int, N >::type()))
constexpr auto array_zip_and_reduce(array< A, N > a, array< B, N > b) -> decltype(h_array_zip_and_reduce< Reducer, Op, A, B, N >(a, b, typename gen_numeric_list< int, N >::type()))

◆ coeff() [1/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeff ( ) const
inline

Definition at line 138 of file Tensor.h.

139  {
140  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
141  return m_storage.data()[0];
142  }

◆ coeff() [2/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeff ( const array< Index, NumIndices > &  indices) const
inline

Definition at line 123 of file Tensor.h.

124  {
126  return m_storage.data()[linearizedIndex(indices)];
127  }
#define eigen_internal_assert(x)
bool checkIndexRange(const array< Index, NumIndices > &indices) const
Definition: Tensor.h:438
Index linearizedIndex(const array< Index, NumIndices > &indices) const
Definition: Tensor.h:453

◆ coeff() [3/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename CustomIndices >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeff ( CustomIndices &  indices) const
inline

Definition at line 133 of file Tensor.h.

134  {
135  return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
136  }
const Scalar & coeff() const
Definition: Tensor.h:138

◆ coeff() [4/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeff ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
) const
inline

Definition at line 115 of file Tensor.h.

116  {
117  // The number of indices used to access a tensor coefficient must be equal to the rank of the tensor.
118  EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
119  return coeff(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
120  }
std::array< T, N > array

◆ coeff() [5/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeff ( Index  index) const
inline

Definition at line 144 of file Tensor.h.

145  {
146  eigen_internal_assert(index >= 0 && index < size());
147  return m_storage.data()[index];
148  }
Index size() const
Definition: Tensor.h:104

◆ coeffRef() [1/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeffRef ( )
inline

Definition at line 174 of file Tensor.h.

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

◆ coeffRef() [2/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeffRef ( const array< Index, NumIndices > &  indices)
inline

Definition at line 159 of file Tensor.h.

160  {
162  return m_storage.data()[linearizedIndex(indices)];
163  }

◆ coeffRef() [3/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename CustomIndices >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeffRef ( CustomIndices &  indices)
inline

Definition at line 169 of file Tensor.h.

170  {
171  return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
172  }
Scalar & coeffRef()
Definition: Tensor.h:174

◆ coeffRef() [4/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeffRef ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
)
inline

Definition at line 151 of file Tensor.h.

152  {
153  // The number of indices used to access a tensor coefficient must be equal to the rank of the tensor.
154  EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
155  return coeffRef(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
156  }

◆ coeffRef() [5/5]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::coeffRef ( Index  index)
inline

Definition at line 180 of file Tensor.h.

181  {
182  eigen_internal_assert(index >= 0 && index < size());
183  return m_storage.data()[index];
184  }

◆ data() [1/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar* Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::data ( )
inline

Definition at line 105 of file Tensor.h.

105 { return m_storage.data(); }

◆ data() [2/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar* Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::data ( ) const
inline

Definition at line 106 of file Tensor.h.

106 { return m_storage.data(); }

◆ dimension()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Index Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::dimension ( std::size_t  n) const
inline

Definition at line 102 of file Tensor.h.

102 { return m_storage.dimensions()[n]; }
int n

◆ dimensions()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Dimensions& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::dimensions ( ) const
inline

Definition at line 103 of file Tensor.h.

103 { return m_storage.dimensions(); }

◆ linearizedIndex()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Index Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::linearizedIndex ( const array< Index, NumIndices > &  indices) const
inlineprotected

Definition at line 453 of file Tensor.h.

454  {
455  if (Options&RowMajor) {
456  return m_storage.dimensions().IndexOfRowMajor(indices);
457  } else {
458  return m_storage.dimensions().IndexOfColMajor(indices);
459  }
460  }
static constexpr int Options
Definition: Tensor.h:85
DenseIndex IndexOfRowMajor(const array< DenseIndex, NumDims > &indices) const
DenseIndex IndexOfColMajor(const array< DenseIndex, NumDims > &indices) const

◆ operator()() [1/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( )
inline

Definition at line 257 of file Tensor.h.

258  {
259  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
260  return coeffRef();
261  }

◆ operator()() [2/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( ) const
inline

Definition at line 215 of file Tensor.h.

216  {
217  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
218  return coeff();
219  }

◆ operator()() [3/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( const array< Index, NumIndices > &  indices)
inline

Definition at line 237 of file Tensor.h.

238  {
239  return coeffRef(indices);
240  }

◆ operator()() [4/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( const array< Index, NumIndices > &  indices) const
inline

Definition at line 204 of file Tensor.h.

205  {
206  return coeff(indices);
207  }

◆ operator()() [5/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename CustomIndices >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( CustomIndices &  indices)
inline

Definition at line 246 of file Tensor.h.

247  {
248  return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
249  }

◆ operator()() [6/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename CustomIndices >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( CustomIndices &  indices) const
inline

Definition at line 198 of file Tensor.h.

199  {
200  return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
201  }

◆ operator()() [7/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
)
inline

Definition at line 229 of file Tensor.h.

230  {
231  // The number of indices used to access a tensor coefficient must be equal to the rank of the tensor.
232  EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
233  return operator()(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
234  }
const Scalar & operator()() const
Definition: Tensor.h:215

◆ operator()() [8/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( Index  firstIndex,
Index  secondIndex,
IndexTypes...  otherIndices 
) const
inline

Definition at line 187 of file Tensor.h.

188  {
189  // The number of indices used to access a tensor coefficient must be equal to the rank of the tensor.
190  EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
191  return this->operator()(array<Index, NumIndices>{{firstIndex, secondIndex, otherIndices...}});
192  }

◆ operator()() [9/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( Index  index)
inline

Definition at line 251 of file Tensor.h.

252  {
253  eigen_assert(index >= 0 && index < size());
254  return coeffRef(index);
255  }
#define eigen_assert(x)

◆ operator()() [10/10]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator() ( Index  index) const
inline

Definition at line 209 of file Tensor.h.

210  {
211  eigen_internal_assert(index >= 0 && index < size());
212  return coeff(index);
213  }

◆ operator=() [1/3]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename OtherDerived >
Tensor& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator= ( const OtherDerived &  other)
inline

Definition at line 340 of file Tensor.h.

341  {
342  typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
343  Assign assign(*this, other);
344  resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
345  internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
346  return *this;
347  }

◆ operator=() [2/3]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Tensor& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator= ( const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > &  other)
inline

Definition at line 330 of file Tensor.h.

331  {
332  typedef TensorAssignOp<Tensor, const Tensor> Assign;
333  Assign assign(*this, other);
334  resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
335  internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
336  return *this;
337  }

◆ operator=() [3/3]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Tensor& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator= ( Self &&  other)
inline

Definition at line 323 of file Tensor.h.

324  {
325  m_storage = std::move(other.m_storage);
326  return *this;
327  }

◆ operator[]() [1/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator[] ( Index  index)
inline

Definition at line 263 of file Tensor.h.

264  {
265  // The bracket operator is only for vectors, use the parenthesis operator instead
266  EIGEN_STATIC_ASSERT(NumIndices == 1, YOU_MADE_A_PROGRAMMING_MISTAKE)
267  return coeffRef(index);
268  }

◆ operator[]() [2/2]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
const Scalar& Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::operator[] ( Index  index) const
inline

Definition at line 221 of file Tensor.h.

222  {
223  // The bracket operator is only for vectors, use the parenthesis operator instead.
224  EIGEN_STATIC_ASSERT(NumIndices == 1, YOU_MADE_A_PROGRAMMING_MISTAKE);
225  return coeff(index);
226  }

◆ rank()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Index Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::rank ( ) const
inline

Definition at line 101 of file Tensor.h.

101 { return NumIndices; }

◆ resize() [1/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( )
inline

Definition at line 385 of file Tensor.h.

386  {
387  EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
388  // Nothing to do: rank 0 tensors have fixed size
389  }

◆ resize() [2/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( const array< Index, NumIndices > &  dimensions)
inline

Normal Dimension

Definition at line 358 of file Tensor.h.

359  {
360  int i;
361  Index size = Index(1);
362  for (i = 0; i < NumIndices; i++) {
363  internal::check_rows_cols_for_overflow<Dynamic, Dynamic, Dynamic>::run(size, dimensions[i]);
364  size *= dimensions[i];
365  }
366  #ifdef EIGEN_INITIALIZE_COEFFS
367  bool size_changed = size != this->size();
368  m_storage.resize(size, dimensions);
370  #else
371  m_storage.resize(size, dimensions);
372  #endif
373  }
int i
internal::traits< Self >::Index Index
Definition: Tensor.h:73
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index

◆ resize() [3/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( const DSizes< Index, NumIndices > &  dimensions)
inline

Definition at line 376 of file Tensor.h.

376  {
378  for (int i = 0; i < NumIndices; ++i) {
379  dims[i] = dimensions[i];
380  }
381  resize(dims);
382  }

◆ resize() [4/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename FirstType , typename... OtherTypes>
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( const Eigen::IndexList< FirstType, OtherTypes... > &  dimensions)
inline

Definition at line 393 of file Tensor.h.

393  {
395  for (int i = 0; i < NumIndices; ++i) {
396  dims[i] = static_cast<Index>(dimensions[i]);
397  }
398  resize(dims);
399  }

◆ resize() [5/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename std::ptrdiff_t... Indices>
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( const Sizes< Indices... > &  dimensions)
inline

Definition at line 413 of file Tensor.h.

413  {
415  for (int i = 0; i < NumIndices; ++i) {
416  dims[i] = static_cast<Index>(dimensions[i]);
417  }
418  resize(dims);
419  }

◆ resize() [6/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename CustomDimension >
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( CustomDimension &  dimensions)
inline

Custom Dimension

Definition at line 405 of file Tensor.h.

406  {
407  resize(internal::customIndices2Array<Index,NumIndices>(dimensions));
408  }

◆ resize() [7/7]

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
template<typename... IndexTypes>
void Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::resize ( Index  firstDimension,
IndexTypes...  otherDimensions 
)
inline

Definition at line 350 of file Tensor.h.

351  {
352  // The number of dimensions used to resize a tensor must be equal to the rank of the tensor.
353  EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
354  resize(array<Index, NumIndices>{{firstDimension, otherDimensions...}});
355  }

◆ size()

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
Index Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::size ( ) const
inline

Definition at line 104 of file Tensor.h.

104 { return m_storage.size(); }
DenseIndex size() const
Definition: TensorStorage.h:64

Member Data Documentation

◆ Layout

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
constexpr int Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Layout
staticconstexpr

Definition at line 84 of file Tensor.h.

◆ m_storage

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
TensorStorage<Scalar, Dimensions, Options> Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::m_storage
protected

Definition at line 90 of file Tensor.h.

◆ NumIndices

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
constexpr int Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::NumIndices
staticconstexpr

Definition at line 86 of file Tensor.h.

◆ Options

template<typename Scalar_ , int NumIndices_, int Options_, typename IndexType_ >
constexpr int Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::Options
staticconstexpr

Definition at line 85 of file Tensor.h.


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