Eigen::TensorRef< PlainObjectType > Class Template Reference

A reference to a tensor expression The expression will be evaluated lazily (as much as possible). More...

+ Inheritance diagram for Eigen::TensorRef< PlainObjectType >:

Public Types

enum  {
  IsAligned ,
  PacketAccess ,
  BlockAccess ,
  PreferBlockAccess ,
  CoordAccess ,
  RawAccess
}
 
typedef PlainObjectType::Base Base
 
typedef Base::CoeffReturnType CoeffReturnType
 
typedef PlainObjectType::Dimensions Dimensions
 
typedef internal::traits< PlainObjectType >::Index Index
 
typedef Eigen::internal::nested< Self >::type Nested
 
typedef PointerType PointerArgType
 
typedef ScalarPointerType
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::traits< PlainObjectType >::Scalar Scalar
 
typedef TensorRef< PlainObjectType > Self
 
typedef internal::traits< PlainObjectType >::StorageKind StorageKind
 
typedef internal::TensorBlockNotImplemented TensorBlock
 

Public Member Functions

template<std::size_t NumIndices>
const Scalar coeff (const array< Index, NumIndices > &indices) const
 
const Scalar coeff (Index index) const
 
template<std::size_t NumIndices>
ScalarcoeffRef (const array< Index, NumIndices > &indices)
 
template<typename... IndexTypes>
ScalarcoeffRef (Index firstIndex, IndexTypes... otherIndices)
 
ScalarcoeffRef (Index index)
 
const Scalardata () const
 
Index dimension (Index n) const
 
const Dimensionsdimensions () const
 
template<typename... IndexTypes>
const Scalar operator() (Index firstIndex, IndexTypes... otherIndices) const
 
const Scalar operator() (Index index) const
 
template<typename Expression >
TensorRefoperator= (const Expression &expr)
 
TensorRefoperator= (const TensorRef &other)
 
Index rank () const
 
Index size () const
 
 TensorRef ()
 
template<typename Expression >
 TensorRef (const Expression &expr)
 
 TensorRef (const TensorRef &other)
 
 ~TensorRef ()
 

Static Public Attributes

static constexpr int Layout
 
static constexpr Index NumIndices
 

Private Member Functions

void unrefEvaluator ()
 

Private Attributes

internal::TensorLazyBaseEvaluator< Dimensions, Scalar > * m_evaluator
 

Detailed Description

template<typename PlainObjectType>
class Eigen::TensorRef< PlainObjectType >

A reference to a tensor expression The expression will be evaluated lazily (as much as possible).

Definition at line 126 of file TensorRef.h.

Member Typedef Documentation

◆ Base

template<typename PlainObjectType >
typedef PlainObjectType::Base Eigen::TensorRef< PlainObjectType >::Base

Definition at line 130 of file TensorRef.h.

◆ CoeffReturnType

template<typename PlainObjectType >
typedef Base::CoeffReturnType Eigen::TensorRef< PlainObjectType >::CoeffReturnType

Definition at line 136 of file TensorRef.h.

◆ Dimensions

template<typename PlainObjectType >
typedef PlainObjectType::Dimensions Eigen::TensorRef< PlainObjectType >::Dimensions

Definition at line 141 of file TensorRef.h.

◆ Index

template<typename PlainObjectType >
typedef internal::traits<PlainObjectType>::Index Eigen::TensorRef< PlainObjectType >::Index

Definition at line 133 of file TensorRef.h.

◆ Nested

template<typename PlainObjectType >
typedef Eigen::internal::nested<Self>::type Eigen::TensorRef< PlainObjectType >::Nested

Definition at line 131 of file TensorRef.h.

◆ PointerArgType

template<typename PlainObjectType >
typedef PointerType Eigen::TensorRef< PlainObjectType >::PointerArgType

Definition at line 138 of file TensorRef.h.

◆ PointerType

template<typename PlainObjectType >
typedef Scalar* Eigen::TensorRef< PlainObjectType >::PointerType

Definition at line 137 of file TensorRef.h.

◆ RealScalar

template<typename PlainObjectType >
typedef NumTraits<Scalar>::Real Eigen::TensorRef< PlainObjectType >::RealScalar

Definition at line 135 of file TensorRef.h.

◆ Scalar

template<typename PlainObjectType >
typedef internal::traits<PlainObjectType>::Scalar Eigen::TensorRef< PlainObjectType >::Scalar

Definition at line 134 of file TensorRef.h.

◆ Self

template<typename PlainObjectType >
typedef TensorRef<PlainObjectType> Eigen::TensorRef< PlainObjectType >::Self

Definition at line 129 of file TensorRef.h.

◆ StorageKind

template<typename PlainObjectType >
typedef internal::traits<PlainObjectType>::StorageKind Eigen::TensorRef< PlainObjectType >::StorageKind

