SUNphi  1.0
UnaryMinus.hpp
Go to the documentation of this file.
1 #ifndef _UNARYMINUS_HPP
2 #define _UNARYMINUS_HPP
3 
4 /// \file UnaryMinus.hpp
5 ///
6 /// \brief Header file for the definition of -smet
7 
8 #include <physics/Spin.hpp>
9 #include <smet/NnarySmET.hpp>
10 #include <tens/TensKind.hpp>
11 
12 namespace SUNphi
13 {
14  // Base type to qualify as UMinuser
15  DEFINE_BASE_TYPE(UMinuser);
16 
17  /// Class to take the conjugate of a SmET
18  template <typename..._Refs> // Type of the expression to conjugate
19  class UMinuser :
20  public BaseUMinuser, // Inherit from BaseUMinuser to detect in expression
21  public NnarySmET<UMinuser<_Refs...>>, // Inherit from NnarySmET
22  public ConstrainAreSmETs<_Refs...> // Constrain all \c _Refs to be \c SmETs
23  {
24  public:
25 
27 
28  /// Returns the opposite of the argument
29  template <typename T> // Type of the argument to negate
30  static DECLAUTO representativeFunction(T&& t) ///< Argument to negate
31  {
32  return -t;
33  }
34 
36 
37  // Attributes
40 
42 
44 
46 
48  };
49 
50  // Check that a test UMinuser is a NnarySmET
51  STATIC_ASSERT_IS_NNARY_SMET(UMinuser<Tens<TensKind<Spin>,double>>);
52 
53  // Build UMinuser from uminus
54  SIMPLE_NNARY_SMET_BUILDER(uMinus,UMinuser);
55 
56  // Simplifies uMinus(uMinus)
57  CANCEL_DUPLICATED_NNARY_SMET_CALL(uMinus,UMinuser);
58 
59  /// Implement -smet: return uminus
60  template <typename T, // Type of the expression
61  SFINAE_ON_TEMPLATE_ARG(isSmET<T>)>
62  DECLAUTO operator-(T&& smet) ///< Expression
63  {
64  return uMinus(forw<T>(smet));
65  }
66 }
67 
68 #endif
#define SAME_TK_AS_REF(ID)
Get the same TensKind of a given ref.
Definition: NnarySmET.hpp:201
#define NO_EXTRA_MERGE_DELIMS
Add an empty ExtraDelims.
Definition: NnarySmET.hpp:319
#define PROVIDE_SIMPLE_NNARY_COMP_SIZE
Definition: NnarySmET.hpp:151
#define CANCEL_DUPLICATED_NNARY_SMET_CALL(CALLER,NNARY_SMET)
Definition: NnarySmET.hpp:451
#define REPRESENTATIVE_FUNCTION_WINS_ALL
Provides Fund, eval and mergedComps according to representativeFunction.
Definition: NnarySmET.hpp:432
#define FORWARD_IS_ALIASING_TO_REFS
Definition: NnarySmET.hpp:420
#define PROVIDE_NNARY_SMET_SIMPLE_CREATOR(NNARY_SMET)
Defines a simple creator taking n references.
Definition: NnarySmET.hpp:383
#define STATIC_ASSERT_IS_NNARY_SMET(...)
Defines the check for a Nnary SmET.
Definition: NnarySmET.hpp:394
#define SFINAE_ON_TEMPLATE_ARG(...)
Definition: SFINAE.hpp:24
#define NOT_STORING
Set the SmET to not-storing.
Definition: BaseSmET.hpp:86
#define DECLAUTO
Short name for decltype(auto)
#define SIMPLE_NNARY_SMET_BUILDER(BUILDER,NNARY_SMET)
Definition: NnarySmET.hpp:406
#define PROVIDE_NNARY_SMET_REFS_AND_CHECK_ARE_N(N)
Definition: NnarySmET.hpp:126
#define DEFINE_BASE_TYPE(TYPE,...)
Definition: TypeTraits.hpp:526