Eigen::TensorRef< PlainObjectType > Class Template Reference

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

#include <TensorRef.h>

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

Public Types

enum  {
  IsAligned = false , PacketAccess = false , BlockAccess = false , PreferBlockAccess = false ,
  CoordAccess = false , RawAccess = false
}
 
typedef TensorRef< PlainObjectType > Self
 
typedef PlainObjectType::Base Base
 
typedef Eigen::internal::nested< Self >::type Nested
 
typedef internal::traits< PlainObjectType >::StorageKind StorageKind
 
typedef internal::traits< PlainObjectType >::Index Index
 
typedef internal::traits< PlainObjectType >::Scalar Scalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Base::CoeffReturnType CoeffReturnType
 
typedef ScalarPointerType
 
typedef PointerType PointerArgType
 
typedef PlainObjectType::Dimensions Dimensions
 
typedef internal::TensorBlockNotImplemented TensorBlock
 
- Public Types inherited from Eigen::TensorBase< TensorRef< PlainObjectType > >
typedef TensorBase< TensorRef< PlainObjectType >, ReadOnlyAccessors > Base
 
typedef internal::traits< TensorRef< PlainObjectType > > DerivedTraits
 
typedef DerivedTraits::Scalar Scalar
 
typedef DerivedTraits::Index Index
 
typedef Scalar CoeffReturnType
 

Public Member Functions

EIGEN_STRONG_INLINE TensorRef ()
 
template<typename Expression >
EIGEN_STRONG_INLINE TensorRef (const Expression &expr)
 
template<typename Expression >
EIGEN_STRONG_INLINE TensorRefoperator= (const Expression &expr)
 
 ~TensorRef ()
 
 TensorRef (const TensorRef &other)
 
TensorRefoperator= (const TensorRef &other)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank () const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension (Index n) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensionsdimensions () const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size () const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalardata () const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index index) const
 
template<typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index firstIndex, IndexTypes... otherIndices) const
 
template<typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarcoeffRef (Index firstIndex, IndexTypes... otherIndices)
 
template<std::size_t NumIndices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff (const array< Index, NumIndices > &indices) const
 
template<std::size_t NumIndices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarcoeffRef (const array< Index, NumIndices > &indices)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff (Index index) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarcoeffRef (Index index)
 
- Public Member Functions inherited from Eigen::TensorBase< TensorRef< PlainObjectType > >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & setZero ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & setConstant (const Scalar &val)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & setRandom ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & setRandom ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & setValues (const typename internal::Initializer< TensorRef< PlainObjectType >, NumDimensions >::InitList &vals)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & operator+= (const OtherDerived &other)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & operator-= (const OtherDerived &other)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & operator*= (const OtherDerived &other)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & operator/= (const OtherDerived &other)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorLayoutSwapOp< const TensorRef< PlainObjectType > > swap_layout () const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorLayoutSwapOp< TensorRef< PlainObjectType > > swap_layout ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorConcatenationOp< const Axis, const TensorRef< PlainObjectType >, const OtherDerived > concatenate (const OtherDerived &other, const Axis &axis) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorConcatenationOp< const Axis, TensorRef< PlainObjectType >, OtherDerived > concatenate (const OtherDerived &other, const Axis &axis)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorReshapingOp< const NewDimensions, const TensorRef< PlainObjectType > > reshape (const NewDimensions &newDimensions) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorReshapingOp< const NewDimensions, TensorRef< PlainObjectType > > reshape (const NewDimensions &newDimensions)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorSlicingOp< const StartIndices, const Sizes, const TensorRef< PlainObjectType > > slice (const StartIndices &startIndices, const Sizes &sizes) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorSlicingOp< const StartIndices, const Sizes, TensorRef< PlainObjectType > > slice (const StartIndices &startIndices, const Sizes &sizes)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorStridingSlicingOp< const StartIndices, const StopIndices, const Strides, const TensorRef< PlainObjectType > > stridedSlice (const StartIndices &startIndices, const StopIndices &stopIndices, const Strides &strides) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorStridingSlicingOp< const StartIndices, const StopIndices, const Strides, TensorRef< PlainObjectType > > stridedSlice (const StartIndices &startIndices, const StopIndices &stopIndices, const Strides &strides)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorChippingOp< DimId, const TensorRef< PlainObjectType > > chip (const Index offset) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorChippingOp< DimId, TensorRef< PlainObjectType > > chip (const Index offset)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorChippingOp< Dynamic, const TensorRef< PlainObjectType > > chip (const Index offset, const Index dim) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorChippingOp< Dynamic, TensorRef< PlainObjectType > > chip (const Index offset, const Index dim)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorReverseOp< const ReverseDimensions, const TensorRef< PlainObjectType > > reverse (const ReverseDimensions &rev) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorReverseOp< const ReverseDimensions, TensorRef< PlainObjectType > > reverse (const ReverseDimensions &rev)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorRollOp< const Rolls, const TensorRef< PlainObjectType > > roll (const Rolls &roll) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRollOp< const Rolls, TensorRef< PlainObjectType > > roll (const Rolls &roll)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorShufflingOp< const Shuffle, const TensorRef< PlainObjectType > > shuffle (const Shuffle &shfl) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorShufflingOp< const Shuffle, TensorRef< PlainObjectType > > shuffle (const Shuffle &shfl)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorStridingOp< const Strides, const TensorRef< PlainObjectType > > stride (const Strides &strides) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorStridingOp< const Strides, TensorRef< PlainObjectType > > stride (const Strides &strides)
 
