SUNphi  1.0
NnarySmET.hpp File Reference

Header file defining basic properties of Nnary SmET. More...

Go to the source code of this file.

Classes

struct  SUNphi::BaseNnarySmET
 Defines the NnarySmET type traits. More...
 
struct  SUNphi::ConstrainAreNnarySmETs< Args >
 
struct  SUNphi::HasMember_refs< Type >
 
struct  SUNphi::HasMember_refs< Type >::Fallback
 
struct  SUNphi::HasMember_refs< Type >::Derived
 
struct  SUNphi::HasMember_refs< Type >::Check< U, U >
 
struct  SUNphi::ConstrainHasMember_refs< T >
 Class forcing T to have a member "refs" defined. More...
 
struct  SUNphi::NnarySmET< T >
 Nnary SmET. More...
 

Macros

#define STATIC_ASSERT_IS_NNARY_SMET(...)
 Defines the check for a Nnary SmET. More...
 
#define IDENTITY_REPRESENTATIVE_FUNCTION
 Provide an identity representative function. More...
 
#define EVAL_THROUGH_REPRESENTATIVE_FUNCTION_PASSING_COMPS_BY_NAME
 Provides an evaluator through a representative function. More...
 
#define PROVIDE_NNARY_SMET_REFS_AND_CHECK_ARE_N(N)
 
#define PROVIDE_SIMPLE_NNARY_COMP_SIZE
 
#define PROVIDE_FUND_ACCORDING_TO_REPRESENTATIVE_FUNCTION
 Defines the Fund type using the call to representativeFunction. More...
 
#define SAME_FUND_AS_REF(ID)
 Get the same Fund type of a given ref. More...
 
#define AS_ASSIGNABLE_AS_REF(ID)   IS_ASSIGNABLE_ATTRIBUTE(/*! As assignable as ref ID */,Unqualified<Ref<ID>>::isAssignable)
 Get the same assignability of a given ref.
 
#define SAME_TK_AS_REF(ID)
 Get the same TensKind of a given ref. More...
 
#define PROVIDE_POS_OF_RES_TCS_IN_REFS
 Provide the position of result Tk TensComp in each input. More...
 
#define PROVIDE_EXTRA_MERGE_DELIMS(...)
 Add an ExtraDelims IntSeq called ExtraDelims. More...
 
#define NO_EXTRA_MERGE_DELIMS
 Add an empty ExtraDelims. More...
 
#define PROVIDE_MERGEABLE_COMPS_ACCORDING_TO_REFS_AND_EXTRA
 Provide MergeableComps delimiter according to references and extra. More...
 
#define MERGED_COMPS_VIEW_OF_REF(I)   get<I>(refs).template getMergedCompsView<TupleElementType<I,MDs>>()
 Returns the merged comps view of the I-th Ref.
 
#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW(DESCRIPTION, ...)
 Provides a getMergedCompsView method, taking Is as template parameter. More...
 
#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW_ACCORDING_TO_REPRESENTATIVE_FUNCTION
 Uses the representativeFunction to provide a merged view. More...
 
#define PROVIDE_NNARY_SMET_SIMPLE_CREATOR(NNARY_SMET)
 Defines a simple creator taking n references. More...
 
#define STATIC_ASSERT_IS_NNARY_SMET(...)
 Defines the check for a Nnary SmET. More...
 
#define SIMPLE_NNARY_SMET_BUILDER(BUILDER, NNARY_SMET)
 
#define FORWARD_IS_ALIASING_TO_REFS
 
#define REPRESENTATIVE_FUNCTION_WINS_ALL
 Provides Fund, eval and mergedComps according to representativeFunction. More...
 
#define CANCEL_DUPLICATED_NNARY_SMET_CALL(CALLER, NNARY_SMET)
 
#define NNARY_SMET_GOES_INSIDE(EXT_FUN, NNARY_SMET, INT_FUN)
 
#define ABSORB_DUPLICATED_NNARY_SMET_CALL(CALLER, NNARY_SMET)
 

Typedefs

