SpECTRE  2021.08.02
TensorExpressions Namespace Reference

Classes

struct  AddSub
 
struct  AddSub< T1, T2, ArgsList1< Args1... >, ArgsList2< Args2... >, Sign >
 
struct  LhsTensorSymmAndIndices
 Determines and stores a LHS tensor's symmetry and index list from a RHS tensor expression and desired LHS index order. More...
 
struct  LhsTensorSymmAndIndices< RhsTensorIndexList, tmpl::list< LhsTensorIndices... >, RhsSymmetry, RhsTensorIndexTypeList, NumIndices, std::index_sequence< Ints... > >
 
struct  NumberAsExpression
 Defines an expression representing a double More...
 
struct  OuterProduct
 Defines the tensor expression representing the outer product of two tensor expressions. More...
 
struct  OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >
 
struct  SquareRoot
 Defines the tensor expression representing the square root of a tensor expression that evaluates to a rank 0 tensor. More...
 
struct  TensorAsExpression
 Defines an expression representing a Tensor. More...
 
struct  TensorAsExpression< Tensor< X, Symm, IndexList< Indices... > >, ArgsList< Args... > >
 
struct  TensorContract
 

Functions

template<auto &... LhsTensorIndices, typename X , typename LhsSymmetry , typename LhsIndexList , typename Derived , typename RhsSymmetry , typename RhsIndexList , typename... RhsTensorIndices>
void evaluate (const gsl::not_null< Tensor< X, LhsSymmetry, LhsIndexList > * > lhs_tensor, const TensorExpression< Derived, X, RhsSymmetry, RhsIndexList, tmpl::list< RhsTensorIndices... > > &rhs_tensorexpression)
 Evaluate a RHS tensor expression to a tensor with the LHS index order set in the template parameters. More...
 
template<auto &... LhsTensorIndices, typename RhsTE , Requires< std::is_base_of_v< Expression, RhsTE > > = nullptr>
auto evaluate (const RhsTE &rhs_tensorexpression)
 Evaluate a RHS tensor expression to a tensor with the LHS index order set in the template parameters. More...
 
template<size_t NumIndices>
constexpr std::array< size_t, NumIndices > compute_tensorindex_transformation (const std::array< size_t, NumIndices > &tensorindices1, const std::array< size_t, NumIndices > &tensorindices2) noexcept
 Computes a transformation from one generic tensor index order to another. More...
 
template<size_t NumIndices>
constexpr std::array< size_t, NumIndices > transform_multi_index (const std::array< size_t, NumIndices > &input_multi_index, const std::array< size_t, NumIndices > &tensorindex_transformation) noexcept
 Computes the tensor multi-index that is equivalent to a given tensor multi-index, according to the differences in their generic index orders. More...
 

Detailed Description

Holds all possible TensorExpressions currently implemented

Function Documentation

◆ compute_tensorindex_transformation()

template<size_t NumIndices>
constexpr std::array< size_t, NumIndices > TensorExpressions::compute_tensorindex_transformation ( const std::array< size_t, NumIndices > &  tensorindices1,
const std::array< size_t, NumIndices > &  tensorindices2 
)
constexprnoexcept

Computes a transformation from one generic tensor index order to another.

Details

The elements of the transformation are the positions of the second list of generic indices in the first list of generic indices. Put another way, for some i, tensorindices2[i] == tensorindices1[index_transformation[i]].

Here is an example of what the algorithm does:

Transformation between (1) \(R_{cab}\) and (2) \(S_{abc}\) tensorindices1:

{2, 0, 1} // TensorIndex values for {c, a, b}

tensorindices2:

{0, 1, 2} // TensorIndex values for {a, b, c}

returned tensorindex_transformation:

{1, 2, 0} // positions of S' indices {a, b, c} in R's indices {c, a, b}
Template Parameters
NumIndicesthe number of indices
Parameters
tensorindices1the TensorIndex values of the first generic index order
tensorindices2the TensorIndex values of the second generic index order

Returns: a transformation from the first generic index order to the second

◆ transform_multi_index()

template<size_t NumIndices>
constexpr std::array< size_t, NumIndices > TensorExpressions::transform_multi_index ( const std::array< size_t, NumIndices > &  input_multi_index,
const std::array< size_t, NumIndices > &  tensorindex_transformation 
)
constexprnoexcept

Computes the tensor multi-index that is equivalent to a given tensor multi-index, according to the differences in their generic index orders.

Details

Here is an example of what the algorithm does:

Transform (input) multi-index of \(R_{cab}\) to the equivalent (output) multi-index of \(S_{abc}\) tensorindex_transformation:

{1, 2, 0} // positions of S' indices {a, b, c} in R's indices {c, a, b}

input_multi_index:

{3, 4, 5} // i.e. c = 3, a = 4, b = 5

returned equivalent output_multi_index:

{4, 5, 3} // i.e. a = 4, b = 5, c = 3
Template Parameters
NumIndicesthe number of indices
Parameters
input_multi_indexthe input tensor multi-index to transform
tensorindex_transformationthe positions of the output's generic indices in the input's generic indices (see example in details)

Returns: the output tensor multi-index that is equivalent to input_multi_index, according to generic index order differences