SpECTRE  2021.08.02
TensorExpressions::TensorContract< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList > Struct Template Reference

Classes

struct  ComputeContraction
 Helper struct for computing the contraction of one pair of indices. More...
 
struct  ComputeContraction< tmpl::list< UncontractedLhsTensorIndices... > >
 

Public Types

using first_contracted_index = tmpl::at_c< IndexList, FirstContractedIndexPos >
 
using second_contracted_index = tmpl::at_c< IndexList, SecondContractedIndexPos >
 
using new_type = typename detail::ContractedType< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList >::type
 
using type = X
 
using symmetry = typename new_type::symmetry
 
using index_list = typename new_type::index_list
 
using args_list = typename new_type::args_list
 
template<typename... LhsIndices>
using get_uncontracted_lhs_tensorindex_list_helper = tmpl::append< tmpl::front< tmpl::split_at< tmpl::list< LhsIndices... >, tmpl::size_t< FirstContractedIndexPos > > >, tmpl::list< tmpl::at_c< ArgsList, FirstContractedIndexPos > >, tmpl::back< tmpl::split_at< tmpl::list< LhsIndices... >, tmpl::size_t< FirstContractedIndexPos > > > >
 
template<typename... LhsIndices>
using get_uncontracted_lhs_tensorindex_list = tmpl::append< tmpl::front< tmpl::split_at< get_uncontracted_lhs_tensorindex_list_helper< LhsIndices... >, tmpl::size_t< SecondContractedIndexPos > > >, tmpl::list< tmpl::at_c< ArgsList, SecondContractedIndexPos > >, tmpl::back< tmpl::split_at< get_uncontracted_lhs_tensorindex_list_helper< LhsIndices... >, tmpl::size_t< SecondContractedIndexPos > > > >
 Constructs the uncontracted LHS's list of TensorIndexs by inserting the pair of indices being contracted into the list of contracted LHS TensorIndexs. More...
 

Public Member Functions

 TensorContract (const TensorExpression< T, X, Symm, IndexList, ArgsList > &t)
 
template<typename... ContractedLhsIndices>
decltype(auto) get (const std::array< size_t, num_tensor_indices > &contracted_lhs_multi_index) const
 Return the value of the component of the contracted LHS tensor at a given multi-index. More...
 

Static Public Member Functions

static constexpr std::array< size_t, num_uncontracted_tensor_indices > get_first_uncontracted_lhs_multi_index_to_sum (const std::array< size_t, num_tensor_indices > &contracted_lhs_multi_index) noexcept
 Return the multi-index of the first uncontracted LHS component to be summed to compute a given contracted LHS component. More...
 

Static Public Attributes

static constexpr auto num_tensor_indices = tmpl::size<index_list>::value
 
static constexpr auto num_uncontracted_tensor_indices
 

Member Typedef Documentation

◆ get_uncontracted_lhs_tensorindex_list

template<size_t FirstContractedIndexPos, size_t SecondContractedIndexPos, typename T , typename X , typename Symm , typename IndexList , typename ArgsList >
template<typename... LhsIndices>
using TensorExpressions::TensorContract< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList >::get_uncontracted_lhs_tensorindex_list = tmpl::append< tmpl::front<tmpl::split_at< get_uncontracted_lhs_tensorindex_list_helper<LhsIndices...>, tmpl::size_t<SecondContractedIndexPos> >>, tmpl::list<tmpl::at_c<ArgsList, SecondContractedIndexPos> >, tmpl::back<tmpl::split_at< get_uncontracted_lhs_tensorindex_list_helper<LhsIndices...>, tmpl::size_t<SecondContractedIndexPos> >> >

Constructs the uncontracted LHS's list of TensorIndexs by inserting the pair of indices being contracted into the list of contracted LHS TensorIndexs.

Example: Let ti_a_t denote the type of ti_a, and apply the same convention for other generic indices. If we contract RHS tensor \(R^{a}{}_{bac}\) to LHS tensor \(L_{cb}\), the RHS list of generic indices (ArgsList) is tmpl::list<ti_A_t, ti_b_t, ti_a_t, ti_c_t> and the LHS generic indices (LhsIndices) are ti_c_t, ti_b_t. ti_A_t and ti_a_t are inserted into LhsIndices at their positions from the RHS, which yields: tmpl::list<ti_A_t, ti_c_t, ti_a_t, ti_b_t>.

Member Function Documentation

◆ get()

template<size_t FirstContractedIndexPos, size_t SecondContractedIndexPos, typename T , typename X , typename Symm , typename IndexList , typename ArgsList >
template<typename... ContractedLhsIndices>
decltype(auto) TensorExpressions::TensorContract< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList >::get ( const std::array< size_t, num_tensor_indices > &  contracted_lhs_multi_index) const
inline

Return the value of the component of the contracted LHS tensor at a given multi-index.

Details

Given a RHS tensor to be contracted, the uncontracted LHS represents the uncontracted RHS tensor arranged with the LHS's generic index order. The contracted LHS represents the result of contracting this uncontracted LHS. For example, if we have RHS tensor \(R^{a}{}_{abc}\) and we want to contract it to the LHS tensor \(L_{cb}\), then \(L_{cb}\) represents the contracted LHS, while \(L^{a}{}_{acb}\) represents the uncontracted LHS. Note that the relative ordering of the LHS generic indices \(c\) and \(b\) in the contracted LHS is preserved in the uncontracted LHS.

To compute a contraction, we need to get all the uncontracted LHS components to sum. In the example above, this means that in order to compute \(L_{cb}\) for some \(c\) and \(b\), we need to sum the components \(L^{a}{}_{acb}\) for all values of \(a\). This function first constructs the list of generic indices (TensorIndexs) of the uncontracted LHS, then uses helper functions to compute and return the contracted LHS component by summing the necessary uncontracted LHS components.

Template Parameters
ContractedLhsIndicesthe TensorIndexs of the contracted LHS tensor
Parameters
contracted_lhs_multi_indexthe multi-index of the contracted LHS tensor component to retrieve

Returns: the value of the component at contracted_lhs_multi_index in the contracted LHS tensor

◆ get_first_uncontracted_lhs_multi_index_to_sum()

template<size_t FirstContractedIndexPos, size_t SecondContractedIndexPos, typename T , typename X , typename Symm , typename IndexList , typename ArgsList >
static constexpr std::array< size_t, num_uncontracted_tensor_indices > TensorExpressions::TensorContract< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList >::get_first_uncontracted_lhs_multi_index_to_sum ( const std::array< size_t, num_tensor_indices > &  contracted_lhs_multi_index)
inlinestaticconstexprnoexcept

Return the multi-index of the first uncontracted LHS component to be summed to compute a given contracted LHS component.

Details

Returns the multi-index that results from taking the contracted_lhs_multi_index and inserting 0 at the two positions of the pair of indices to contract.

Parameters
contracted_lhs_multi_indexthe multi-index of a contracted LHS component to be computed

Returns: the multi-index of the first uncontracted LHS component to be summed to compute the contracted LHS component at contracted_lhs_multi_index

Member Data Documentation

◆ num_uncontracted_tensor_indices

template<size_t FirstContractedIndexPos, size_t SecondContractedIndexPos, typename T , typename X , typename Symm , typename IndexList , typename ArgsList >
constexpr auto TensorExpressions::TensorContract< FirstContractedIndexPos, SecondContractedIndexPos, T, X, Symm, IndexList, ArgsList >::num_uncontracted_tensor_indices
staticconstexpr
Initial value:
=
tmpl::size<Symm>::value