template<typename T , typename Ret = void>
using SUNphi::EnableIfIsNnarySmET = EnableIf< isNnarySmET< T >,Ret >
 
template<typename T >
using SUNphi::ConstrainIsNnarySmET = ConstrainIsBaseOf< BaseNnarySmET,T >
 
template<typename T >
using SUNphi::ConstrainIsNotNnarySmET = ConstrainIsNotBaseOf< BaseNnarySmET,T >
 
template<typename RefsMD , typename PosOfResTcsInRefTks , typename ExtraDelims >
using SUNphi::NnarySmETCompsMergeability = decltype(_nnarySmETCompsMergeability(RefsMD{}, PosOfResTcsInRefTks{}, IntSeqOfSameNumb< tupleSize< RefsMD >, NOT_PRESENT >{}, ExtraDelims{}))
 

Functions

template<typename Type >
constexpr bool SUNphi::hasMember_refsHelper ()
 
template<int ResPos = 0, typename... MergeDelim, typename... PosOfResTcsInRefTk, int... PrevPosInts, typename ExtraDelim >
decltype(auto) constexpr SUNphi::_nnarySmETCompsMergeability (Tuple< MergeDelim... >, Tuple< PosOfResTcsInRefTk... >, IntSeq< PrevPosInts... >, ExtraDelim)
 

Variables

template<typename T >
constexpr bool SUNphi::isNnarySmET = isBaseOf<BaseNnarySmET ,T>
 
template<typename Type >
constexpr bool SUNphi::hasMember_refs = hasMember_refsHelper<RemRef<Type>>()
 

Detailed Description

Header file defining basic properties of Nnary SmET.

Definition in file NnarySmET.hpp.

Macro Definition Documentation

#define ABSORB_DUPLICATED_NNARY_SMET_CALL (   CALLER,
  NNARY_SMET 
)
Value:
\ \ \ \
template <typename D, /* Type of the nested NNARY_SMET */ \
SFINAE_ON_TEMPLATE_ARG(is ## NNARY_SMET<D>)> /* Enable only for the NNARY_SMET required */ \
DECLAUTO CALLER(D&& smet) \
{ \
return forw<D>(smet); \
} \
#define SWALLOW_SEMICOLON_AT_GLOBAL_SCOPE
#define SFINAE_ON_TEMPLATE_ARG(...)
Definition: SFINAE.hpp:24
#define DECLAUTO
Short name for decltype(auto)

Implements a duplicated-call absorber

Example

1 Tens<TensKind<Compl>,double> cicc;
2 wrap(wrap(cicc)); // returns wrap(cicc)

< Name of builder

Definition at line 515 of file NnarySmET.hpp.

#define CANCEL_DUPLICATED_NNARY_SMET_CALL (   CALLER,
  NNARY_SMET 
)

Implements a duplicated-call canceller

Example

1 Tens<TensKind<Compl>,double> cicc;
2 conj(conj(cicc)); // returns cicc

< Name of builder

Definition at line 451 of file NnarySmET.hpp.

#define EVAL_THROUGH_REPRESENTATIVE_FUNCTION_PASSING_COMPS_BY_NAME
Value:
\ \ \ \ \ \ \
template <typename...Args> /* Type of the arguments */ \
DECLAUTO eval(Args&&...args) const /* Components to get */ \
{ \
return this->evalThroughRepresentativeFunctionPassingCompsByName(IntsUpTo<NSmET>{}, \
forw<Args>(args)...); \
} \
Args && args
< Function to cal
Definition: LoopUnroll.hpp:22
#define PROVIDE_ALSO_NON_CONST_METHOD(NAME)
Definition: TypeTraits.hpp:376
#define DECLAUTO
Short name for decltype(auto)

Provides an evaluator through a representative function.

Definition at line 105 of file NnarySmET.hpp.

#define FORWARD_IS_ALIASING_TO_REFS
Value:
\
template <typename Tref> \
bool isAliasing(const Tref& alias) const \
{ \
CRASH<<"Fixme"; \
\
return \
true; \
}
#define CRASH
Initialize the crasher.
Definition: Crash.hpp:13