Definition at line 132 of file TensorRef.h.

◆ TensorBlock

template<typename PlainObjectType >
typedef internal::TensorBlockNotImplemented Eigen::TensorRef< PlainObjectType >::TensorBlock

Definition at line 154 of file TensorRef.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename PlainObjectType >
anonymous enum
Enumerator
IsAligned 
PacketAccess 
BlockAccess 
PreferBlockAccess 
CoordAccess 
RawAccess 

Definition at line 144 of file TensorRef.h.

144  {
145  IsAligned = false,
146  PacketAccess = false,
147  BlockAccess = false,
148  PreferBlockAccess = false,
149  CoordAccess = false, // to be implemented
150  RawAccess = false
151  };

Constructor & Destructor Documentation

◆ TensorRef() [1/3]

template<typename PlainObjectType >
Eigen::TensorRef< PlainObjectType >::TensorRef ( )
inline

Definition at line 157 of file TensorRef.h.

157  : m_evaluator(NULL) {
158  }
internal::TensorLazyBaseEvaluator< Dimensions, Scalar > * m_evaluator
Definition: TensorRef.h:283

◆ TensorRef() [2/3]

template<typename PlainObjectType >
template<typename Expression >
Eigen::TensorRef< PlainObjectType >::TensorRef ( const Expression &  expr)
inline

Definition at line 161 of file TensorRef.h.

161  : m_evaluator(new internal::TensorLazyEvaluator<Dimensions, Expression, DefaultDevice>(expr, DefaultDevice())) {
162  m_evaluator->incrRefCount();
163  }

◆ ~TensorRef()

template<typename PlainObjectType >
Eigen::TensorRef< PlainObjectType >::~TensorRef ( )
inline

Definition at line 173 of file TensorRef.h.

173  {
174  unrefEvaluator();
175  }
void unrefEvaluator()
Definition: TensorRef.h:274

◆ TensorRef() [3/3]

template<typename PlainObjectType >
Eigen::TensorRef< PlainObjectType >::TensorRef ( const TensorRef< PlainObjectType > &  other)
inline

Definition at line 177 of file TensorRef.h.

177  : TensorBase<TensorRef<PlainObjectType> >(other), m_evaluator(other.m_evaluator) {
178  eigen_assert(m_evaluator->refCount() > 0);
179  m_evaluator->incrRefCount();
180  }
#define eigen_assert(x)

Member Function Documentation

◆ coeff() [1/2]

template<typename PlainObjectType >
template<std::size_t NumIndices>
const Scalar Eigen::TensorRef< PlainObjectType >::coeff ( const array< Index, NumIndices > &  indices) const
inline

Definition at line 225 of file TensorRef.h.

226  {
227  const Dimensions& dims = this->dimensions();
228  Index index = 0;
229  if (PlainObjectType::Options & RowMajor) {
230  index += indices[0];
231  for (size_t i = 1; i < NumIndices; ++i) {
232  index = index * dims[i] + indices[i];
233  }
234  } else {
235  index += indices[NumIndices-1];
236  for (int i = NumIndices-2; i >= 0; --i) {
237  index = index * dims[i] + indices[i];
238  }
239  }
240  return m_evaluator->coeff(index);
241  }
int i
PlainObjectType::Dimensions Dimensions
Definition: TensorRef.h:141
static constexpr Index NumIndices
Definition: TensorRef.h:140
const Dimensions & dimensions() const
Definition: TensorRef.h:197
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index

◆ coeff() [2/2]

template<typename PlainObjectType >
const Scalar Eigen::TensorRef< PlainObjectType >::coeff ( Index  index) const
inline

Definition at line 262 of file TensorRef.h.

263  {
264  return m_evaluator->coeff(index);
265  }

◆ coeffRef() [1/3]

template<typename PlainObjectType >
template<std::size_t NumIndices>
Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( const array< Index, NumIndices > &  indices)
inline

Definition at line 243 of file TensorRef.h.

244  {
245  const Dimensions& dims = this->dimensions();
246  Index index = 0;
247  if (PlainObjectType::Options & RowMajor) {
248  index += indices[0];
249  for (size_t i = 1; i < NumIndices; ++i) {
250  index = index * dims[i] + indices[i];
251  }
252  } else {
253  index += indices[NumIndices-1];
254  for (int i = NumIndices-2; i >= 0; --i) {
255  index = index * dims[i] + indices[i];
256  }
257  }
258  return m_evaluator->coeffRef(index);
259  }

◆ coeffRef() [2/3]

template<typename PlainObjectType >
template<typename... IndexTypes>
Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( Index  firstIndex,
IndexTypes...  otherIndices 
)
inline

Definition at line 217 of file TensorRef.h.

