1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Added support for Ta to Lattice types

This commit is contained in:
neo 2015-06-04 18:29:55 +09:00
parent bb73569fd6
commit 949b6a7afa
3 changed files with 29 additions and 12 deletions

View File

@ -48,5 +48,16 @@ PARALLEL_FOR_LOOP
}
template<class vobj> inline auto Ta(const Lattice<vobj> &z) -> Lattice<decltype(Ta(z._odata[0]))>
{
Lattice<decltype(Ta(z._odata[0]))> ret(z._grid);
PARALLEL_FOR_LOOP
for(int ss=0;ss<z._grid->oSites();ss++){
ret._odata[ss] = Ta(z._odata[ss]);
}
return ret;
}
}
#endif

View File

@ -5,10 +5,10 @@ namespace Grid {
///////////////////////////////////////////////
// Ta function for scalar, vector, matrix
///////////////////////////////////////////////
/* inline ComplexF Ta( const ComplexF &arg){ return arg;} */
/* inline ComplexD Ta( const ComplexD &arg){ return arg;} */
/* inline RealF Ta( const RealF &arg){ return arg;} */
/* inline RealD Ta( const RealD &arg){ return arg;} */
inline ComplexF Ta( const ComplexF &arg){ return arg;}
inline ComplexD Ta( const ComplexD &arg){ return arg;}
inline RealF Ta( const RealF &arg){ return arg;}
inline RealD Ta( const RealD &arg){ return arg;}
template<class vtype> inline iScalar<vtype> Ta(const iScalar<vtype>&r)
@ -28,8 +28,13 @@ namespace Grid {
template<class vtype,int N> inline iMatrix<vtype,N> Ta(const iMatrix<vtype,N> &arg)
{
iMatrix<vtype,N> ret(arg);
vtype factor = (1/(double)N);
ret = (ret - adj(arg))*0.5;
double factor = (1/(double)N);
for(int c1=0;c1<N;c1++){
for(int c2=0;c2<N;c2++){
ret._internal[c1][c2]= (ret._internal[c1][c2] - adj(arg._internal[c2][c1]));
ret._internal[c1][c2] *= 0.5;
}}
//ret = (ret - adj(arg))*0.5;
ret -= trace(ret)*factor;
return ret;
}

View File

@ -123,6 +123,8 @@ int main (int argc, char ** argv)
cMat = outerProduct(cVec,cVec);
scalar = localInnerProduct(cVec,cVec);
cMat = Ta(cMat); //traceless antihermitian
scalar += scalar;
scalar -= scalar;
@ -214,13 +216,12 @@ int main (int argc, char ** argv)
scm=transposeIndex<1>(scm);
random(SerialRNG, cm);
std::cout << cm << std::endl;
//random(SerialRNG, cm);
//std::cout << cm << std::endl;
cm = Ta(cm);
//cm = adj(cm);
TComplex tracecm= trace(cm);
std::cout << cm << " "<< tracecm << std::endl;
//TComplex tracecm= trace(cm);
//std::cout << cm << " "<< tracecm << std::endl;
// Foo = Foo+scalar; // LatticeColourMatrix+Scalar