11 #ifndef EIGEN_CXX11_TENSOR_TENSOR_H 12 #define EIGEN_CXX11_TENSOR_TENSOR_H 62 template<
typename Scalar_,
int NumIndices_,
int Options_,
typename IndexType_>
89 #ifdef EIGEN_HAS_SFINAE 90 template<
typename CustomIndices>
91 struct isOfNormalIndex{
92 static const bool is_array = internal::is_base_of<array<Index, NumIndices>, CustomIndices>::value;
94 static const bool value = is_array | is_int;
110 inline Self&
base() {
return *
this; }
111 inline const Self&
base()
const {
return *
this; }
113 #if EIGEN_HAS_VARIADIC_TEMPLATES 114 template<
typename... IndexTypes>
115 EIGEN_DEVICE_FUNC
inline const Scalar&
coeff(Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
const 118 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
131 #ifdef EIGEN_HAS_SFINAE 132 template<
typename CustomIndices,
137 return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
144 return m_storage.data()[0];
150 return m_storage.data()[index];
153 #if EIGEN_HAS_VARIADIC_TEMPLATES 154 template<
typename... IndexTypes>
155 inline Scalar&
coeffRef(Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
158 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
171 #ifdef EIGEN_HAS_SFINAE 172 template<
typename CustomIndices,
177 return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
184 return m_storage.data()[0];
190 return m_storage.data()[index];
193 #if EIGEN_HAS_VARIADIC_TEMPLATES 194 template<
typename... IndexTypes>
195 inline const Scalar&
operator()(Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
const 198 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
225 #ifdef EIGEN_HAS_SFINAE 226 template<
typename CustomIndices,
231 return coeff(internal::customIndices2Array<Index,NumIndices>(indices));
238 return coeff(indices);
260 #if EIGEN_HAS_VARIADIC_TEMPLATES 261 template<
typename... IndexTypes>
262 inline Scalar&
operator()(Index firstIndex, Index secondIndex, IndexTypes... otherIndices)
265 EIGEN_STATIC_ASSERT(
sizeof...(otherIndices) + 2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
298 #ifdef EIGEN_HAS_SFINAE 299 template<
typename CustomIndices,
304 return coeffRef(internal::customIndices2Array<Index,NumIndices>(indices));
335 : m_storage(other.m_storage)
339 #if EIGEN_HAS_VARIADIC_TEMPLATES 340 template<
typename... IndexTypes>
342 :
m_storage(firstDimension, otherDimensions...)
345 EIGEN_STATIC_ASSERT(
sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
349 : m_storage(dim1,
array<Index, 1>(dim1))
354 : m_storage(dim1*dim2,
array<Index, 2>(dim1, dim2))
359 : m_storage(dim1*dim2*dim3,
array<Index, 3>(dim1, dim2, dim3))
364 : m_storage(dim1*dim2*dim3*dim4,
array<Index, 4>(dim1, dim2, dim3, dim4))
369 : m_storage(dim1*dim2*dim3*dim4*dim5,
array<Index, 5>(dim1, dim2, dim3, dim4, dim5))
382 template<
typename OtherDerived>
387 Assign assign(*
this, other.
derived());
391 template<
typename OtherDerived>
396 Assign assign(*
this, other.
derived());
405 Assign assign(*
this, other);
410 template<
typename OtherDerived>
415 Assign assign(*
this, other);
421 #if EIGEN_HAS_VARIADIC_TEMPLATES 422 template<
typename... IndexTypes> EIGEN_DEVICE_FUNC
423 void resize(Index firstDimension, IndexTypes... otherDimensions)
426 EIGEN_STATIC_ASSERT(
sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
438 size *= dimensions[i];
440 #ifdef EIGEN_INITIALIZE_COEFFS 441 bool size_changed = size != this->
size();
442 m_storage.resize(size, dimensions);
445 m_storage.resize(size, dimensions);
453 dims[i] = dimensions[i];
466 #ifdef EIGEN_HAS_SFINAE 467 template<
typename CustomDimension,
472 resize(internal::customIndices2Array<Index,NumIndices>(dimensions));
476 #ifndef EIGEN_EMULATE_CXX11_META_H 477 template <
typename std::ptrdiff_t... Indices>
482 dims[i] =
static_cast<Index
>(dimensions[i]);
487 template <std::
size_t V1, std::
size_t V2, std::
size_t V3, std::
size_t V4, std::
size_t V5>
492 dims[i] =
static_cast<Index
>(dimensions[i]);
510 array_apply_and_reduce<logical_and_op, greater_equal_zero_op>(indices) &&
512 array_zip_and_reduce<logical_and_op, lesser_op>(indices, m_storage.dimensions());
518 return m_storage.dimensions().IndexOfRowMajor(indices);
520 return m_storage.dimensions().IndexOfColMajor(indices);
527 #endif // EIGEN_CXX11_TENSOR_TENSOR_H EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index dim1, Index dim2, Index dim3, Index dim4)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index i0, Index i1, Index i2)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor & operator=(const OtherDerived &other)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes< Indices... > &)
#define EIGEN_STRONG_INLINE
#define EIGEN_MAX_ALIGN_BYTES
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(Index i0, Index i1, Index i2, Index i3) const
EIGEN_DEVICE_FUNC void resize(const DSizes< Index, NumIndices > &dimensions)
TensorBase< Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > Base
Tensor< Scalar_, NumIndices_, Options_, IndexType_ > Self
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const TensorBase< OtherDerived, ReadOnlyAccessors > &other)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index i0, Index i1, Index i2, Index i3, Index i4)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(const array< Index, NumIndices > &indices)
NumTraits< Scalar >::Real RealScalar
A cost model used to limit the number of threads used for evaluating tensor expression.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index linearizedIndex(const array< Index, NumIndices > &indices) const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const
TensorStorage< Scalar, Dimensions, Options > m_storage
EIGEN_DEVICE_FUNC void resize()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & derived()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index i0, Index i1, Index i2, Index i3)
EIGEN_DEVICE_FUNC void resize(const Sizes< Indices... > &dimensions)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(Index i0, Index i1, Index i2, Index i3, Index i4) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator[](Index index)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index dim1)
bool array_apply_and_reduce(const array< A, N > &a)
Eigen::internal::nested< Self >::type Nested
#define EIGEN_SFINAE_ENABLE_IF(__condition__)
internal::traits< Self >::Index Index
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const TensorBase< OtherDerived, WriteAccessors > &other)
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE void run(Index, Index)
DSizes< Index, NumIndices_ > Dimensions
bool checkIndexRange(const array< Index, NumIndices > &indices) const
static const int NumIndices
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(Index i0, Index i1) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const array< Index, NumIndices > &dimensions)
static EIGEN_DEVICE_FUNC void run(const Expression &expr, const Device &device=Device())
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index dim1, Index dim2, Index dim3, Index dim4, Index dim5)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(const array< Index, NumIndices > &indices)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Base::CoeffReturnType CoeffReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(Index i0, Index i1, Index i2) const
EIGEN_DEVICE_FUNC void resize(const array< Index, NumIndices > &dimensions)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(const array< Index, NumIndices > &indices) const
const Self & base() const
bool array_zip_and_reduce(const array< A, N > &a, const array< B, N > &b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index i0, Index i1)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator[](Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()(const array< Index, NumIndices > &indices) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor & operator=(const Tensor &other)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index dim1, Index dim2, Index dim3)
internal::traits< Self >::StorageKind StorageKind
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()(Index index)
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
#define eigen_internal_assert(x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const Self &other)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index dim1, Index dim2)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & operator()()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & operator()() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const