SpECTRE  v2024.09.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
tenex Namespace Reference

Classes

struct  AddSub
 Defines the tensor expression representing the addition or subtraction of two tensor expressions. More...
 
struct  AddSub< T1, T2, ArgsList1< Args1... >, ArgsList2< Args2... >, Sign >
 
struct  Divide
 Defines the tensor expression representing the quotient of one tensor expression divided by another tensor expression that evaluates to a rank 0 tensor. More...
 
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< tmpl::list< RhsTensorIndices... >, tmpl::list< LhsTensorIndices... >, tmpl::integral_list< std::int32_t, RhsSymm... >, RhsTensorIndexTypeList, NumLhsIndices, NumRhsIndices, std::index_sequence< LhsInts... > >
 
struct  MarkAsNumberAsExpression
 Marks a class as being a NumberAsExpression<DataType> More...
 
struct  Negate
 Defines the tensor expression representing the negation of a tensor expression. More...
 
struct  NumberAsExpression
 Defines an expression representing a number. 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< SymmValues... >, IndexList< Indices... > >, ArgsList< Args... > >
 
struct  TensorContract
 
struct  tensorindex_list_is_valid
 Determine whether or not a given list of TensorIndexs is valid to be used with a tensor. More...
 
struct  tensorindex_list_is_valid< tmpl::list< TensorIndices... > >
 

Typedefs

template<typename TensorIndexList1 , typename TensorIndexList2 >
using generic_indices_at_same_positions = implementation defined
 Determine whether or not two lists of TensorIndexs contain the same generic indices at the same positions. More...
 

Functions

template<auto &... LhsTensorIndices, typename LhsDataType , typename LhsSymmetry , typename LhsIndexList , typename Derived , typename RhsDataType , typename RhsSymmetry , typename RhsIndexList , typename... RhsTensorIndices>
void evaluate (const gsl::not_null< Tensor< LhsDataType, LhsSymmetry, LhsIndexList > * > lhs_tensor, const TensorExpression< Derived, RhsDataType, RhsSymmetry, RhsIndexList, tmpl::list< RhsTensorIndices... > > &rhs_tensorexpression)
 Assign the result of 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)
 Assign the result of a RHS tensor expression to a tensor with the LHS index order set in the template parameters. More...
 
template<auto &... LhsTensorIndices, typename LhsDataType , typename RhsDataType , typename LhsSymmetry , typename LhsIndexList , typename Derived , typename RhsSymmetry , typename RhsIndexList , typename... RhsTensorIndices>
void update (const gsl::not_null< Tensor< LhsDataType, LhsSymmetry, LhsIndexList > * > lhs_tensor, const TensorExpression< Derived, RhsDataType, RhsSymmetry, RhsIndexList, tmpl::list< RhsTensorIndices... > > &rhs_tensorexpression)
 If the LHS tensor is used in the RHS expression, this should be used to assign a LHS tensor to the result of a RHS tensor expression that contains it. More...
 
template<size_t NumIndices1, size_t NumIndices2>
constexpr std::array< size_t, NumIndices2 > compute_tensorindex_transformation (const std::array< size_t, NumIndices1 > &tensorindices1, const std::array< size_t, NumIndices2 > &tensorindices2)
 Computes a transformation from one generic tensor index order to another. More...
 
template<size_t NumIndicesIn, size_t NumIndicesOut>
constexpr std::array< size_t, NumIndicesOut > transform_multi_index (const std::array< size_t, NumIndicesIn > &input_multi_index, const std::array< size_t, NumIndicesOut > &tensorindex_transformation)
 Computes the tensor multi-index that is equivalent to a given tensor multi-index, according to the differences in their generic index orders. More...
 
template<auto &... LhsTensorIndices, typename X , typename LhsSymmetry , typename LhsIndexList , typename N , Requires< std::is_arithmetic_v< N > > = nullptr>
void evaluate (const gsl::not_null< Tensor< X, LhsSymmetry, LhsIndexList > * > lhs_tensor, const N rhs_value)
 Assign a number to components of a tensor with the LHS index order set in the template parameters. More...
 
template<auto &... LhsTensorIndices, typename X , typename LhsSymmetry , typename LhsIndexList , typename N >
void evaluate (const gsl::not_null< Tensor< X, LhsSymmetry, LhsIndexList > * > lhs_tensor, const std::complex< N > &rhs_value)
 Assign a number to components of a tensor with the LHS index order set in the template parameters. More...
 

Detailed Description

Holds all possible TensorExpressions currently implemented

Function Documentation

◆ compute_tensorindex_transformation()

template<size_t NumIndices1, size_t NumIndices2>
constexpr std::array< size_t, NumIndices2 > tenex::compute_tensorindex_transformation ( const std::array< size_t, NumIndices1 > &  tensorindices1,
const std::array< size_t, NumIndices2 > &  tensorindices2 
)
constexpr

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

Details

In most cases, the elements of the transformation are simply 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) Rcab and (2) Sabc 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}

One special case scenario to note is when concrete time indices are involved in the transformation. Consider transforming a multi-index for some tensor Rab to another tensor Sbtat. This would be necessary for evaluating the LHS of a simple equation such as Rab=Sbtat. The transformation between a multi-index for R to the equivalent multi-index for S cannot simply be the list of positions of S' indices in R's indices, as R does not contain all of S' indices, because it has no time indices. To handle cases like this, a placeholder value for the position of any time index is substituted for an actual position, since one may not exist. In this example, the transformation would be {1, PLACEHOLDER_VALUE, 0, PLACEHOLDER_VALUE}, where PLACEHOLDER_VALUE is defined by TensorIndexTransformation_detail::time_index_position_placeholder. 1 and 0 are the positions of b and a in R, and the placeholder is used for the positions of time indices.

Template Parameters
NumIndices1the number of indices for the first generic index order
NumIndices2the number of indices for the second generic index order
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 NumIndicesIn, size_t NumIndicesOut>
constexpr std::array< size_t, NumIndicesOut > tenex::transform_multi_index ( const std::array< size_t, NumIndicesIn > &  input_multi_index,
const std::array< size_t, NumIndicesOut > &  tensorindex_transformation 
)
constexpr

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 Rcab to the equivalent (output) multi-index of Sabc 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

One special case scenario to note is when concrete time indices are involved in the transformation. Consider transforming a multi-index for some tensor Rab to another tensor Sbtat. This would be necessary for evaluating the LHS of a simple equation such as Rab=Sbtat. The transformation between a multi-index for R to the equivalent multi-index for S cannot simply be the list of positions of S' indices in R's indices, as R does not contain all of S' indices, because it has no time indices. To handle cases like this, a placeholder value for the position of any time index must be substituted for an actual position, since one may not exist. In this example, the proper input transformation (tensorindex_transformation) would need to be {1, PLACEHOLDER_VALUE, 0, PLACEHOLDER_VALUE}, where PLACEHOLDER_VALUE is defined by TensorIndexTransformation_detail::time_index_position_placeholder. 1 and 0 are the positions of b and a in R, and the placeholder is used for the positions of time indices. In computing the output transformed multi-index, the function will insert a 0 at each position where this placeholder is found in the transformation. For example, if input_multi_index is {1, 2}, representing R12, the returned output multi-index will be {2, 0, 1, 0}, representing S2010.

Template Parameters
NumIndicesInthe number of indices
NumIndicesOutthe 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