TensorDevice< TensorRef< PlainObjectType >, DeviceType > device (const DeviceType &dev)
 
TensorAsyncDevice< TensorRef< PlainObjectType >, DeviceType, DoneCallback > device (const DeviceType &dev, DoneCallback done)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & derived ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorRef< PlainObjectType > & derived () const
 

Static Public Attributes

static constexpr Index NumIndices = PlainObjectType::NumIndices
 
static constexpr int Layout = PlainObjectType::Layout
 
- Static Public Attributes inherited from Eigen::TensorBase< TensorRef< PlainObjectType > >
static constexpr int NumDimensions
 

Private Member Functions

EIGEN_STRONG_INLINE void unrefEvaluator ()
 

Private Attributes

internal::TensorLazyBaseEvaluator< Dimensions, Scalar > * m_evaluator
 

Additional Inherited Members

- Protected Member Functions inherited from Eigen::TensorBase< TensorRef< PlainObjectType > >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorRef< PlainObjectType > & operator= (const OtherDerived &other)
 

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).

Member Typedef Documentation

◆ Base

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

◆ CoeffReturnType

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

◆ Dimensions

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

◆ Index

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

◆ Nested

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

◆ PointerArgType

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

◆ PointerType

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

◆ RealScalar

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

◆ Scalar

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

◆ Self

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

◆ StorageKind

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

◆ TensorBlock

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

Member Enumeration Documentation

◆ anonymous enum

template<typename PlainObjectType >
anonymous enum
Enumerator
IsAligned 
PacketAccess 
BlockAccess 
PreferBlockAccess 
CoordAccess 
RawAccess 
131  {
132  IsAligned = false,
133  PacketAccess = false,
134  BlockAccess = false,
135  PreferBlockAccess = false,
136  CoordAccess = false, // to be implemented
137  RawAccess = false
138  };
@ PacketAccess
Definition: TensorRef.h:133
@ PreferBlockAccess
Definition: TensorRef.h:135
@ BlockAccess
Definition: TensorRef.h:134
@ IsAligned
Definition: TensorRef.h:132
@ CoordAccess
Definition: TensorRef.h:136
@ RawAccess
Definition: TensorRef.h:137

Constructor & Destructor Documentation

◆ TensorRef() [1/3]

template<typename PlainObjectType >
EIGEN_STRONG_INLINE Eigen::TensorRef< PlainObjectType >::TensorRef ( )
inline
144 : m_evaluator(NULL) {}
internal::TensorLazyBaseEvaluator< Dimensions, Scalar > * m_evaluator
Definition: TensorRef.h:247

