SpECTRE
v2024.12.16
|
Namespaces | |
namespace | tenex |
namespace | ti |
Contains definitions for the available TensorIndex s to use in a TensorExpression | |
Classes | |
struct | tenex::AddSub< T1, T2, ArgsList1, ArgsList2, Sign > |
Defines the tensor expression representing the addition or subtraction of two tensor expressions. More... | |
struct | tenex::TensorContract< T, X, Symm, IndexList, ArgsList, NumContractedIndices > |
struct | tenex::Divide< T1, T2, Args2 > |
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 | tenex::LhsTensorSymmAndIndices< RhsTensorIndexList, LhsTensorIndexList, RhsSymmetry, RhsTensorIndexTypeList, NumLhsIndices, NumRhsIndices, LhsIndexSequence > |
Determines and stores a LHS tensor's symmetry and index list from a RHS tensor expression and desired LHS index order. More... | |
struct | tenex::Negate< T > |
Defines the tensor expression representing the negation of a tensor expression. More... | |
struct | tenex::MarkAsNumberAsExpression |
Marks a class as being a NumberAsExpression<DataType> More... | |
struct | tenex::NumberAsExpression< DataType > |
Defines an expression representing a number. More... | |
struct | tenex::OuterProduct< T1, T2, IndexList1, IndexList2, ArgsList1, ArgsList2 > |
Defines the tensor expression representing the outer product of two tensor expressions. More... | |
struct | tenex::SquareRoot< T, Args > |
Defines the tensor expression representing the square root of a tensor expression that evaluates to a rank 0 tensor. More... | |
struct | tenex::TensorAsExpression< T, ArgsList > |
Defines an expression representing a Tensor. More... | |
struct | Expression |
Marks a class as being a TensorExpression. More... | |
struct | TensorExpression< Derived, DataType, Symm, tmpl::list< Indices... >, ArgsList< Args... > > |
The base class all tensor expression implementations derive from. More... | |
struct | TensorIndex< I, > |
Represents the geeric indices in a TensorExpression. More... | |
struct | tt::is_tensor_index< T > |
Check if a type T is a TensorIndex used in TensorExpressions. More... | |
struct | tenex::tensorindex_list_is_valid< TensorIndexList > |
Determine whether or not a given list of TensorIndexs is valid to be used with a tensor. More... | |
struct | tt::is_time_index< T > |
Check if a type T is a TensorIndex representing a concrete time index. More... | |
struct | MarkAsVectorImpl |
Marks a class as being a VectorImpl More... | |
Typedefs | |
template<typename TensorIndexList1 , typename TensorIndexList2 > | |
using | tenex::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... | |
template<auto &... TensorIndices> | |
using | make_tensorindex_list = typename tenex::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<typename T1 , typename T2 , typename... Args2> | |
auto | operator/ (const TensorExpression< T1, typename T1::type, typename T1::symmetry, typename T1::index_list, typename T1::args_list > &t1, const TensorExpression< T2, typename T2::type, typename T2::symmetry, typename T2::index_list, tmpl::list< Args2... > > &t2) |
Returns the tensor expression representing the quotient of one tensor expression over another tensor expression that evaluates to a rank 0 tensor. More... | |
template<auto &... LhsTensorIndices, typename LhsDataType , typename LhsSymmetry , typename LhsIndexList , typename Derived , typename RhsDataType , typename RhsSymmetry , typename RhsIndexList , typename... RhsTensorIndices> | |
void | tenex::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 | tenex::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 | tenex::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<typename T > | |
auto | operator- (const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t) |
Returns the tensor expression representing the negation of a tensor expression. 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 Symm , typename IndexList , typename... Args> | |
auto | sqrt (const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &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 , typename Symm , typename IndexList , typename... Args, typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator+ (const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t, const N number) |
Returns the tensor expression representing the sum of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator+ (const N number, const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t) |
Returns the tensor expression representing the sum of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N > | |
auto | operator+ (const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t, const std::complex< N > &number) |
Returns the tensor expression representing the sum of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N > | |
auto | operator+ (const std::complex< N > &number, const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t) |
Returns the tensor expression representing the sum of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator- (const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t, const N number) |
Returns the tensor expression representing the difference of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator- (const N number, const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t) |
Returns the tensor expression representing the difference of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N > | |
auto | operator- (const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t, const std::complex< N > &number) |
Returns the tensor expression representing the difference of a tensor expression and a number. More... | |
template<typename T , typename X , typename Symm , typename IndexList , typename... Args, typename N > | |
auto | operator- (const std::complex< N > &number, const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t) |
Returns the tensor expression representing the difference of a tensor expression and a number. More... | |
template<typename T , typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator/ (const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t, const N number) |
Returns the tensor expression representing the quotient of a tensor expression over a number. More... | |
template<typename T , typename N > | |
auto | operator/ (const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t, const std::complex< N > &number) |
Returns the tensor expression representing the quotient of a tensor expression over a number. More... | |
template<typename T , typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator/ (const N number, const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t) |
Returns the tensor expression representing the quotient of a number over a tensor expression that evaluates to a rank 0 tensor. More... | |
template<typename T , typename N > | |
auto | operator/ (const std::complex< N > &number, const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t) |
Returns the tensor expression representing the quotient of a number over a tensor expression that evaluates to a rank 0 tensor. More... | |
template<auto &... LhsTensorIndices, typename X , typename LhsSymmetry , typename LhsIndexList , typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
void | tenex::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 | tenex::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... | |
template<typename T , typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator* (const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t, const N number) |
Returns the tensor expression representing the product of a tensor expression and a number. More... | |
template<typename T , typename N , Requires< std::is_arithmetic_v< N > > = nullptr> | |
auto | operator* (const N number, const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t) |
Returns the tensor expression representing the product of a tensor expression and a number. More... | |
template<typename T , typename N > | |
auto | operator* (const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t, const std::complex< N > &number) |
Returns the tensor expression representing the product of a tensor expression and a number. More... | |
template<typename T , typename N > | |
auto | operator* (const std::complex< N > &number, const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > &t) |
Returns the tensor expression representing the product of a tensor expression and a number. 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 tenex::generic_indices_at_same_positions = implementation defined |
Determine whether or not two lists of TensorIndexs contain the same generic indices at the same positions.
TensorIndexList1 | the first TensorIndex list |
TensorIndexList2 | the second TensorIndex list |
using make_tensorindex_list = typename tenex::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 |
void tenex::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.
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
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.
The LHS Tensor
cannot be part of the RHS expression, e.g. evaluate(make_not_null(&L), L() + R());
, because the LHS Tensor
will generally not be computed correctly when the RHS TensorExpression
is split up and the LHS tensor components are computed by accumulating the result of subtrees (see the section on splitting in the documentation for the TensorExpression
class). If you need to use the LHS Tensor
on the RHS, use tenex::update
instead.
Given Tensor
s R
, S
, T
, G
, and H
, we can compute the LHS tensor
LhsTensorIndices
must be passed by reference because non-type template parameters cannot be class types until C++20.LhsTensorIndices | the TensorIndex s 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 |
void tenex::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.
Example usage:
Tensor
passed in must already be sized because there is no way to infer component size from the RHSLhsTensorIndices
must be passed by reference because non-type template parameters cannot be class types until C++20.LhsTensorIndices | the TensorIndex s 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_value | the RHS value to assign |
void tenex::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.
Example usage:
Tensor
passed in must already be sized because there is no way to infer component size from the RHSLhsTensorIndices
must be passed by reference because non-type template parameters cannot be class types until C++20.LhsTensorIndices | the TensorIndex s 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_value | the RHS value to assign |
auto tenex::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.
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
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 tenex::evaluate
overload that takes an empty LHS Tensor as its first argument.
Given Tensor
s R
, S
, T
, G
, and H
, we can compute the LHS tensor
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 N | number, |
const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t | ||
) |
Returns the tensor expression representing the product of a tensor expression and a number.
t | the tensor expression operand of the product |
number | the numeric operand of the product |
Returns: the tensor expression representing the product of the tensor expression and the number
auto operator* | ( | const std::complex< N > & | number, |
const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t | ||
) |
Returns the tensor expression representing the product of a tensor expression and a number.
t | the tensor expression operand of the product |
number | the numeric operand of the product |
Returns: the tensor expression representing the product of the tensor expression and the number
auto operator* | ( | const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t, |
const N | number | ||
) |
Returns the tensor expression representing the product of a tensor expression and a number.
t | the tensor expression operand of the product |
number | the numeric operand of the product |
Returns: the tensor expression representing the product of the tensor expression and the number
auto operator* | ( | const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t, |
const std::complex< N > & | number | ||
) |
Returns the tensor expression representing the product of a tensor expression and a number.
t | the tensor expression operand of the product |
number | the numeric operand of the product |
Returns: the tensor expression representing the product of the tensor expression and the number
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 N | number, |
const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t | ||
) |
Returns the tensor expression representing the sum of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the sum |
number | the numeric operand of the sum |
Returns: the tensor expression representing the sum of the tensor expression and the number
auto operator+ | ( | const std::complex< N > & | number, |
const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t | ||
) |
Returns the tensor expression representing the sum of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the sum |
number | the numeric operand of the sum |
Returns: the tensor expression representing the sum of the tensor expression and the number
auto operator+ | ( | const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t, |
const N | number | ||
) |
Returns the tensor expression representing the sum of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the sum |
number | the numeric operand of the sum |
Returns: the tensor expression representing the sum of the tensor expression and the number
auto operator+ | ( | const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t, |
const std::complex< N > & | number | ||
) |
Returns the tensor expression representing the sum of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the sum |
number | the numeric operand of the sum |
Returns: the tensor expression representing the sum of the tensor expression and the number
auto operator- | ( | const N | number, |
const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t | ||
) |
Returns the tensor expression representing the difference of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the difference |
number | the numeric operand of the difference |
Returns: the tensor expression representing the difference of the tensor expression and the number
auto operator- | ( | const std::complex< N > & | number, |
const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t | ||
) |
Returns the tensor expression representing the difference of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the difference |
number | the numeric operand of the difference |
Returns: the tensor expression representing the difference of the tensor expression and the number
auto operator- | ( | const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t | ) |
Returns the tensor expression representing the negation of a tensor expression.
t | the tensor expression |
Returns: the tensor expression representing the negation of t
auto operator- | ( | const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t, |
const N | number | ||
) |
Returns the tensor expression representing the difference of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the difference |
number | the numeric operand of the difference |
Returns: the tensor expression representing the difference of the tensor expression and the number
auto operator- | ( | const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | t, |
const std::complex< N > & | number | ||
) |
Returns the tensor expression representing the difference of a tensor expression and a number.
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))
R(ti::t, ti::t)
t | the tensor expression operand of the difference |
number | the numeric operand of the difference |
Returns: the tensor expression representing the difference of the tensor expression and the number
auto operator/ | ( | const N | number, |
const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t | ||
) |
Returns the tensor expression representing the quotient of a number over a tensor expression that evaluates to a rank 0 tensor.
number | the numeric numerator of the quotient |
t | the tensor expression denominator of the quotient |
Returns: the tensor expression representing the quotient of the number over the tensor expression
auto operator/ | ( | const std::complex< N > & | number, |
const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t | ||
) |
Returns the tensor expression representing the quotient of a number over a tensor expression that evaluates to a rank 0 tensor.
number | the numeric numerator of the quotient |
t | the tensor expression denominator of the quotient |
Returns: the tensor expression representing the quotient of the number over the tensor expression
auto operator/ | ( | const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t, |
const N | number | ||
) |
Returns the tensor expression representing the quotient of a tensor expression over a number.
t * (1.0 / number)
t | the tensor expression operand of the quotient |
number | the numeric operand of the quotient |
Returns: the tensor expression representing the quotient of the tensor expression over the number
auto operator/ | ( | const TensorExpression< T, typename T::type, typename T::symmetry, typename T::index_list, typename T::args_list > & | t, |
const std::complex< N > & | number | ||
) |
Returns the tensor expression representing the quotient of a tensor expression over a number.
t * (1.0 / number)
t | the tensor expression operand of the quotient |
number | the numeric operand of the quotient |
Returns: the tensor expression representing the quotient of the tensor expression over the number
auto operator/ | ( | const TensorExpression< T1, typename T1::type, typename T1::symmetry, typename T1::index_list, typename T1::args_list > & | t1, |
const TensorExpression< T2, typename T2::type, typename T2::symmetry, typename T2::index_list, tmpl::list< Args2... > > & | t2 | ||
) |
Returns the tensor expression representing the quotient of one tensor expression over another tensor expression that evaluates to a rank 0 tensor.
t2
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 t2
could take:
R()
R(ti::A, ti::a)
(R(ti::A, ti::B) * S(ti::a, ti::b))
R(ti::t, ti::t) + 1.0
t1 | the tensor expression numerator |
t2 | the rank 0 tensor expression denominator |
auto sqrt | ( | const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > & | 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))
R(ti::t, ti::t) + 1.0
t | the tensor expression of which to take the square root |
void tenex::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.
See documentation for tenex::evaluate
for basic functionality.
tenex::update
differs from tenex::evaluate
in that tenex::update
should be used when some LHS Tensor
has been partially computed, and now we would like to update it with a RHS expression that contains it. In other words, this should be used when we would like to emulate assignment operations like LHS +=
, LHS -=
, LHS *=
, etc.
One important difference to note with tenex::update
is that it cannot split up the RHS expression and evaluate subtrees, while tenex::evaluate
can (see TensorExpression
documentation). From benchmarking, it was found that the runtime of DataVector
expressions scales poorly as we increase the number of operations. For this reason, when the data type held by the tensors in the expression is DataVector
, it's best to avoid passing RHS expressions with a large number of operations (e.g. an inner product that sums over many terms).
In implementing a large equation with many operations, we can manually break up the equation and evaluate different subexpressions at a time by making one initial call to tenex::evaluate
followed by any number of calls to tenex::update
that use the LHS tensor in the RHS expression and will compute the rest of the equation:
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 |