From c4d3e7919315ee16d08af71e4906abb17e2411fa Mon Sep 17 00:00:00 2001 From: Ryan Hill Date: Thu, 29 Jan 2026 14:46:52 +0000 Subject: [PATCH] Add ET support for Lattice spin- and colour-traces --- Grid/qcd/QCD.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Grid/qcd/QCD.h b/Grid/qcd/QCD.h index dbedfa7c49..5b35dc6461 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 //////////////////////////////////////////