Set aliasing according to the isAliasing of references

Todo:
enforce cehck only with TensClass

Definition at line 420 of file NnarySmET.hpp.

#define IDENTITY_REPRESENTATIVE_FUNCTION
Value:
\
template <typename T> /* Argument type */ \
static DECLAUTO representativeFunction(T&& t) \
{ \
return \
forw<T>(t); \
}
Tens< Tk, double > T
Tensor class of the expression.
Definition: RelBind.hpp:263
#define DECLAUTO
Short name for decltype(auto)

Provide an identity representative function.

Definition at line 29 of file NnarySmET.hpp.

#define NNARY_SMET_GOES_INSIDE (   EXT_FUN,
  NNARY_SMET,
  INT_FUN 
)
Value:
\ \ \ \
template <typename D, /* Type of the nested NNARY_SMET */ \
SFINAE_ON_TEMPLATE_ARG(is ## NNARY_SMET<D>)> /* Enable only for the NNARY_SMET required */ \
DECLAUTO EXT_FUN(D&& smet) \
{ \
return INT_FUN(EXT_FUN(get<0>(smet.refs))); \
} \
#define SWALLOW_SEMICOLON_AT_GLOBAL_SCOPE
#define SFINAE_ON_TEMPLATE_ARG(...)
Definition: SFINAE.hpp:24
#define DECLAUTO
Short name for decltype(auto)

Defines a simple way to swap nested NnarySmET

Todo:
we need to implement the same check done for CANCEL_DUPLICATED_NNARY_SMET_CALL

< External builder

< Name of the SmET

Definition at line 494 of file NnarySmET.hpp.

#define NO_EXTRA_MERGE_DELIMS
Value:
\
#define PROVIDE_EXTRA_MERGE_DELIMS(...)
Add an ExtraDelims IntSeq called ExtraDelims.
Definition: NnarySmET.hpp:313

Add an empty ExtraDelims.

Definition at line 319 of file NnarySmET.hpp.

#define PROVIDE_EXTRA_MERGE_DELIMS (   ...)
Value:
\
using ExtraDelims= \
__VA_ARGS__

Add an ExtraDelims IntSeq called ExtraDelims.

Definition at line 313 of file NnarySmET.hpp.

#define PROVIDE_FUND_ACCORDING_TO_REPRESENTATIVE_FUNCTION
Value:
\ \ \ \ \
template <int...Is> \
static DECLAUTO _fundThroughRepresentativeFunction(IntSeq<Is...>) \
{ \
return representativeFunction(typename RemRef<Ref<Is>>::Fund{}...); \
} \
\ \
using Fund= \
decltype(_fundThroughRepresentativeFunction(IntsUpTo<NSmET>{}))
#define DECLAUTO
Short name for decltype(auto)

Defines the Fund type using the call to representativeFunction.

Definition at line 175 of file NnarySmET.hpp.

#define PROVIDE_MERGEABLE_COMPS_ACCORDING_TO_REFS_AND_EXTRA
Value:
NnarySmETCompsMergeability< \
Tuple<typename RemRef<_Refs>::MergeableComps...>,\
PosOfResTcsInRefsTk, \
ExtraDelims>)
#define PROVIDE_MERGEABLE_COMPS(LONG_DESCRIPTION,...)
Definition: BaseSmET.hpp:179

Provide MergeableComps delimiter according to references and extra.

Definition at line 324 of file NnarySmET.hpp.