218  {
219  const std::size_t num_indices = (sizeof...(otherIndices) + 1);
220  const array<Index, num_indices> indices{{firstIndex, otherIndices...}};
221  return coeffRef(indices);
222  }
Scalar & coeffRef(Index firstIndex, IndexTypes... otherIndices)
Definition: TensorRef.h:217
std::array< T, N > array

◆ coeffRef() [3/3]

template<typename PlainObjectType >
Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( Index  index)
inline

Definition at line 268 of file TensorRef.h.

269  {
270  return m_evaluator->coeffRef(index);
271  }

◆ data()

template<typename PlainObjectType >
const Scalar* Eigen::TensorRef< PlainObjectType >::data ( ) const
inline

Definition at line 201 of file TensorRef.h.

201 { return m_evaluator->data(); }

◆ dimension()

template<typename PlainObjectType >
Index Eigen::TensorRef< PlainObjectType >::dimension ( Index  n) const
inline

Definition at line 195 of file TensorRef.h.

195 { return m_evaluator->dimensions()[n]; }
int n

◆ dimensions()

template<typename PlainObjectType >
const Dimensions& Eigen::TensorRef< PlainObjectType >::dimensions ( ) const
inline

Definition at line 197 of file TensorRef.h.

197 { return m_evaluator->dimensions(); }

◆ operator()() [1/2]

template<typename PlainObjectType >
template<typename... IndexTypes>
const Scalar Eigen::TensorRef< PlainObjectType >::operator() ( Index  firstIndex,
IndexTypes...  otherIndices 
) const
inline

Definition at line 210 of file TensorRef.h.

211  {
212  const std::size_t num_indices = (sizeof...(otherIndices) + 1);
213  const array<Index, num_indices> indices{{firstIndex, otherIndices...}};
214  return coeff(indices);
215  }
const Scalar coeff(const array< Index, NumIndices > &indices) const
Definition: TensorRef.h:225

◆ operator()() [2/2]

template<typename PlainObjectType >
const Scalar Eigen::TensorRef< PlainObjectType >::operator() ( Index  index) const
inline

Definition at line 204 of file TensorRef.h.

205  {
206  return m_evaluator->coeff(index);
207  }

◆ operator=() [1/2]

template<typename PlainObjectType >
template<typename Expression >
TensorRef& Eigen::TensorRef< PlainObjectType >::operator= ( const Expression &  expr)
inline

Definition at line 166 of file TensorRef.h.

166  {
167  unrefEvaluator();
168  m_evaluator = new internal::TensorLazyEvaluator<Dimensions, Expression, DefaultDevice>(expr, DefaultDevice());
169  m_evaluator->incrRefCount();
170  return *this;
171  }

◆ operator=() [2/2]

template<typename PlainObjectType >
TensorRef& Eigen::TensorRef< PlainObjectType >::operator= ( const TensorRef< PlainObjectType > &  other)
inline

Definition at line 182 of file TensorRef.h.

182  {
183  if (this != &other) {
184  unrefEvaluator();
185  m_evaluator = other.m_evaluator;
186  eigen_assert(m_evaluator->refCount() > 0);
187  m_evaluator->incrRefCount();
188  }
189  return *this;
190  }

◆ rank()

template<typename PlainObjectType >
Index Eigen::TensorRef< PlainObjectType >::rank ( ) const
inline

Definition at line 193 of file TensorRef.h.

193 { return m_evaluator->dimensions().size(); }

◆ size()

template<typename PlainObjectType >
Index Eigen::TensorRef< PlainObjectType >::size ( ) const
inline

Definition at line 199 of file TensorRef.h.

199 { return m_evaluator->dimensions().TotalSize(); }

◆ unrefEvaluator()

template<typename PlainObjectType >
void Eigen::TensorRef< PlainObjectType >::unrefEvaluator ( )
inlineprivate

Definition at line 274 of file TensorRef.h.

274  {
275  if (m_evaluator) {
276  m_evaluator->decrRefCount();
277  if (m_evaluator->refCount() == 0) {
278  delete m_evaluator;
279  }
280  }
281  }

Member Data Documentation

◆ Layout

template<typename PlainObjectType >
constexpr int Eigen::TensorRef< PlainObjectType >::Layout
staticconstexpr

Definition at line 143 of file TensorRef.h.

◆ m_evaluator

template<typename PlainObjectType >
internal::TensorLazyBaseEvaluator<Dimensions, Scalar>* Eigen::TensorRef< PlainObjectType >::m_evaluator
private

Definition at line 283 of file TensorRef.h.

◆ NumIndices

template<typename PlainObjectType >
constexpr Index Eigen::TensorRef< PlainObjectType >::NumIndices
staticconstexpr

Definition at line 140 of file TensorRef.h.


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