SpECTRE  v2024.05.11
tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > > Struct Template Reference

Public Types

using type = typename detail::OuterProductType< T1, T2 >::type
 The type of the data being stored in the result of the expression.
 
using symmetry = typename detail::OuterProductType< T1, T2 >::symmetry
 The Symmetry of the result of the expression.
 
using index_list = typename detail::OuterProductType< T1, T2 >::index_list
 The list of TensorIndexTypes of the result of the expression.
 
using args_list = typename detail::OuterProductType< T1, T2 >::tensorindex_list
 The list of generic TensorIndexs of the result of the expression.
 

Public Member Functions

 OuterProduct (T1 t1, T2 t2)
 
template<typename LhsTensor >
void assert_lhs_tensor_not_in_rhs_expression (const gsl::not_null< LhsTensor * > lhs_tensor) const
 Assert that the LHS tensor of the equation does not also appear in this expression's subtree.
 
template<typename LhsTensorIndices , typename LhsTensor >
void assert_lhs_tensorindices_same_in_rhs (const gsl::not_null< LhsTensor * > lhs_tensor) const
 Assert that each instance of the LHS tensor in the RHS tensor expression uses the same generic index order that the LHS uses. More...
 
size_t get_rhs_tensor_component_size () const
 Get the size of a component from a Tensor in this expression's subtree of the RHS TensorExpression More...
 
constexpr std::array< size_t, op1_num_tensor_indicesget_op1_multi_index (const std::array< size_t, num_tensor_indices > &result_multi_index) const
 Return the first operand's multi-index given the outer product's multi-index. More...
 
constexpr std::array< size_t, op2_num_tensor_indicesget_op2_multi_index (const std::array< size_t, num_tensor_indices > &result_multi_index) const
 Return the second operand's multi-index given the outer product's multi-index. More...
 
decltype(auto) get (const std::array< size_t, num_tensor_indices > &result_multi_index) const
 Return the value of the component of the outer product tensor at a given multi-index. More...
 
template<typename ResultType >
decltype(auto) get_primary (const ResultType &result_component, const std::array< size_t, op1_num_tensor_indices > &op1_multi_index, const std::array< size_t, op2_num_tensor_indices > &op2_multi_index) const
 Return the product of the components at the given multi-indices of the left and right operands. More...
 
template<typename ResultType >
decltype(auto) get_primary (const ResultType &result_component, const std::array< size_t, num_tensor_indices > &result_multi_index) const
 Return the value of the component of the outer product tensor at a given multi-index. More...
 
template<typename ResultType >
void evaluate_primary_children (ResultType &result_component, const std::array< size_t, op1_num_tensor_indices > &op1_multi_index, const std::array< size_t, op2_num_tensor_indices > &op2_multi_index) const
 Evaluate the LHS Tensor's result component at this subtree by evaluating the two operand's subtrees separately and multiplying. More...
 
template<typename ResultType >
void evaluate_primary_subtree (ResultType &result_component, const std::array< size_t, num_tensor_indices > &result_multi_index) const
 Successively evaluate the LHS Tensor's result component at each leg in this expression's subtree. More...
 

Static Public Attributes

static constexpr auto num_tensor_indices = tmpl::size<index_list>::value
 The number of tensor indices in the result of the expression.
 
static constexpr auto op1_num_tensor_indices
 The number of tensor indices in the left operand expression. More...
 
static constexpr auto op2_num_tensor_indices
 The number of tensor indices in the right operand expression. More...
 
static constexpr size_t num_ops_left_child = T1::num_ops_subtree
 The number of arithmetic tensor operations done in the subtree for the left operand.
 
static constexpr size_t num_ops_right_child = T2::num_ops_subtree
 The number of arithmetic tensor operations done in the subtree for the right operand.
 
static constexpr size_t num_ops_subtree
 The total number of arithmetic tensor operations done in this expression's whole subtree. More...
 
static constexpr size_t height_relative_to_closest_tensor_leaf_in_subtree
 The height of this expression's node in the expression tree relative to the closest TensorAsExpression leaf in its subtree. More...
 