#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW (   DESCRIPTION,
  ... 
)
Value:
DESCRIPTION \
template <typename Is> /* IntSeq delimiting the comps groups */ \
DECLAUTO getMergedCompsView() \
const \
{ \
/* Check that we can merge as asked */ \
assertMergeableWith<Is>(); \
\
using MDs= \
Tuple<InsertInOrderedIntSeq /* Insert the begin */ \
<0, /* Insert 0 as begin */ \
IntSeqGetElsAfterAppending \
<RemRef<_Refs>::Tk::nTypes, \
false, /* Omit NOT_PRESENT */ \
Is, \
PosOfTypesNotAsserting<typename Tk::types, \
typename RemRef<_Refs>::Tk::types>>, \
0, /* Shift after inserting */ \
true>...>; /* Ignore 0 if present */ \
\
__VA_ARGS__; \
} \
PROVIDE_ALSO_NON_CONST_METHOD(getMergedCompsView)
decltype(_insertInOrderedIntSeq< Ins, IncrAft, IgnoreIfPresent >(intSeq<>, typename ConstrainIsOrderedIntSeq< IS >::type{})) InsertInOrderedIntSeq
#define PROVIDE_ALSO_NON_CONST_METHOD(NAME)
Definition: TypeTraits.hpp:376
#define DECLAUTO
Short name for decltype(auto)

Provides a getMergedCompsView method, taking Is as template parameter.

Definition at line 338 of file NnarySmET.hpp.

#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW_ACCORDING_TO_REPRESENTATIVE_FUNCTION
Value:
\
template <int...Is, /* Ints used to call the representativeFunction */ \
typename MDs> /* MergeDelims to be used */ \
DECLAUTO mergedCompsViewAccordingToRepresentativeFunction(IntSeq<Is...>, \
MDs) const \
{ \
return representativeFunction(MERGED_COMPS_VIEW_OF_REF(Is)...); \
} \
PROVIDE_ALSO_NON_CONST_METHOD(mergedCompsViewAccordingToRepresentativeFunction); \
return mergedCompsViewAccordingToRepresentativeFunction(IntsUpTo<NSmET>{},MDs{}))
#define MERGED_COMPS_VIEW_OF_REF(I)
Returns the merged comps view of the I-th Ref.
Definition: NnarySmET.hpp:334
#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW(DESCRIPTION,...)
Provides a getMergedCompsView method, taking Is as template parameter.
Definition: NnarySmET.hpp:338
#define PROVIDE_ALSO_NON_CONST_METHOD(NAME)
Definition: TypeTraits.hpp:376
#define DECLAUTO
Short name for decltype(auto)

Uses the representativeFunction to provide a merged view.

Definition at line 365 of file NnarySmET.hpp.

#define PROVIDE_NNARY_SMET_REFS_AND_CHECK_ARE_N (   N)
Value:
\
using Refs= \
Tuple<_Refs...>; \
\ \
Tuple<Reference<_Refs>...> refs; \
\ \
template <int I> \
using Ref= \
TupleElementType<I,Tuple<_Refs...>>; \
\ \
static constexpr \
int NSmET= \
N; \
\
/* Check that NSmET coincides with the par */ \
static_assert(N==sizeof...(_Refs))
std::tuple< Tp... > Tuple
Definition: TupleClass.hpp:20

Provide the references to the objects

The reference types are contained in a Tuple with types obtained from template pars

Definition at line 126 of file NnarySmET.hpp.

#define PROVIDE_NNARY_SMET_SIMPLE_CREATOR (   NNARY_SMET)
Value:
\
template <typename...SMETS, \
typename=EnableIf<((isSame<Unqualified<SMETS>,Unqualified<_Refs>>) && ...)>> \
explicit NNARY_SMET(SMETS&&...smets) : refs(forw<SMETS>(smets)...) \
{ \
}
constexpr T && forw(U &&u)
Forward according to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html.

Defines a simple creator taking n references.

< Name of the NnarySmET

Definition at line 383 of file NnarySmET.hpp.

#define PROVIDE_POS_OF_RES_TCS_IN_REFS
Value:
\
using PosOfResTcsInRefsTk= \
\ \
using PosOfResTcsPresInRefsTk= \
TensKind< Tc1, Tc2 > Tk
TensorKind of the expression.
Definition: RelBind.hpp:259

Provide the position of result Tk TensComp in each input.

Definition at line 206 of file NnarySmET.hpp.

