|
SpECTRE
2021.08.02
|
Namespaces | |
| namespace | TensorExpressions |
Typedefs | |
| template<auto &... TensorIndices> | |
| using | make_tensorindex_list = typename TensorIndex_detail::make_tensorindex_list_impl< TensorIndices... >::type |
| Creates a TensorIndex type list from a list of TensorIndex objects. More... | |
Functions | |
| template<typename T1 , typename T2 , typename X1 , typename X2 , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 > | |
| auto | operator+ (const TensorExpression< T1, X1, Symm1, IndexList1, Args1 > &t1, const TensorExpression< T2, X2, Symm2, IndexList2, Args2 > &t2) |
| template<typename T1 , typename T2 , typename X1 , typename X2 , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 > | |
| auto | operator- (const TensorExpression< T1, X1, Symm1, IndexList1, Args1 > &t1, const TensorExpression< T2, X2, Symm2, IndexList2, Args2 > &t2) |
| template<auto &... LhsTensorIndices, typename X , typename LhsSymmetry , typename LhsIndexList , typename Derived , typename RhsSymmetry , typename RhsIndexList , typename... RhsTensorIndices> | |
| void | TensorExpressions::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 | TensorExpressions::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<typename... LhsTensorIndices> | |
| static constexpr std::array< size_t, sizeof...(OperandTensorIndices)> | TensorExpressions::OuterProduct< T1, T2, IndexList1< Indices1... >, IndexList2< Indices2... >, ArgsList1< Args1... >, ArgsList2< Args2... > >::GetOpTensorMultiIndex< tmpl::list< OperandTensorIndices... > >::apply (const std::array< size_t, num_tensor_indices > &lhs_tensor_multi_index) |
| Computes the multi-index of a component of an operand of the outer product from the multi-index of a component of the outer product. More... | |
| template<typename T1 , typename T2 , typename ArgsList1 , typename ArgsList2 > | |
| auto | operator* (const TensorExpression< T1, typename T1::type, typename T1::symmetry, typename T1::index_list, ArgsList1 > &t1, const TensorExpression< T2, typename T2::type, typename T2::symmetry, typename T2::index_list, ArgsList2 > &t2) |
| Returns the tensor expression representing the product of two tensor expressions. More... | |
| template<typename T , typename X , typename ArgsList > | |
| auto | operator/ (const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > &t, const double number) |
Returns the tensor expression representing the quotient of a tensor expression and a double More... | |
| template<typename T > | |
| auto | sqrt (const TensorExpression< T, typename T::type, tmpl::list<>, tmpl::list<>, tmpl::list<> > &t) |
| Returns the tensor expression representing the square root of a tensor expression that evaluates to a rank 0 tensor. More... | |
| template<typename T , typename X > | |
| auto | operator+ (const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > &t, const double number) |
Returns the tensor expression representing the sum of a tensor expression and a double More... | |
| template<typename T , typename X > | |
| auto | operator+ (const double number, const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > &t) |
Returns the tensor expression representing the sum of a tensor expression and a double More... | |
| template<typename T , typename X > | |
| auto | operator- (const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > &t, const double number) |
Returns the tensor expression representing the difference of a tensor expression and a double More... | |
| template<typename T , typename X > | |
| auto | operator- (const double number, const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > &t) |
Returns the tensor expression representing the difference of a tensor expression and a double More... | |
| template<typename T , typename X , typename ArgsList > | |
| auto | operator* (const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > &t, const double number) |
Returns the tensor expression representing the product of a tensor expression and a double More... | |
| template<typename T , typename X , typename ArgsList > | |
| auto | operator* (const double number, const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > &t) |
Returns the tensor expression representing the product of a tensor expression and a double More... | |
Tensor Expressions allow writing expressions of tensors in a way similar to what is used with pen and paper.
Tensor expressions are implemented using (smart) expression templates. This allows a domain specific language making expressions such as
possible.
| using make_tensorindex_list = typename TensorIndex_detail::make_tensorindex_list_impl< TensorIndices...>::type |
Creates a TensorIndex type list from a list of TensorIndex objects.
| TensorIndices | list of generic index objects, e.g. ti_a, ti_b |
|
inlinestaticconstexpr |
Computes the multi-index of a component of an operand of the outer product from the multi-index of a component of the outer product.
Example: Let's say we are evaluating \(L_abc = R_{b} * S_{ca}\). Let ti_a_t denote the type of ti_a, and apply the same convention for other generic indices. Let LhsTensorIndices == ti_a_t, ti_b_t, ti_c_t, and OperandTensorIndices is either ti_b_t or ti_c_t, ti_a_t. Let lhs_tensor_multi_index == [0, 1, 2], representing the multi-index of the component \(L_{012}\). If OperandTensorIndices == ti_c_t, ti_a_t, this function will return the tensor multi-index representing the component \(S_{20}\), which is [2, 0].
| LhsTensorIndices | the TensorIndexs of the outer product tensor |
| lhs_tensor_multi_index | the tensor multi-index of a component in the outer product tensor |
Returns: the tensor multi-index of an operand of the outer product
| void TensorExpressions::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.
Uses the right hand side (RHS) TensorExpression's index ordering (RhsTE::args_list) and the desired left hand side (LHS) tensor's index ordering (LhsTensorIndices) to fill the provided LHS Tensor with that LHS index ordering. This can carry out the evaluation of a RHS tensor expression to a LHS tensor with the same index ordering, such as \(L_{ab} = R_{ab}\), or different ordering, such as \(L_{ba} = R_{ab}\).
The symmetry of the provided LHS Tensor need not match the symmetry determined from evaluating the RHS TensorExpression according to its order of operations. This allows one to specify LHS symmetries (via lhs_tensor) that may not be preserved by the RHS expression's order of operations, which depends on how the expression is written and implemented.
Given two rank 2 Tensors R and S with index order (a, b), add them together and fill the provided resultant LHS Tensor L with index order (b, a):
This represents evaluating: \(L_{ba} = R_{ab} + S_{ab}\)
Note: LhsTensorIndices must be passed by reference because non-type template parameters cannot be class types until C++20.
| LhsTensorIndices | the TensorIndexs of the Tensor on the LHS of the tensor expression, e.g. ti_a, ti_b, ti_c |
| lhs_tensor | pointer to the resultant LHS Tensor to fill |
| rhs_tensorexpression | the RHS TensorExpression to be evaluated |
| auto TensorExpressions::evaluate | ( | const RhsTE & | rhs_tensorexpression | ) |
Evaluate a RHS tensor expression to a tensor with the LHS index order set in the template parameters.
Uses the right hand side (RHS) TensorExpression's index ordering (RhsTE::args_list) and the desired left hand side (LHS) tensor's index ordering (LhsTensorIndices) to construct a LHS Tensor with that LHS index ordering. This can carry out the evaluation of a RHS tensor expression to a LHS tensor with the same index ordering, such as \(L_{ab} = R_{ab}\), or different ordering, such as \(L_{ba} = R_{ab}\).
The symmetry of the returned LHS Tensor depends on the order of operations in the RHS TensorExpression, i.e. how the expression is written. If you would like to specify the symmetry of the LHS Tensor instead of it being determined by the order of operations in the RHS expression, please use the other evaluate overload that takes an empty LHS Tensor as its first argument.
Given two rank 2 Tensors R and S with index order (a, b), add them together and generate the resultant LHS Tensor L with index order (b, a):
Returns: Tensor
This represents evaluating: \(L_{ba} = R_{ab} + S_{ab}\)
Note: If a generic spatial index is used for a spacetime index in the RHS tensor, its corresponding index in the LHS tensor type will be a spatial index with the same valence, frame, and number of spatial dimensions.
Note: LhsTensorIndices must be passed by reference because non-type template parameters cannot be class types until C++20.
| LhsTensorIndices | the TensorIndexs of the Tensor on the LHS of the tensor expression, e.g. ti_a, ti_b, ti_c |
| rhs_tensorexpression | the RHS TensorExpression to be evaluated |
Returns: the resultant LHS Tensor with index order specified by LhsTensorIndices
| auto operator* | ( | const double | number, |
| const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > & | t | ||
| ) |
Returns the tensor expression representing the product of a tensor expression and a double
| T | the derived TensorExpression type of the tensor expression operand of the product |
| X | the type of data stored in the tensor expression operand of the product |
| ArgsList | the TensorIndexs of the tensor expression operand of the product |
| t | the tensor expression operand of the product |
| number | the double operand of the product |
Returns: the tensor expression representing the product of a tensor expression and a double
| auto operator* | ( | const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > & | t, |
| const double | number | ||
| ) |
Returns the tensor expression representing the product of a tensor expression and a double
| T | the derived TensorExpression type of the tensor expression operand of the product |
| X | the type of data stored in the tensor expression operand of the product |
| ArgsList | the TensorIndexs of the tensor expression operand of the product |
| t | the tensor expression operand of the product |
| number | the double operand of the product |
Returns: the tensor expression representing the product of a tensor expression and a double
| auto operator* | ( | const TensorExpression< T1, typename T1::type, typename T1::symmetry, typename T1::index_list, ArgsList1 > & | t1, |
| const TensorExpression< T2, typename T2::type, typename T2::symmetry, typename T2::index_list, ArgsList2 > & | t2 | ||
| ) |
Returns the tensor expression representing the product of two tensor expressions.
If the two operands have N pairs of indices that need to be contracted, the returned expression will be an OuterProduct expression nested inside N TensorContract expressions. This represents computing the inner product of the outer product of the two operands. If the operands do not have any indices to be contracted, the returned expression will be an OuterProduct.
The two arguments are expressions that contain the two operands of the product, where the types of the operands are T1 and T2.
| T1 | the derived TensorExpression type of the first operand of the product |
| T2 | the derived TensorExpression type of the second operand of the product |
| ArgsList1 | the TensorIndexs of the first operand |
| ArgsList2 | the TensorIndexs of the second operand |
| t1 | first operand expression of the product |
| t2 | the second operand expression of the product |
Returns: the tensor expression representing the product of two tensor expressions
| auto operator+ | ( | const double | number, |
| const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > & | t | ||
| ) |
Returns the tensor expression representing the sum of a tensor expression and a double
The tensor expression operand must represent an expression that, when evaluated, would be a rank 0 tensor. For example, if R and S are Tensors, here is a non-exhaustive list of some of the acceptable forms that the tensor expression operand could take:
R()R(ti_A, ti_a)(R(ti_A, ti_B) * S(ti_a, ti_b))| T | the derived TensorExpression type of the tensor expression operand of the sum |
| X | the type of data stored in the tensor expression operand of the sum |
| t | the tensor expression operand of the sum |
| number | the double operand of the sum |
Returns: the tensor expression representing the sum of a tensor expression and a double
| auto operator+ | ( | const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > & | t, |
| const double | number | ||
| ) |
Returns the tensor expression representing the sum of a tensor expression and a double
The tensor expression operand must represent an expression that, when evaluated, would be a rank 0 tensor. For example, if R and S are Tensors, here is a non-exhaustive list of some of the acceptable forms that the tensor expression operand could take:
R()R(ti_A, ti_a)(R(ti_A, ti_B) * S(ti_a, ti_b))| T | the derived TensorExpression type of the tensor expression operand of the sum |
| X | the type of data stored in the tensor expression operand of the sum |
| t | the tensor expression operand of the sum |
| number | the double operand of the sum |
Returns: the tensor expression representing the sum of a tensor expression and a double
| auto operator- | ( | const double | number, |
| const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > & | t | ||
| ) |
Returns the tensor expression representing the difference of a tensor expression and a double
The tensor expression operand must represent an expression that, when evaluated, would be a rank 0 tensor. For example, if R and S are Tensors, here is a non-exhaustive list of some of the acceptable forms that the tensor expression operand could take:
R()R(ti_A, ti_a)(R(ti_A, ti_B) * S(ti_a, ti_b))| T | the derived TensorExpression type of the tensor expression operand of the difference |
| X | the type of data stored in the tensor expression operand of the difference |
| t | the tensor expression operand of the difference |
| number | the double operand of the difference |
Returns: the tensor expression representing the difference of a tensor expression and a double
| auto operator- | ( | const TensorExpression< T, X, tmpl::list<>, tmpl::list<>, tmpl::list<> > & | t, |
| const double | number | ||
| ) |
Returns the tensor expression representing the difference of a tensor expression and a double
The tensor expression operand must represent an expression that, when evaluated, would be a rank 0 tensor. For example, if R and S are Tensors, here is a non-exhaustive list of some of the acceptable forms that the tensor expression operand could take:
R()R(ti_A, ti_a)(R(ti_A, ti_B) * S(ti_a, ti_b))| T | the derived TensorExpression type of the tensor expression operand of the difference |
| X | the type of data stored in the tensor expression operand of the difference |
| t | the tensor expression operand of the difference |
| number | the double operand of the difference |
Returns: the tensor expression representing the difference of a tensor expression and a double
| auto operator/ | ( | const TensorExpression< T, X, typename T::symmetry, typename T::index_list, ArgsList > & | t, |
| const double | number | ||
| ) |
Returns the tensor expression representing the quotient of a tensor expression and a double
t * (1.0 / number)| T | the derived TensorExpression type of the tensor expression operand of the quotient |
| X | the type of data stored in the tensor expression operand of the quotient |
| ArgsList | the TensorIndexs of the tensor expression operand of the quotient |
| t | the tensor expression operand of the quotient |
| number | the double operand of the quotient |
Returns: the tensor expression representing the quotient of a tensor expression and a double
| auto sqrt | ( | const TensorExpression< T, typename T::type, tmpl::list<>, tmpl::list<>, tmpl::list<> > & | t | ) |
Returns the tensor expression representing the square root of a tensor expression that evaluates to a rank 0 tensor.
t must be an expression that, when evaluated, would be a rank 0 tensor. For example, if R and S are Tensors, here is a non-exhaustive list of some of the acceptable forms that t could take:
R()R(ti_A, ti_a)(R(ti_A, ti_B) * S(ti_a, ti_b))| t | the type of the tensor expression of which to take the square root |