static constexpr bool is_primary_end = T1::is_primary_start
 If on the primary path, whether or not the expression is an ending point of a leg.
 
static constexpr size_t num_ops_to_evaluate_primary_left_child
 If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done in the subtree of the child along the primary path, given that we will have already computed the whole subtree at the next lowest leg's starting point. More...
 
static constexpr size_t num_ops_to_evaluate_primary_right_child
 If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done in the right operand's subtree. No splitting is currently done, so this is just num_ops_right_child. More...
 
static constexpr size_t num_ops_to_evaluate_primary_subtree
 If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done for this expression's subtree, given that we will have already computed the subtree at the next lowest leg's starting point. More...
 
static constexpr bool is_primary_start
 If on the primary path, whether or not the expression is a starting point of a leg. More...
 
static constexpr bool evaluate_children_separately
 When evaluating along a primary path, whether each operand's subtrees should be evaluated separately. Since DataVector expression runtime scales poorly with increased number of operations, evaluating the two expression subtrees separately like this is beneficial when at least one of the subtrees contains a large number of operations. More...
 
static constexpr bool primary_child_subtree_contains_primary_start
 If on the primary path, whether or not the expression's child along the primary path is a subtree that contains a starting point of a leg along the primary path. More...
 
static constexpr bool primary_subtree_contains_primary_start
 If on the primary path, whether or not this subtree contains a starting point of a leg along the primary path. More...
 

Member Function Documentation

◆ assert_lhs_tensorindices_same_in_rhs()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
template<typename LhsTensorIndices , typename LhsTensor >
void tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::assert_lhs_tensorindices_same_in_rhs ( const gsl::not_null< LhsTensor * >  lhs_tensor) const
inline

Assert that each instance of the LHS tensor in the RHS tensor expression uses the same generic index order that the LHS uses.

Template Parameters
LhsTensorIndicesthe list of generic TensorIndexs of the LHS result Tensor being computed
Parameters
lhs_tensorthe LHS result Tensor being computed

◆ evaluate_primary_children()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
template<typename ResultType >
void tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::evaluate_primary_children ( ResultType &  result_component,
const std::array< size_t, op1_num_tensor_indices > &  op1_multi_index,
const std::array< size_t, op2_num_tensor_indices > &  op2_multi_index 
) const
inline

Evaluate the LHS Tensor's result component at this subtree by evaluating the two operand's subtrees separately and multiplying.

Details

This function takes into account whether we have already computed part of the result component at a lower subtree. In recursively computing this product, the current result component will be substituted in for the most recent (highest) subtree below it that has already been evaluated.

The left and right operands' subtrees are evaluated successively with two separate assignments to the LHS result component. Since DataVector expression runtime scales poorly with increased number of operations, evaluating the two expression subtrees separately like this is beneficial when at least one of the subtrees contains a large number of operations. Instead of evaluating a larger expression with their combined total number of operations, we evaluate two smaller ones.

Parameters
result_componentthe LHS tensor component to evaluate
op1_multi_indexthe multi-index of the component of the first operand of the product to evaluate
op2_multi_indexthe multi-index of the component of the second operand of the product to evaluate

◆ evaluate_primary_subtree()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
template<typename ResultType >
void tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::evaluate_primary_subtree ( ResultType &  result_component,
const std::array< size_t, num_tensor_indices > &  result_multi_index 
) const
inline

Successively evaluate the LHS Tensor's result component at each leg in this expression's subtree.

Details

This function takes into account whether we have already computed part of the result component at a lower subtree. In recursively computing this product, the current result component will be substituted in for the most recent (highest) subtree below it that has already been evaluated.

Parameters
result_componentthe LHS tensor component to evaluate
result_multi_indexthe multi-index of the component of the outer product tensor to evaluate

◆ get()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
decltype(auto) tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get ( const std::array< size_t, num_tensor_indices > &  result_multi_index) const
inline

Return the value of the component of the outer product tensor at a given multi-index.

Details

