Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ > Class Template Reference

#include <contrib/Eigen/src/Tensor/Tensor.h>

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. Tensor expressions such as the sum of two tensors are evaluated with packet instructions whenever the evaluators involved support packet access.

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:69

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. Taking blocks and using tensors in expressions is already supported through TensorBase; interoperability with the vector/matrix code currently relies on wrapping the data in a Map or a TensorMap instead of dedicated methods. Fixed-size tensors are provided by the separate TensorFixedSize class.

Storage orders

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

Public Member Functions

void resize (const array< Index, NumIndices > &dimensions)
 
template<typename CustomDimension, EIGEN_SFINAE_ENABLE_IF(!(isOfNormalIndex< CustomDimension >::value))>
void resize (CustomDimension &dimensions)
 
 Tensor (const array< Index, NumIndices > &dimensions)
 

Constructor & Destructor Documentation

◆ Tensor()

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

Normal Dimension

Member Function Documentation

◆ resize() [1/2]

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

◆ resize() [2/2]

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

Custom Dimension


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