#define PROVIDE_SIMPLE_NNARY_COMP_SIZE
Value:
\
template <typename TC, /* \c TensComp to search */ \
int I=0> /* Integer of the ref to search in */ \
int compSize() const \
{ \
static_assert(I>=0 and I<NSmET,"Cannot search in negative or larger-than-N ref"); \
\ \
using RefTk= \
typename Ref<I>::Tk; \
\ \
constexpr bool found= \
RefTk::template contains<TC>; \
\
/* Returns the size if it's in the I-th Tk */ \
if constexpr(found) \
return get<I>(refs).template compSize<TC>(); \
else \
return compSize<TC,I+1>(); \
}
TensKind< Tc1, Tc2 > Tk
TensorKind of the expression.
Definition: RelBind.hpp:259

Returns the size of a TensComp, with a simple approach

Search the asked TensComp in each ref TensKind iteratively and returns the size in the first found ref

Definition at line 151 of file NnarySmET.hpp.

#define REPRESENTATIVE_FUNCTION_WINS_ALL
Value:
\
\
\
\
#define PROVIDE_NNARY_GET_MERGED_COMPS_VIEW_ACCORDING_TO_REPRESENTATIVE_FUNCTION
Uses the representativeFunction to provide a merged view.
Definition: NnarySmET.hpp:365
#define EVAL_THROUGH_REPRESENTATIVE_FUNCTION_PASSING_COMPS_BY_NAME
Provides an evaluator through a representative function.
Definition: NnarySmET.hpp:105
#define PROVIDE_POS_OF_RES_TCS_IN_REFS
Provide the position of result Tk TensComp in each input.
Definition: NnarySmET.hpp:206
#define PROVIDE_MERGEABLE_COMPS_ACCORDING_TO_REFS_AND_EXTRA
Provide MergeableComps delimiter according to references and extra.
Definition: NnarySmET.hpp:324
#define PROVIDE_FUND_ACCORDING_TO_REPRESENTATIVE_FUNCTION
Defines the Fund type using the call to representativeFunction.
Definition: NnarySmET.hpp:175

Provides Fund, eval and mergedComps according to representativeFunction.

Definition at line 432 of file NnarySmET.hpp.

#define SAME_FUND_AS_REF (   ID)
Value:
\
PROVIDE_FUND(typename RemRef<Ref<ID>>::Fund)
#define PROVIDE_FUND(...)
Provides the Fund member.
Definition: BaseSmET.hpp:108

Get the same Fund type of a given ref.

Definition at line 192 of file NnarySmET.hpp.

#define SAME_TK_AS_REF (   ID)
Value:
\
PROVIDE_TK(typename RemRef<Ref<ID>>::Tk)
#define PROVIDE_TK(...)
Provides the Tk member.
Definition: BaseSmET.hpp:94
TensKind< Tc1, Tc2 > Tk
TensorKind of the expression.
Definition: RelBind.hpp:259

Get the same TensKind of a given ref.

Definition at line 201 of file NnarySmET.hpp.

#define SIMPLE_NNARY_SMET_BUILDER (   BUILDER,
  NNARY_SMET 
)
Value:
\ \ \ \
template <typename...Ts> /* Types of the SmET to get */ \
NNARY_SMET<Ts...> BUILDER(Ts&&...smets) \
{ \
return NNARY_SMET<Ts...>(forw<Ts>(smets)...); \
} \
#define SWALLOW_SEMICOLON_AT_GLOBAL_SCOPE

Create a simple builder with a name and a NNARY_SMET returned type

NnarySmET cannot use SFINAE to worsen default constructors (unless packing args in Tuple) so the simple builder cannot be overloaded. If required, use a custom builder and use if constexpr construct inside it to route the manipulations.

< Name of builder function

Definition at line 406 of file NnarySmET.hpp.

#define STATIC_ASSERT_IS_NNARY_SMET (   ...)
Value:
STATIC_ASSERT_IS_SMET(__VA_ARGS__); \
STATIC_ASSERT_HAS_MEMBER(refs,__VA_ARGS__)
#define STATIC_ASSERT_IS_SMET(...)
Definition: BaseSmET.hpp:257
#define STATIC_ASSERT_HAS_MEMBER(TAG,...)
Definition: TypeTraits.hpp:560