This function takes the multi-index of some component of the resultant outer product to compute. The function first computes the multi-indices of the pair of components in the two operand expressions, then multiplies the values at these multi-indices to obtain the value of the resultant outer product component. For example, say we are evaluating \(L_abc = R_{b} * S_{ca}\). Let result_multi_index == {0, 1, 2}, which refers to the component \(L_{012}\), the component we wish to compute. This function will compute the multi-indices of the operands that correspond to \(R_{1}\) and \(S_{20}\), retrieve their values, and return their product.

Parameters
result_multi_indexthe multi-index of the component of the outer product tensor to retrieve

Returns: the value of the component at result_multi_index in the outer product tensor

◆ get_op1_multi_index()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr std::array< size_t, op1_num_tensor_indices > tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get_op1_multi_index ( const std::array< size_t, num_tensor_indices > &  result_multi_index) const
inlineconstexpr

Return the first operand's multi-index given the outer product's multi-index.

Parameters
result_multi_indexthe multi-index of the component of the outer product tensor

Returns: the first operand's multi-index

◆ get_op2_multi_index()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr std::array< size_t, op2_num_tensor_indices > tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get_op2_multi_index ( const std::array< size_t, num_tensor_indices > &  result_multi_index) const
inlineconstexpr

Return the second operand's multi-index given the outer product's multi-index.

Parameters
result_multi_indexthe multi-index of the component of the outer product tensor

Returns: the second operand's multi-index

◆ get_primary() [1/2]

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
template<typename ResultType >
decltype(auto) tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get_primary ( const ResultType &  result_component,
const std::array< size_t, num_tensor_indices > &  result_multi_index 
) const
inline

Return the value of the component of the outer product tensor at a given multi-index.

Details

This function differs from get in that it takes into account whether we have already computed part of the result component at a lower subtree. In recursively computing this product, the current result component will be substituted in for the most recent (highest) subtree below it that has already been evaluated.

Parameters
result_componentthe LHS tensor component to evaluate
result_multi_indexthe multi-index of the component of the outer product tensor to retrieve

Returns: the value of the component at result_multi_index in the outer product tensor

◆ get_primary() [2/2]

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
template<typename ResultType >
decltype(auto) tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get_primary ( const ResultType &  result_component,
const std::array< size_t, op1_num_tensor_indices > &  op1_multi_index,
const std::array< size_t, op2_num_tensor_indices > &  op2_multi_index 
) const
inline

Return the product of the components at the given multi-indices of the left and right operands.

Details

This function differs from get in that it takes into account whether we have already computed part of the result component at a lower subtree. In recursively computing this product, the current result component will be substituted in for the most recent (highest) subtree below it that has already been evaluated.

Parameters
result_componentthe LHS tensor component to evaluate
op1_multi_indexthe multi-index of the component of the first operand of the product to retrieve
op2_multi_indexthe multi-index of the component of the second operand of the product to retrieve

◆ get_rhs_tensor_component_size()

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::get_rhs_tensor_component_size ( ) const
inline

Get the size of a component from a Tensor in this expression's subtree of the RHS TensorExpression

Returns: the size of a component from a Tensor in this expression's subtree of the RHS TensorExpression

Member Data Documentation

◆ evaluate_children_separately

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr bool tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::evaluate_children_separately
staticconstexpr
Initial value:
=
detail::max_num_ops_in_sub_expression<type> or
detail::max_num_ops_in_sub_expression<type>)
static constexpr size_t num_ops_to_evaluate_primary_right_child
If on the primary path, this is the remaining number of arithmetic tensor operations that need to be ...
Definition: Product.hpp:144
static constexpr bool is_primary_start
If on the primary path, whether or not the expression is a starting point of a leg.
Definition: Product.hpp:155
static constexpr size_t num_ops_to_evaluate_primary_left_child
If on the primary path, this is the remaining number of arithmetic tensor operations that need to be ...
Definition: Product.hpp:139

When evaluating along a primary path, whether each operand's subtrees should be evaluated separately. Since DataVector expression runtime scales poorly with increased number of operations, evaluating the two expression subtrees separately like this is beneficial when at least one of the subtrees contains a large number of operations.