◆ TensorRef() [2/3]

template<typename PlainObjectType >
template<typename Expression >
EIGEN_STRONG_INLINE Eigen::TensorRef< PlainObjectType >::TensorRef ( const Expression &  expr)
inline
148  : m_evaluator(new internal::TensorLazyEvaluator<Dimensions, Expression, DefaultDevice>(expr, DefaultDevice())) {
149  m_evaluator->incrRefCount();
150  }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ ~TensorRef()

template<typename PlainObjectType >
Eigen::TensorRef< PlainObjectType >::~TensorRef ( )
inline
160 { unrefEvaluator(); }
EIGEN_STRONG_INLINE void unrefEvaluator()
Definition: TensorRef.h:238

References Eigen::TensorRef< PlainObjectType >::unrefEvaluator().

◆ TensorRef() [3/3]

template<typename PlainObjectType >
Eigen::TensorRef< PlainObjectType >::TensorRef ( const TensorRef< PlainObjectType > &  other)
inline
162  : TensorBase<TensorRef<PlainObjectType> >(other), m_evaluator(other.m_evaluator) {
163  eigen_assert(m_evaluator->refCount() > 0);
164  m_evaluator->incrRefCount();
165  }
#define eigen_assert(x)
Definition: Macros.h:910

References eigen_assert, and Eigen::TensorRef< PlainObjectType >::m_evaluator.

Member Function Documentation

◆ coeff() [1/2]

template<typename PlainObjectType >
template<std::size_t NumIndices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar Eigen::TensorRef< PlainObjectType >::coeff ( const array< Index, NumIndices > &  indices) const
inline
199  {
200  const Dimensions& dims = this->dimensions();
201  Index index = 0;
202  if (PlainObjectType::Options & RowMajor) {
203  index += indices[0];
204  for (size_t i = 1; i < NumIndices; ++i) {
205  index = index * dims[i] + indices[i];
206  }
207  } else {
208  index += indices[NumIndices - 1];
209  for (int i = NumIndices - 2; i >= 0; --i) {
210  index = index * dims[i] + indices[i];
211  }
212  }
213  return m_evaluator->coeff(index);
214  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
internal::traits< PlainObjectType >::Index Index
Definition: TensorRef.h:120
PlainObjectType::Dimensions Dimensions
Definition: TensorRef.h:128
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorRef.h:179
static constexpr Index NumIndices
Definition: TensorRef.h:127
@ RowMajor
Definition: Constants.h:320

References Eigen::TensorRef< PlainObjectType >::dimensions(), i, Eigen::TensorRef< PlainObjectType >::m_evaluator, Eigen::TensorRef< PlainObjectType >::NumIndices, and Eigen::RowMajor.

Referenced by Eigen::TensorRef< PlainObjectType >::operator()().

◆ coeff() [2/2]

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar Eigen::TensorRef< PlainObjectType >::coeff ( Index  index) const
inline
233 { return m_evaluator->coeff(index); }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ coeffRef() [1/3]

template<typename PlainObjectType >
template<std::size_t NumIndices>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( const array< Index, NumIndices > &  indices)
inline
216  {
217  const Dimensions& dims = this->dimensions();
218  Index index = 0;
219  if (PlainObjectType::Options & RowMajor) {
220  index += indices[0];
221  for (size_t i = 1; i < NumIndices; ++i) {
222  index = index * dims[i] + indices[i];
223  }
224  } else {
225  index += indices[NumIndices - 1];
226  for (int i = NumIndices - 2; i >= 0; --i) {
227  index = index * dims[i] + indices[i];
228  }
229  }
230  return m_evaluator->coeffRef(index);
231  }

References Eigen::TensorRef< PlainObjectType >::dimensions(), i, Eigen::TensorRef< PlainObjectType >::m_evaluator, Eigen::TensorRef< PlainObjectType >::NumIndices, and Eigen::RowMajor.

◆ coeffRef() [2/3]

template<typename PlainObjectType >
template<typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( Index  firstIndex,
IndexTypes...  otherIndices 
)
inline
192  {
193  const std::size_t num_indices = (sizeof...(otherIndices) + 1);
194  const array<Index, num_indices> indices{{firstIndex, otherIndices...}};
195  return coeffRef(indices);
196  }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index firstIndex, IndexTypes... otherIndices)
Definition: TensorRef.h:192

