From e529dd96964ba0d78e638dc1e3937de84c967805 Mon Sep 17 00:00:00 2001 From: Azusa Yamaguchi Date: Sun, 14 Jun 2015 01:00:11 +0100 Subject: [PATCH] Peek poke colour/spin/complex and trace transpose support --- lib/qcd/QCD.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index f17c557b..ab180ff6 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -250,6 +250,7 @@ namespace QCD { ////////////////////////////////////////////////////////////////////////////// // Peek and Poke named after physics attributes ////////////////////////////////////////////////////////////////////////////// + //spin template auto peekSpin(const vobj &rhs,int i) -> decltype(peekIndex(rhs,0)) { @@ -289,20 +290,117 @@ namespace QCD { { return peekIndex(rhs,i); } - template auto peekLorentz(const vobj &rhs,int i,int j) -> decltype(peekIndex(rhs,0,0)) - { - return peekIndex(rhs,i,j); - } template auto peekLorentz(const Lattice &rhs,int i) -> decltype(peekIndex(rhs,0)) { return peekIndex(rhs,i); } - template auto peekLorentz(const Lattice &rhs,int i,int j) -> decltype(peekIndex(rhs,0,0)) + + ////////////////////////////////////////////// + // Poke lattice + ////////////////////////////////////////////// + template + void pokeColour(Lattice &lhs, + const Lattice(lhs._odata[0],0))> & rhs, + int i) { - return peekIndex(rhs,i,j); + pokeIndex(lhs,rhs,i); + } + template + void pokeColour(Lattice &lhs, + const Lattice(lhs._odata[0],0,0))> & rhs, + int i,int j) + { + pokeIndex(lhs,rhs,i,j); + } + template + void pokeSpin(Lattice &lhs, + const Lattice(lhs._odata[0],0))> & rhs, + int i) + { + pokeIndex(lhs,rhs,i); + } + template + void pokeSpin(Lattice &lhs, + const Lattice(lhs._odata[0],0,0))> & rhs, + int i,int j) + { + pokeIndex(lhs,rhs,i,j); + } + template + void pokeLorentz(Lattice &lhs, + const Lattice(lhs._odata[0],0))> & rhs, + int i) + { + pokeIndex(lhs,rhs,i); } - // FIXME transpose Colour, transpose Spin, traceColour traceSpin + ////////////////////////////////////////////// + // Poke scalars + ////////////////////////////////////////////// + + template void pokeSpin(vobj &lhs,const decltype(peekIndex(lhs,0)) & rhs,int i) + { + pokeIndex(lhs,rhs,i); + } + template void pokeSpin(vobj &lhs,const decltype(peekIndex(lhs,0,0)) & rhs,int i,int j) + { + pokeIndex(lhs,rhs,i,j); + } + + template void pokeColour(vobj &lhs,const decltype(peekIndex(lhs,0)) & rhs,int i) + { + pokeIndex(lhs,rhs,i); + } + template void pokeColour(vobj &lhs,const decltype(peekIndex(lhs,0,0)) & rhs,int i,int j) + { + pokeIndex(lhs,rhs,i,j); + } + + template void pokeLorentz(vobj &lhs,const decltype(peekIndex(lhs,0)) & rhs,int i) + { + pokeIndex(lhs,rhs,i); + } + + + ////////////////////////////////////////////// + // transpose array and scalar + ////////////////////////////////////////////// + template inline Lattice transposeSpin(const Lattice &lhs){ + return transposeIndex(lhs); + } + template inline Lattice transposeColour(const Lattice &lhs){ + return transposeIndex(lhs); + } + template inline vobj transposeSpin(const vobj &lhs){ + return transposeIndex(lhs); + } + template inline vobj transposeColour(const vobj &lhs){ + return transposeIndex(lhs); + } + + ////////////////////////////////////////// + // Trace lattice and non-lattice + ////////////////////////////////////////// + template + inline auto traceSpin(const Lattice &lhs) -> Lattice(lhs._odata[0]))> + { + return traceIndex(lhs); + } + template + inline auto traceColour(const Lattice &lhs) -> Lattice(lhs._odata[0]))> + { + return traceIndex(lhs); + } + template + inline auto traceSpin(const vobj &lhs) -> Lattice(lhs))> + { + return traceIndex(lhs); + } + template + inline auto traceColour(const vobj &lhs) -> Lattice(lhs))> + { + return traceIndex(lhs); + } } //namespace QCD } // Grid