◆ height_relative_to_closest_tensor_leaf_in_subtree

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::height_relative_to_closest_tensor_leaf_in_subtree
staticconstexpr
Initial value:
=
T2::height_relative_to_closest_tensor_leaf_in_subtree <=
T1::height_relative_to_closest_tensor_leaf_in_subtree
? (T2::height_relative_to_closest_tensor_leaf_in_subtree !=
? T2::height_relative_to_closest_tensor_leaf_in_subtree + 1
: T2::height_relative_to_closest_tensor_leaf_in_subtree)
: T1::height_relative_to_closest_tensor_leaf_in_subtree + 1
T max(T... args)

The height of this expression's node in the expression tree relative to the closest TensorAsExpression leaf in its subtree.

◆ is_primary_start

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr bool tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::is_primary_start
staticconstexpr
Initial value:
=
detail::max_num_ops_in_sub_expression<type>
static constexpr size_t num_ops_to_evaluate_primary_subtree
If on the primary path, this is the remaining number of arithmetic tensor operations that need to be ...
Definition: Product.hpp:150

If on the primary path, whether or not the expression is a starting point of a leg.

◆ num_ops_subtree

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::num_ops_subtree
staticconstexpr
Initial value:
=
static constexpr size_t num_ops_left_child
The number of arithmetic tensor operations done in the subtree for the left operand.
Definition: Product.hpp:105
static constexpr size_t num_ops_right_child
The number of arithmetic tensor operations done in the subtree for the right operand.
Definition: Product.hpp:108

The total number of arithmetic tensor operations done in this expression's whole subtree.

◆ num_ops_to_evaluate_primary_left_child

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::num_ops_to_evaluate_primary_left_child
staticconstexpr
Initial value:
=
is_primary_end ? 0 : T1::num_ops_to_evaluate_primary_subtree
static constexpr bool is_primary_end
If on the primary path, whether or not the expression is an ending point of a leg.
Definition: Product.hpp:134

If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done in the subtree of the child along the primary path, given that we will have already computed the whole subtree at the next lowest leg's starting point.

◆ num_ops_to_evaluate_primary_right_child

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::num_ops_to_evaluate_primary_right_child
staticconstexpr
Initial value:

If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done in the right operand's subtree. No splitting is currently done, so this is just num_ops_right_child.

◆ num_ops_to_evaluate_primary_subtree

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr size_t tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::num_ops_to_evaluate_primary_subtree
staticconstexpr
Initial value:

If on the primary path, this is the remaining number of arithmetic tensor operations that need to be done for this expression's subtree, given that we will have already computed the subtree at the next lowest leg's starting point.

◆ op1_num_tensor_indices

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr auto tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::op1_num_tensor_indices
staticconstexpr
Initial value:
=
constexpr T & value(T &t)
Returns t.value() if t is a std::optional otherwise returns t.
Definition: OptionalHelpers.hpp:32

The number of tensor indices in the left operand expression.

◆ op2_num_tensor_indices

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr auto tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::op2_num_tensor_indices
staticconstexpr
Initial value:
=
static constexpr auto op1_num_tensor_indices
The number of tensor indices in the left operand expression.
Definition: Product.hpp:96
static constexpr auto num_tensor_indices
The number of tensor indices in the result of the expression.
Definition: Product.hpp:94

The number of tensor indices in the right operand expression.

◆ primary_child_subtree_contains_primary_start

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr bool tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::primary_child_subtree_contains_primary_start
staticconstexpr
Initial value:
=
T1::primary_subtree_contains_primary_start

If on the primary path, whether or not the expression's child along the primary path is a subtree that contains a starting point of a leg along the primary path.

◆ primary_subtree_contains_primary_start

template<typename T1 , typename T2 , template< typename... > class IndexList1, typename... Indices1, template< typename... > class IndexList2, typename... Indices2, template< typename... > class ArgsList1, typename... Args1, template< typename... > class ArgsList2, typename... Args2>
constexpr bool tenex::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::primary_subtree_contains_primary_start
staticconstexpr
Initial value:
=
static constexpr bool primary_child_subtree_contains_primary_start
If on the primary path, whether or not the expression's child along the primary path is a subtree tha...
Definition: Product.hpp:171

If on the primary path, whether or not this subtree contains a starting point of a leg along the primary path.


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