|
using | storage_type = std::array< X, Tensor_detail::Structure< Symm, Indices... >::size()> |
| The type of the sequence that holds the data.
|
|
using | type = X |
| The type that is stored by the Tensor.
|
|
using | symmetry = Symm |
| Typelist of the symmetry of the Tensor. More...
|
|
using | index_list = tmpl::list< Indices... > |
| Typelist of the TensorIndexType's that the Tensor has.
|
|
using | structure = Tensor_detail::Structure< Symm, Indices... > |
| The Tensor_detail::Structure for the particular tensor index structure. More...
|
|
template<typename ArgsList > |
using | TE = tenex::TensorAsExpression< Tensor< X, Symm, IndexList< Indices... > >, ArgsList > |
| The type of the TensorExpression that would represent this Tensor in a tensor expression.
|
|
using | value_type = typename storage_type::value_type |
|
using | reference = typename storage_type::reference |
|
using | const_reference = typename storage_type::const_reference |
|
using | iterator = typename storage_type::iterator |
|
using | const_iterator = typename storage_type::const_iterator |
|
using | pointer = typename storage_type::pointer |
|
using | const_pointer = typename storage_type::const_pointer |
|
using | reverse_iterator = typename storage_type::reverse_iterator |
|
using | const_reverse_iterator = typename storage_type::const_reverse_iterator |
|
|
| Tensor (const Tensor &)=default |
|
| Tensor (Tensor &&)=default |
|
Tensor & | operator= (const Tensor &)=default |
|
Tensor & | operator= (Tensor &&)=default |
|
template<size_t NumberOfIndices = sizeof...(Indices), Requires<(NumberOfIndices<=1)> = nullptr> |
| Tensor (storage_type data) |
| Initialize a vector or scalar from an array. More...
|
|
template<typename... Args, Requires< not(std::disjunction_v< std::is_same< Tensor< X, Symm, IndexList< Indices... > >, std::decay_t< Args > >... > and sizeof...(Args)==1) and std::is_constructible_v< X, Args... > > = nullptr> |
| Tensor (Args &&... args) |
| Constructor that passes "args" to constructor of X and initializes each component to be the same.
|
|
iterator | begin () |
|
const_iterator | begin () const |
|
const_iterator | cbegin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
const_iterator | cend () const |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
const_reverse_iterator | crbegin () const |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
const_reverse_iterator | crend () const |
|
std::pair< std::vector< std::string >, std::vector< X > > | get_vector_of_data () const |
| Copy tensor data into an std::vector<X> along with the component names into a std::vector<std::string> More...
|
|
|
template<typename T > |
constexpr reference | get (const std::array< T, sizeof...(Indices)> &tensor_index) |
| Get data entry using an array representing a tensor index. More...
|
|
template<typename T > |
constexpr const_reference | get (const std::array< T, sizeof...(Indices)> &tensor_index) const |
| Get data entry using an array representing a tensor index. More...
|
|
|
template<typename... N> |
constexpr reference | get (N... n) |
| Get data entry using a list of integers representing a tensor index. More...
|
|
template<typename... N> |
constexpr const_reference | get (N... n) const |
| Get data entry using a list of integers representing a tensor index. More...
|
|
|
template<typename... TensorIndices> |
constexpr auto | operator() (TensorIndices...) const |
| Retrieve a TensorExpression object with the index structure passed in.
|
|
|
constexpr reference | operator[] (const size_t storage_index) |
| Return i'th component of storage vector.
|
|
constexpr const_reference | operator[] (const size_t storage_index) const |
| Return i'th component of storage vector.
|
|
|
static constexpr size_t | size () |
| Return the number of independent components of the Tensor. More...
|
|
static constexpr size_t | rank () |
| Returns the rank of the Tensor. More...
|
|
|
template<typename... N> |
static constexpr size_t | get_storage_index (const N... args) |
| Get the storage index of the tensor index. Should only be used when optimizing code in which computing the storage index is a bottleneck.
|
|
template<typename I > |
static constexpr size_t | get_storage_index (const std::array< I, sizeof...(Indices)> &tensor_index) |
| Get the storage index of the tensor index. Should only be used when optimizing code in which computing the storage index is a bottleneck.
|
|
|
static constexpr size_t | index_dim (const size_t i) |
| Get dimensionality of i'th tensor index. More...
|
|
|
static constexpr std::array< int, sizeof...(Indices)> | symmetries () |
| Return an array corresponding to the Symmetry of the Tensor.
|
|
|
static constexpr std::array< IndexType, sizeof...(Indices)> | index_types () |
| Return array of the IndexType's (spatial or spacetime)
|
|
|
static constexpr std::array< size_t, sizeof...(Indices)> | index_dims () |
| Return array of dimensionality of each index. More...
|
|
|
static constexpr std::array< UpLo, sizeof...(Indices)> | index_valences () |
| Return array of the valence of each index (UpLo)
|
|
|
static constexpr auto | index_frames () |
| Returns std::tuple of the Frame of each index.
|
|
|
template<typename T = int> |
static std::string | component_name (const std::array< T, rank()> &tensor_index=std::array< T, rank()>{}, const std::array< std::string, rank()> &axis_labels=make_array< rank()>(std::string(""))) |
| Given a tensor index, get the canonical label associated with the canonical TensorIndexType. More...
|
|
|
template<typename IndexType = int> |
static std::string | component_suffix (const std::array< IndexType, rank()> &tensor_index=std::array< IndexType, rank()>{}, const std::array< std::string, rank()> &axis_labels=make_array< rank()>(std::string(""))) |
| Suffix to append to the tensor name that indicates the component. More...
|
|
static std::string | component_suffix (const size_t storage_index, const std::array< std::string, rank()> &axis_labels) |
| Suffix to append to the tensor name that indicates the component. More...
|
|
static std::string | component_suffix (size_t storage_index) |
| Suffix to append to the tensor name that indicates the component. More...
|
|
|
|
template<int... N, typename... Args> |
constexpr Tensor< Args... >::reference | get (Tensor< Args... > &t) |
| Retrieve the index N... by computing the storage index at compile time.
|
|
template<int... N, typename... Args> |
constexpr Tensor< Args... >::const_reference | get (const Tensor< Args... > &t) |
| Retrieve the index N... by computing the storage index at compile time.
|
|
constexpr std::array< size_t, sizeof...(Indices)> | get_tensor_index (const const_iterator &iter) const |
| Given an iterator or storage index, get the canonical tensor index. For scalars this is defined to be std::array<int, 1>{{0}}.
|
|
static constexpr std::array< size_t, sizeof...(Indices)> | get_tensor_index (const size_t storage_index) |
| Given an iterator or storage index, get the canonical tensor index. For scalars this is defined to be std::array<int, 1>{{0}}.
|
|
constexpr size_t | multiplicity (const const_iterator &iter) const |
| Given an iterator or storage index, get the multiplicity of an index. More...
|
|
static constexpr size_t | multiplicity (const size_t storage_index) |
| Given an iterator or storage index, get the multiplicity of an index. More...
|
|
template<typename X, typename Symm, template< typename... > class IndexList, typename... Indices>
class Tensor< X, Symm, IndexList< Indices... > >
Represents an object with multiple components.
Details
Tensor is a container that represents indexable geometric objects. Each index has its own dimension, valence, and frame and must be either spatial or spacetime. Note that the dimension passed to SpatialIndex
and SpacetimeIndex
is always the spatial dimension of the index. Tensors with symmetric indices are stored only once and must be of the same type. A list of available type aliases can be found in the tnsr namespace where the adopted conventions are:
- Upper case for contravariant or upper indices, lower case for covariant or lower indices.
a, b, c, d
are used for spacetime indices while i, j, k, l
are used for spatial indices.
Scalar
is not inside the tnsr
namespace but is used to represent a scalar with no indices.
Example
Definition: ContractFirstNIndices.hpp:16
index_list<SpacetimeIndex<1, UpLo::Lo, Frame::Grid>,
tensor_1{};
Tensor_detail::TensorIndexType< SpatialDim, Ul, Fr, IndexType::Spatial > SpatialIndex
A SpatialIndex holds information about the number of spatial dimensions, whether the index is covaria...
Definition: IndexType.hpp:206
- Template Parameters
-
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
using Tensor< X, Symm, IndexList< Indices... > >::structure = Tensor_detail::Structure<Symm, Indices...> |
The Tensor_detail::Structure for the particular tensor index structure.
Each tensor index structure, e.g. \(T_{ab}\), \(T_a{}^b\) or \(T^{ab}\) has its own Tensor_detail::TensorStructure that holds information about how the data is stored, what the multiplicity of the stored indices are, the number of (independent) components, etc.
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
using Tensor< X, Symm, IndexList< Indices... > >::symmetry = Symm |
Typelist of the symmetry of the Tensor.
Details
For a rank-3 tensor symmetric in the last two indices, \(T_{a(bc)}\), the Symmetry is <2, 1, 1>
. For a non-symmetric rank-2 tensor the Symmetry is <2, 1>
.
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
Suffix to append to the tensor name that indicates the component.
The suffix is empty for scalars, otherwise it is an underscore followed by the Tensor::component_name
of either the tensor_index
or the canonical tensor index obtained from the storage_index
. Use axis_labels
to overwrite the default labels for each component (see Tensor::component_name
).
An example use case for the suffix is to label tensor components in data files.
- See also
- Tensor::component_name
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
Suffix to append to the tensor name that indicates the component.
The suffix is empty for scalars, otherwise it is an underscore followed by the Tensor::component_name
of either the tensor_index
or the canonical tensor index obtained from the storage_index
. Use axis_labels
to overwrite the default labels for each component (see Tensor::component_name
).
An example use case for the suffix is to label tensor components in data files.
- See also
- Tensor::component_name
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
static std::string Tensor< X, Symm, IndexList< Indices... > >::component_suffix |
( |
size_t |
storage_index | ) |
|
|
static |
Suffix to append to the tensor name that indicates the component.
The suffix is empty for scalars, otherwise it is an underscore followed by the Tensor::component_name
of either the tensor_index
or the canonical tensor index obtained from the storage_index
. Use axis_labels
to overwrite the default labels for each component (see Tensor::component_name
).
An example use case for the suffix is to label tensor components in data files.
- See also
- Tensor::component_name
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
template<typename T >
constexpr reference Tensor< X, Symm, IndexList< Indices... > >::get |
( |
const std::array< T, sizeof...(Indices)> & |
tensor_index | ) |
|
|
inlineconstexpr |
Get data entry using an array representing a tensor index.
Details
Let \(T_{abc}\) be a Tensor. Then get({{0, 2, 1}})
returns the \(T_{0 2 1}\) component.
- Parameters
-
tensor_index | the index at which to get the data |
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
template<typename T >
constexpr const_reference Tensor< X, Symm, IndexList< Indices... > >::get |
( |
const std::array< T, sizeof...(Indices)> & |
tensor_index | ) |
const |
|
inlineconstexpr |
Get data entry using an array representing a tensor index.
Details
Let \(T_{abc}\) be a Tensor. Then get({{0, 2, 1}})
returns the \(T_{0 2 1}\) component.
- Parameters
-
tensor_index | the index at which to get the data |
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
template<typename... N>
constexpr reference Tensor< X, Symm, IndexList< Indices... > >::get |
( |
N... |
n | ) |
|
|
inlineconstexpr |
Get data entry using a list of integers representing a tensor index.
Details
Let \(T_{abc}\) be a Tensor. Then get(0, 2, 1)
returns the \(T_{0 2 1}\) component.
- Parameters
-
n | the index at which to get the data |
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
template<typename... N>
constexpr const_reference Tensor< X, Symm, IndexList< Indices... > >::get |
( |
N... |
n | ) |
const |
|
inlineconstexpr |
Get data entry using a list of integers representing a tensor index.
Details
Let \(T_{abc}\) be a Tensor. Then get(0, 2, 1)
returns the \(T_{0 2 1}\) component.
- Parameters
-
n | the index at which to get the data |
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
static constexpr size_t Tensor< X, Symm, IndexList< Indices... > >::rank |
( |
| ) |
|
|
inlinestaticconstexpr |
Returns the rank of the Tensor.
Details
The rank of a tensor is the number of indices it has. For example, the tensor \(v^a\) is rank-1, the tensor \(\phi\) is rank-0, and the tensor \(T_{abc}\) is rank-3.
template<typename X , typename Symm , template< typename... > class IndexList, typename... Indices>
static constexpr size_t Tensor< X, Symm, IndexList< Indices... > >::size |
( |
| ) |
|
|
inlinestaticconstexpr |
Return the number of independent components of the Tensor.
Details
Returns the number of independent components of the Tensor taking into account symmetries. For example, let \(T_{ab}\) be a n-dimensional rank-2 symmetric tensor, then the number of independent components is \(n(n+1)/2\).