10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_REF_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_REF_H 17 template <
typename Dimensions,
typename Scalar>
42 template <
typename Dimensions,
typename Expr,
typename Device>
52 m_dims = m_impl.dimensions();
53 m_impl.evalSubExprsIfNeeded(
NULL);
67 return m_impl.coeff(index);
70 eigen_assert(
false &&
"can't reference the coefficient of a rvalue");
80 template <
typename Dimensions,
typename Expr,
typename Device>
94 return this->m_impl.coeffRef(index);
98 template <
typename Dimensions,
typename Expr,
typename Device>
100 TensorLazyEvaluatorWritable<Dimensions, Expr, Device>,
101 TensorLazyEvaluatorReadOnly<Dimensions, const Expr, Device> >
::type {
124 template<
typename PlainObjectType>
class TensorRef :
public TensorBase<TensorRef<PlainObjectType> >
128 typedef typename PlainObjectType::Base
Base;
138 static const Index NumIndices = PlainObjectType::NumIndices;
143 PacketAccess =
false,
145 PreferBlockAccess =
false,
146 Layout = PlainObjectType::Layout,
158 template <
typename Expression>
160 m_evaluator->incrRefCount();
163 template <
typename Expression>
177 m_evaluator->incrRefCount();
181 if (
this != &other) {
185 m_evaluator->incrRefCount();
204 return m_evaluator->coeff(index);
207 #if EIGEN_HAS_VARIADIC_TEMPLATES 211 const std::size_t num_indices = (
sizeof...(otherIndices) + 1);
213 return coeff(indices);
218 const std::size_t num_indices = (
sizeof...(otherIndices) + 1);
230 return coeff(indices);
239 return coeff(indices);
249 return coeff(indices);
260 return coeff(indices);
307 if (PlainObjectType::Options &
RowMajor) {
309 for (
size_t i = 1;
i < NumIndices; ++
i) {
310 index = index * dims[
i] + indices[
i];
313 index += indices[NumIndices-1];
314 for (
int i = NumIndices-2;
i >= 0; --
i) {
315 index = index * dims[
i] + indices[
i];
318 return m_evaluator->coeff(index);
325 if (PlainObjectType::Options &
RowMajor) {
327 for (
size_t i = 1;
i < NumIndices; ++
i) {
328 index = index * dims[
i] + indices[
i];
331 index += indices[NumIndices-1];
332 for (
int i = NumIndices-2;
i >= 0; --
i) {
333 index = index * dims[
i] + indices[
i];
336 return m_evaluator->coeffRef(index);
342 return m_evaluator->coeff(index);
348 return m_evaluator->coeffRef(index);
354 m_evaluator->decrRefCount();
355 if (m_evaluator->refCount() == 0) {
366 template<
typename Derived,
typename Device>
379 PacketAccess =
false,
381 PreferBlockAccess =
false,
404 return m_ref.coeff(index);
408 return m_ref.coeffRef(index);
419 template<
typename Derived,
typename Device>
432 PacketAccess =
false,
434 PreferBlockAccess =
false,
446 return this->m_ref.coeffRef(index);
454 #endif // EIGEN_CXX11_TENSOR_TENSOR_REF_H
TensorLazyBaseEvaluator & operator=(const TensorLazyBaseEvaluator &other)
PacketType< CoeffReturnType, Device >::type PacketReturnType
Derived::Scalar CoeffReturnType
TensorRef< PlainObjectType > Self
#define EIGEN_STRONG_INLINE
virtual ~TensorLazyBaseEvaluator()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
virtual EIGEN_DEVICE_FUNC Scalar & coeffRef(DenseIndex index)
virtual EIGEN_DEVICE_FUNC const Dimensions & dimensions() const =0
TensorRef(const TensorRef &other)
internal::TensorBlockNotImplemented TensorBlock
virtual EIGEN_DEVICE_FUNC Scalar & coeffRef(DenseIndex)
internal::TensorBlockNotImplemented TensorBlock
TensorEvaluator< Expr, Device > EvalType
Storage::Type EvaluatorPointerType
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index i0, Index i1, Index i2, Index i3, Index i4)
Derived::Dimensions Dimensions
A cost model used to limit the number of threads used for evaluating tensor expression.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(Index index) const
internal::traits< PlainObjectType >::Index Index
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
internal::traits< PlainObjectType >::StorageKind StorageKind
TensorLazyEvaluator(const Expr &expr, const Device &device)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index index) const
internal::traits< PlainObjectType >::Scalar Scalar
EIGEN_DEVICE_FUNC const Scalar * data() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(Index i0, Index i1, Index i2, Index i3) const
PlainObjectType::Base Base
EIGEN_STRONG_INLINE TensorEvaluator(TensorRef< Derived > &m, const Device &d)
PacketType< CoeffReturnType, Device >::type PacketReturnType
TensorEvaluator< Expr, Device > m_impl
StorageMemory< Scalar, Device > Storage
TensorLazyEvaluatorReadOnly< Dimensions, Expr, Device > Base
Eigen::internal::nested< Self >::type Nested
PointerType PointerArgType
PlainObjectType::Dimensions Dimensions
internal::TensorLazyBaseEvaluator< Dimensions, Scalar > * m_evaluator
EIGEN_STRONG_INLINE TensorEvaluator(const TensorRef< Derived > &m, const Device &)
Storage::Type EvaluatorPointerType
EIGEN_STRONG_INLINE TensorRef(const Expression &expr)
TensorLazyBaseEvaluator()
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_STRONG_INLINE void unrefEvaluator()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(const array< Index, NumIndices > &indices)
TensorLazyEvaluatorWritable(const Expr &expr, const Device &device)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(const array< Index, NumIndices > &indices) const
virtual EIGEN_DEVICE_FUNC const Scalar * data() const =0
virtual EIGEN_DEVICE_FUNC const Scalar coeff(DenseIndex index) const =0
internal::TensorBlockNotImplemented TensorBlock
StorageMemory< Scalar, Device > Storage
virtual EIGEN_DEVICE_FUNC const Scalar coeff(DenseIndex index) const
#define EIGEN_DEVICE_FUNC
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
TensorEvaluator< const TensorRef< Derived >, Device > Base
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(Index i0, Index i1) const
EIGEN_STRONG_INLINE void cleanup()
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index i0, Index i1)
virtual EIGEN_DEVICE_FUNC Scalar & coeffRef(DenseIndex index)=0
TensorLazyEvaluatorReadOnly(const Expr &expr, const Device &device)
StorageMemory< CoeffReturnType, Device > Storage
Derived::Dimensions Dimensions
TensorRef< Derived > m_ref
virtual ~TensorLazyEvaluatorWritable()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(Index n) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(Index i0, Index i1, Index i2) const
EIGEN_STRONG_INLINE TensorRef()
A reference to a tensor expression The expression will be evaluated lazily (as much as possible)...
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
Storage::Type EvaluatorPointerType
virtual ~TensorLazyEvaluatorReadOnly()
Generic expression where a coefficient-wise unary operator is applied to an expression.
Base::CoeffReturnType CoeffReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const
TensorEvaluator< Expr, Device >::Scalar Scalar
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index i0, Index i1, Index i2, Index i3)
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
virtual EIGEN_DEVICE_FUNC const Scalar * data() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index i0, Index i1, Index i2)
virtual EIGEN_DEVICE_FUNC const Dimensions & dimensions() const
Derived::Scalar CoeffReturnType
virtual ~TensorLazyEvaluator()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(Index i0, Index i1, Index i2, Index i3, Index i4) const