diff --git a/Grid_Lattice.h b/Grid_Lattice.h index a94a13a4..8075df94 100644 --- a/Grid_Lattice.h +++ b/Grid_Lattice.h @@ -156,7 +156,8 @@ public: } }; - // FIXME for debug; deprecate this + // FIXME for debug; deprecate this; made obscelete by + // LatticeCoordinate(); friend void lex_sites(Lattice &l){ Real *v_ptr = (Real *)&l._odata[0]; size_t o_len = l._grid->oSites(); @@ -211,6 +212,7 @@ public: return *this; } + // FIXME trace type structure is weird inline friend Lattice > _trace(const Lattice &lhs){ Lattice > ret(lhs._grid); #pragma omp parallel for diff --git a/Grid_math_types.h b/Grid_math_types.h index 58de9c15..9a9f1274 100644 --- a/Grid_math_types.h +++ b/Grid_math_types.h @@ -1059,6 +1059,23 @@ template inline iScalar conj(const iScalar&r) ret._internal = conj(r._internal); return ret; } +template inline iVector conj(const iVector&r) +{ + iVector ret; + for(int i=0;i inline iMatrix conj(const iMatrix&r) +{ + iMatrix ret; + for(int i=0;i inline iScalar adj(const iScalar&r) @@ -1085,8 +1102,14 @@ template inline iMatrix adj(const iMatrix & return ret; } ///////////////////////////////////////////////////////////////// -// Transpose +// Transpose all indices ///////////////////////////////////////////////////////////////// + +inline ComplexD transpose(ComplexD &rhs){ return rhs;} +inline ComplexF transpose(ComplexF &rhs){ return rhs;} +inline RealD transpose(RealD &rhs){ return rhs;} +inline RealF transpose(RealF &rhs){ return rhs;} + template inline typename std::enable_if::value, iMatrix >::type transpose(iMatrix arg) @@ -1128,19 +1151,9 @@ template return ret; } - - -/* - * No need to implement transpose on the primitive types - * Not sure that this idiom is any more elegant that the trace idiom below however! -inline ComplexD transpose(ComplexD &rhs){ return rhs;} -inline ComplexF transpose(ComplexF &rhs){ return rhs;} -inline RealD transpose(RealD &rhs){ return rhs;} -inline RealF transpose(RealF &rhs){ return rhs;} - */ - //////////////////////////////////////////////////////////////////////////////////////////// -// Transpose a specific index +// Transpose a specific index; instructive to compare this style of recursion termination +// to that of adj; which is easiers? //////////////////////////////////////////////////////////////////////////////////////////// template inline typename std::enable_if,Level>::value, iMatrix >::type @@ -1171,15 +1184,40 @@ transposeIndex (const iScalar &arg) { return transposeIndex(arg._internal); } -//////////////////////////////// -// Trace a specific index -//////////////////////////////// + +////////////////////////////////////////////////////////////////// +// Traces: both all indices and a specific index +///////////////////////////////////////////////////////////////// + +inline ComplexF trace( const ComplexF &arg){ return arg;} +inline ComplexD trace( const ComplexD &arg){ return arg;} +inline RealF trace( const RealF &arg){ return arg;} +inline RealD trace( const RealD &arg){ return arg;} template inline ComplexF traceIndex(const ComplexF arg) { return arg;} template inline ComplexD traceIndex(const ComplexD arg) { return arg;} template inline RealF traceIndex(const RealF arg) { return arg;} template inline RealD traceIndex(const RealD arg) { return arg;} +template +inline auto trace(const iMatrix &arg) -> iScalar +{ + iScalar ret; + zeroit(ret._internal); + for(int i=0;i +inline auto trace(const iScalar &arg) -> iScalar +{ + iScalar ret; + ret._internal=trace(arg._internal); + return ret; +} + +// Specific indices. template inline auto traceIndex(const iScalar &arg) -> iScalar(arg._internal)) > { @@ -1268,41 +1306,6 @@ template inline auto imag(const iVector &z) -> iVect return ret; } - ///////////////////////////////// - // Trace of scalar and matrix - ///////////////////////////////// - -inline ComplexF trace( const ComplexF &arg){ - return arg; -} -inline ComplexD trace( const ComplexD &arg){ - return arg; -} -inline RealF trace( const RealF &arg){ - return arg; -} -inline RealD trace( const RealD &arg){ - return arg; -} - -template -inline auto trace(const iMatrix &arg) -> iScalar -{ - iScalar ret; - zeroit(ret._internal); - for(int i=0;i -inline auto trace(const iScalar &arg) -> iScalar -{ - iScalar ret; - ret._internal=trace(arg._internal); - return ret; -} - }; #endif