1#ifndef __DUNE_ACFEM_TENSOR_OPTIMIZATION_SUMOPERANDTUPLE_HH__
2#define __DUNE_ACFEM_TENSOR_OPTIMIZATION_SUMOPERANDTUPLE_HH__
4#include "../../expressions/operationpair.hh"
5#include "../../expressions/optimizesums.hh"
6#include "../modules/kronecker.hh"
7#include "../modules/eye.hh"
9namespace Dune::ACFem::Tensor::Optimization::Sums {
11 using namespace Expressions;
18 template<
class Tuple,
class SFINAE =
void>
30 template<
class Tuple,
class SFINAE =
void>
31 constexpr inline bool IsCompleteSumOfKroneckersV =
false;
34 constexpr inline bool IsKroneckerNodeV =
false;
36 template<
class T,
class Pos>
37 constexpr inline bool IsKroneckerNodeV<TreeData<PlusFunctor, T, Pos> > =
38 IsDiagonalKroneckerDelta<T>::value;
43 template<
class T0,
class... T>
44 constexpr bool isCompleteSumOfKroneckers(MPL::TypeTuple<T0, T...>)
48 if constexpr (minDim == (
sizeof...(T)+1)) {
49 return ((
Head<PivotSequence<T0> >::value + ... +
Head<PivotSequence<T> >::value)
51 minDim * (minDim - 1) / 2);
57 template<
class T0,
class... T>
58 constexpr inline bool IsCompleteSumOfKroneckersV<
59 MPL::TypeTuple<T0, T...>,
60 std::enable_if_t<(IsKroneckerNodeV<T0> && ... && IsKroneckerNodeV<T>)>
61 > = isCompleteSumOfKroneckers(MPL::TypeTuple<typename T0::Operand, typename T::Operand...>{});
64 struct ProcessSumOperands<Tuple,
std::enable_if_t<IsCompleteSumOfKroneckersV<Tuple> > >
66 using Signature =
typename TensorTraits<typename MPL::FrontType<Tuple>::Operand>::Signature;
67 using Type = MPL::TypeTuple<TreeData<PlusFunctor, Eye<Signature>, TreePosition<~0UL> > >;
73 template<
class In,
class Out>
76 template<
class In0,
class... In,
class... Out>
77 struct OptimizeAll<MPL::TypeTuple<In0, In...>, MPL::TypeTuple<Out...> >
79 using Try = Expressions::Sums::TryAddSumOperand<In0, MPL::TypeTuple<Out...> >;
80 using Output = ConditionalType<(
Try::size() > 0), Try, MPL::TypeTuple<Out..., In0> >;
81 using Type =
typename OptimizeAll<MPL::TypeTuple<In...>, Output>::Type;
85 struct OptimizeAll<MPL::TypeTuple<>, Out>
90 template<
class In0,
class In1,
class... In>
91 struct ProcessSumOperands<MPL::TypeTuple<In0, In1, In...>, std::enable_if_t<!IsCompleteSumOfKroneckersV<MPL::TypeTuple<In0, In1, In...> > > >
93 using Type =
typename OptimizeAll<MPL::TypeTuple<In1, In...>, MPL::TypeTuple<In0> >::Type;
constexpr std::size_t size()
Gives the number of elements in tuple-likes and std::integer_sequence.
Definition: size.hh:73
Gets the type of the n-th element of a tuple-like or the std::integral_constant corresponding to the ...
Definition: access.hh:42
Hook into the innermost operand tuple of the factor out code.
Definition: sumoperandtuple.hh:20