diff --git a/Grid/qcd/QCD.h b/Grid/qcd/QCD.h index dbedfa7c4..5b35dc646 100644 --- a/Grid/qcd/QCD.h +++ b/Grid/qcd/QCD.h @@ -596,16 +596,32 @@ template inline vobj transposeColour(const vobj &lhs){ ////////////////////////////////////////// // Trace lattice and non-lattice ////////////////////////////////////////// +#define GRID_UNOP(name) name +#define GRID_DEF_UNOP(op, name) \ + template ::value||is_lattice_expr::value,T1>::type * = nullptr> \ + inline auto op(const T1 &arg) ->decltype(LatticeUnaryExpression(GRID_UNOP(name)(), arg)) \ + { \ + return LatticeUnaryExpression(GRID_UNOP(name)(), arg); \ + } + template inline auto traceSpin(const Lattice &lhs) -> Lattice(vobj()))> { return traceIndex(lhs); } + +GridUnopClass(UnaryTraceSpin, traceIndex(a)); +GRID_DEF_UNOP(traceSpin, UnaryTraceSpin); + template inline auto traceColour(const Lattice &lhs) -> Lattice(vobj()))> { return traceIndex(lhs); } + +GridUnopClass(UnaryTraceColour, traceIndex(a)); +GRID_DEF_UNOP(traceColour, UnaryTraceColour); + template inline auto traceSpin(const vobj &lhs) -> Lattice(lhs))> { @@ -617,6 +633,8 @@ inline auto traceColour(const vobj &lhs) -> Lattice(lhs); } +#undef GRID_UNOP +#undef GRID_DEF_UNOP ////////////////////////////////////////// // Current types //////////////////////////////////////////