Evaluate.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines function TensorExpressions::evaluate(TensorExpression)
6 
7 #pragma once
8 
11 #include "Utilities/Requires.hpp"
12 
13 namespace TensorExpressions {
14 
15 /*!
16  * \ingroup TensorExpressionsGroup
17  * \brief Evaluate a Tensor Expression with LHS indices set in the template
18  * parameters
19  *
20  * @tparam LhsIndices the indices on the left hand side of the tensor expression
21  * @return Tensor<typename T::type, typename T::symmetry, typename
22  * T::index_list>
23  */
24 template <typename... LhsIndices, typename T,
26 auto evaluate(const T& te) {
27  static_assert(
28  sizeof...(LhsIndices) == tmpl::size<typename T::args_list>::value,
29  "Must have the same number of indices on the LHS and RHS of a tensor "
30  "equation.");
31  using rhs = tmpl::remove_duplicates<typename T::args_list>;
32  static_assert(
33  tmpl::equal_members<tmpl::list<LhsIndices...>, rhs>::value,
34  "All indices on the LHS of a Tensor Expression (that is, those specified "
35  "in evaluate<Indices::...>) must be present on the RHS of the expression "
36  "as well.");
37  return Tensor<typename T::type, typename T::symmetry, typename T::index_list>(
38  te, tmpl::list<LhsIndices...>{});
39 }
40 
41 } // namespace TensorExpressions
Defines the type alias Requires.
Defines class.
Definition: AddSubtract.hpp:28
Defines classes for Tensor.
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t ...
Definition: Requires.hpp:67
auto evaluate(const T &te)
Evaluate a Tensor Expression with LHS indices set in the template parameters.
Definition: Evaluate.hpp:26