Namespaces | Classes | Typedefs | Functions
Tensor Expressions

Namespaces

 TensorExpressions
 

Classes

struct  TensorExpressions::TensorContract< Index1, Index2, T, X, Symm, IndexList, ArgsList >
 
struct  TensorExpressions::Product< T1, T2, ArgsList1, ArgsList2 >
 
struct  TensorIndex< I >
 Represents the indices in a TensorExpression. More...
 
struct  Expression
 Marks a class as being a TensorExpression. More...
 
struct  TensorExpression< Derived, DataType, Symm, IndexList, ArgsList< Args... > >
 The base class all tensor expression implementations derive from. More...
 

Typedefs

template<template< typename > class TE, typename ReplacedArgList , typename I , typename TotalContracted >
using TensorExpressions::fully_contracted = detail::fully_contract_helper< TE, ReplacedArgList, I, TotalContracted >
 Represents a fully contracted Tensor.
 
template<typename T >
using next_tensor_index = TensorIndex< T::value+1 >
 Given an TensorIndex<size_t> return TensorIndex<size_t + 1> More...
 
template<typename A , typename B >
using plus_tensor_index = TensorIndex< A::value+B::value >
 Metafunction to return the sum of two TensorIndex's.
 
template<typename Lhs , typename Rhs >
using rhs_elements_in_lhs = tmpl::fold< Rhs, tmpl::list<>, detail::rhs_elements_in_lhs_helper< tmpl::_state, tmpl::_element, tmpl::pin< Lhs > >>
 Returns a list of all the elements in the typelist Rhs that are also in the typelist Lhs. More...
 
template<typename Rhs , typename Lhs , typename RhsOnyWithLhs >
using generate_transformation = tmpl::enumerated_fold< Rhs, tmpl::list<>, detail::generate_transformation_impl< tmpl::_state, tmpl::_element, tmpl::_3, tmpl::pin< Lhs >, tmpl::pin< Rhs >, tmpl::pin< RhsOnyWithLhs > >>
 Generate transformation to account for index order difference in RHS and LHS. More...
 
template<typename List >
using repeated = tmpl::fold< List, tmpl::list<>, detail::repeated_helper< tmpl::pin< List >, tmpl::_state, tmpl::_element > >
 
template<typename List , typename ReplaceList >
using replace_indices = typename detail::replace_indices_impl< List, ReplaceList, 0 >::type
 

Functions

template<typename T1 , typename T2 , typename X , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 >
auto operator+ (const TensorExpression< T1, X, Symm1, IndexList1, Args1 > &t1, const TensorExpression< T2, X, Symm2, IndexList2, Args2 > &t2)
 
template<typename T1 , typename T2 , typename X , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 >
auto operator- (const TensorExpression< T1, X, Symm1, IndexList1, Args1 > &t1, const TensorExpression< T2, X, Symm2, IndexList2, Args2 > &t2)
 
template<int Index1, int Index2, typename T , typename X , typename Symm , typename IndexList , typename Args >
auto TensorExpressions::contract (const TensorExpression< T, X, Symm, IndexList, Args > &t)
 
template<typename... LhsIndices, typename T , Requires< std::is_base_of< Expression, T >::value > = nullptr>
auto TensorExpressions::evaluate (const T &te)
 Evaluate a Tensor Expression with LHS indices set in the template parameters. More...
 
template<typename T1 , typename T2 , typename X , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 >
auto operator* (const TensorExpression< T1, X, Symm1, IndexList1, Args1 > &t1, const TensorExpression< T2, X, Symm2, IndexList2, Args2 > &t2)
 
TensorIndex< 0 > ti_a
 The available TensorIndex's to use in a TensorExpression. More...
 

Detailed Description

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

auto T = evaluate<Indices::_a_t, Indices::_b_t>(F(Indices::_b,
Indices::_a));

possible.

Typedef Documentation

◆ generate_transformation

template<typename Rhs , typename Lhs , typename RhsOnyWithLhs >
using generate_transformation = tmpl::enumerated_fold< Rhs, tmpl::list<>, detail::generate_transformation_impl<tmpl::_state, tmpl::_element, tmpl::_3, tmpl::pin<Lhs>, tmpl::pin<Rhs>, tmpl::pin<RhsOnyWithLhs> >>

Generate transformation to account for index order difference in RHS and LHS.

Details

Generates the transformation \(\mathcal{T}\) that rearranges the Tensor index array to account for index order differences between the LHS and RHS of the tensor expression.

Usage

For typelists Rhs, Lhs and RhsOnyWithLhs, where RhsOnlyWithLhs is the result of the metafunction rhs_elements_in_lhs,

Returns: typelist

◆ next_tensor_index

template<typename T >
using next_tensor_index = TensorIndex<T::value + 1>

Given an TensorIndex<size_t> return TensorIndex<size_t + 1>

Template Parameters
Tthe args to increment

◆ repeated

template<typename List >
using repeated = tmpl::fold< List, tmpl::list<>, detail::repeated_helper<tmpl::pin<List>, tmpl::_state, tmpl::_element> >

Returns a list of all the types that occurred more than once in List.

◆ rhs_elements_in_lhs

template<typename Lhs , typename Rhs >
using rhs_elements_in_lhs = tmpl::fold<Rhs, tmpl::list<>, detail::rhs_elements_in_lhs_helper<tmpl::_state, tmpl::_element, tmpl::pin<Lhs> >>

Returns a list of all the elements in the typelist Rhs that are also in the typelist Lhs.

Details

Given two typelists Lhs and Rhs, returns a typelist of all the elements in Rhs that are also in Lhs in the same order that they are in the Rhs.

Usage

For typelists List1 and List2,

Returns: typelist

Semantics: If Lhs = tmpl::list<A, B, C, D> and Rhs = tmpl::list<B, E, A>, then

result = tmpl::list<B, A>;

Function Documentation

◆ evaluate()

template<typename... LhsIndices, typename T , Requires< std::is_base_of< Expression, T >::value > = nullptr>
auto TensorExpressions::evaluate ( const T &  te)

Evaluate a Tensor Expression with LHS indices set in the template parameters.

Template Parameters
LhsIndicesthe indices on the left hand side of the tensor expression

Returns: Tensor<typename T::type, typename T::symmetry, typename T::index_list>

◆ operator*()

template<typename T1 , typename T2 , typename X , typename Symm1 , typename Symm2 , typename IndexList1 , typename IndexList2 , typename Args1 , typename Args2 >
auto operator* ( const TensorExpression< T1, X, Symm1, IndexList1, Args1 > &  t1,
const TensorExpression< T2, X, Symm2, IndexList2, Args2 > &  t2 
)
Template Parameters
T1
T2
X
Symm1
Symm2
IndexList1
IndexList2
Args1
Args2
Parameters
t1
t2

Returns:

Variable Documentation

◆ ti_a

TensorIndex<0> ti_a

The available TensorIndex's to use in a TensorExpression.

Available tensor indices to use in a Tensor Expression.

auto Gll = TensorExpressions::evaluate<ti_a_t, ti_b_t>(All(ti_a, ti_b) +
Hll(ti_a, ti_b));
auto Gll2 = TensorExpressions::evaluate<ti_a_t, ti_b_t>(All(ti_a, ti_b) +
Hll(ti_b, ti_a));
auto Gll3 = TensorExpressions::evaluate<ti_a_t, ti_b_t>(
All(ti_a, ti_b) + Hll(ti_b, ti_a) + All(ti_b, ti_a) - Hll(ti_b, ti_a));
Note
Because these are never actually used as objects and only for type manipulation they do not need to be instantiated anywhere.