Defines the check for a Nnary SmET.

Defines the check for a NnarySmET.

Definition at line 394 of file NnarySmET.hpp.

#define STATIC_ASSERT_IS_NNARY_SMET (   ...)
Value:
STATIC_ASSERT_IS_SMET(__VA_ARGS__); \
STATIC_ASSERT_HAS_MEMBER(refs,__VA_ARGS__)
#define STATIC_ASSERT_IS_SMET(...)
Definition: BaseSmET.hpp:257
#define STATIC_ASSERT_HAS_MEMBER(TAG,...)
Definition: TypeTraits.hpp:560

Defines the check for a Nnary SmET.

Defines the check for a NnarySmET.

Definition at line 394 of file NnarySmET.hpp.

Typedef Documentation

template<typename T >
using SUNphi::ConstrainIsNnarySmET = typedef ConstrainIsBaseOf<BaseNnarySmET ,T>

Class forcing T to inherits from BaseNnarySmET

Definition at line 18 of file NnarySmET.hpp.

template<typename T >
using SUNphi::ConstrainIsNotNnarySmET = typedef ConstrainIsNotBaseOf<BaseNnarySmET ,T>

Class forcing T not to inherits from BaseNnarySmET

Definition at line 18 of file NnarySmET.hpp.

template<typename T , typename Ret = void>
using SUNphi::EnableIfIsNnarySmET = typedef EnableIf< isNnarySmET <T> ,Ret>

Provides the class itself if T is of the given type

Provides the class itself if T satisfies the condition

Definition at line 18 of file NnarySmET.hpp.

template<typename RefsMD , typename PosOfResTcsInRefTks , typename ExtraDelims >
using SUNphi::NnarySmETCompsMergeability = typedef decltype(_nnarySmETCompsMergeability(RefsMD{},PosOfResTcsInRefTks{},IntSeqOfSameNumb<tupleSize<RefsMD>,NOT_PRESENT>{},ExtraDelims{}))

Determine the mergeability of a given TensComp

A component is declared mergeable if its presence in all TensKind is of the same nature of the previous one (e.g. present only in one of the TensKind), if its position inside the TensKind is consecutive with previous TensComp, and if the component was mergeable in all TensKind

Definition at line 310 of file NnarySmET.hpp.

Function Documentation

template<int ResPos = 0, typename... MergeDelim, typename... PosOfResTcsInRefTk, int... PrevPosInts, typename ExtraDelim >
decltype(auto) constexpr SUNphi::_nnarySmETCompsMergeability ( Tuple< MergeDelim... >  ,
Tuple< PosOfResTcsInRefTk... >  ,
IntSeq< PrevPosInts... >  ,
ExtraDelim   
)

Determine the mergeability of the ResPos component of the result

Nested internal implemention

Number of remaining TensComp to be checked

Slice with the poisition of the current component

Nested delimiters

Function to check whether the current component is not consecutive in all Refs

Check whether the current component is not consecutive in all Refs

Check whether the current component was not originally mergeable

Check where the current component is present

Check where the previous component was present

Check it the position was extra-delimited

Determine if a break in mergeability is needed

Insert a break or not

Definition at line 223 of file NnarySmET.hpp.

template<typename Type >
constexpr bool SUNphi::hasMember_refsHelper ( )

Intemediate function to distinguish the non-class case

Definition at line 21 of file NnarySmET.hpp.

Variable Documentation

template<typename Type >
constexpr bool SUNphi::hasMember_refs = hasMember_refsHelper<RemRef<Type>>()

Detect if Type has member (variable or method) refs

Uses SFINAE to induce ambiguity in the detection of the member

Definition at line 21 of file NnarySmET.hpp.

template<typename T >
constexpr bool SUNphi::isNnarySmET = isBaseOf<BaseNnarySmET ,T>

Expression which is true if T inherits from BaseNnarySmET

Definition at line 18 of file NnarySmET.hpp.