Referenced by test_coeff_ref(), and test_simple_lvalue_ref().

◆ coeffRef() [3/3]

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& Eigen::TensorRef< PlainObjectType >::coeffRef ( Index  index)
inline
235 { return m_evaluator->coeffRef(index); }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ data()

◆ dimension()

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index Eigen::TensorRef< PlainObjectType >::dimension ( Index  n) const
inline
178 { return m_evaluator->dimensions()[n]; }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11

References Eigen::TensorRef< PlainObjectType >::m_evaluator, and n.

Referenced by test_multiple_dims(), and test_ref_of_ref().

◆ dimensions()

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

◆ operator()() [1/2]

template<typename PlainObjectType >
template<typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar Eigen::TensorRef< PlainObjectType >::operator() ( Index  firstIndex,
IndexTypes...  otherIndices 
) const
inline
186  {
187  const std::size_t num_indices = (sizeof...(otherIndices) + 1);
188  const array<Index, num_indices> indices{{firstIndex, otherIndices...}};
189  return coeff(indices);
190  }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(const array< Index, NumIndices > &indices) const
Definition: TensorRef.h:199

References Eigen::TensorRef< PlainObjectType >::coeff().

◆ operator()() [2/2]

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar Eigen::TensorRef< PlainObjectType >::operator() ( Index  index) const
inline
183 { return m_evaluator->coeff(index); }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ operator=() [1/2]

template<typename PlainObjectType >
template<typename Expression >
EIGEN_STRONG_INLINE TensorRef& Eigen::TensorRef< PlainObjectType >::operator= ( const Expression &  expr)
inline
153  {
154  unrefEvaluator();
155  m_evaluator = new internal::TensorLazyEvaluator<Dimensions, Expression, DefaultDevice>(expr, DefaultDevice());
156  m_evaluator->incrRefCount();
157  return *this;
158  }

References Eigen::TensorRef< PlainObjectType >::m_evaluator, and Eigen::TensorRef< PlainObjectType >::unrefEvaluator().

◆ operator=() [2/2]

template<typename PlainObjectType >
TensorRef& Eigen::TensorRef< PlainObjectType >::operator= ( const TensorRef< PlainObjectType > &  other)
inline
167  {
168  if (this != &other) {
169  unrefEvaluator();
170  m_evaluator = other.m_evaluator;
171  eigen_assert(m_evaluator->refCount() > 0);
172  m_evaluator->incrRefCount();
173  }
174  return *this;
175  }

References eigen_assert, Eigen::TensorRef< PlainObjectType >::m_evaluator, and Eigen::TensorRef< PlainObjectType >::unrefEvaluator().

◆ rank()

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index Eigen::TensorRef< PlainObjectType >::rank ( ) const
inline
177 { return m_evaluator->dimensions().size(); }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ size()

template<typename PlainObjectType >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index Eigen::TensorRef< PlainObjectType >::size ( ) const
inline
180 { return m_evaluator->dimensions().TotalSize(); }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

◆ unrefEvaluator()

template<typename PlainObjectType >
EIGEN_STRONG_INLINE void Eigen::TensorRef< PlainObjectType >::unrefEvaluator ( )
inlineprivate
238  {
239  if (m_evaluator) {
240  m_evaluator->decrRefCount();
241  if (m_evaluator->refCount() == 0) {
242  delete m_evaluator;
243  }
244  }
245  }

References Eigen::TensorRef< PlainObjectType >::m_evaluator.

Referenced by Eigen::TensorRef< PlainObjectType >::operator=(), and Eigen::TensorRef< PlainObjectType >::~TensorRef().

Member Data Documentation

◆ Layout

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

◆ m_evaluator

◆ NumIndices

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

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