mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-09 23:45:36 +00:00
Correct implementation of SpTa
This commit is contained in:
parent
5aabe074fe
commit
881b08a465
@ -82,67 +82,39 @@ template<class vtype,int N> accelerator_inline iVector<vtype,N> SpTa(const iVect
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class vtype,int N> accelerator_inline iMatrix<vtype,N> SpTa(const iMatrix<vtype,N> &arg)
|
||||
template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr> accelerator_inline iMatrix<vtype,N> SpTa(const iMatrix<vtype,N> &arg)
|
||||
{
|
||||
// Generalises Ta to Sp2n
|
||||
// Applies the following projections
|
||||
// P_{antihermitian} P_{antihermitian-Sp-algebra} P_{traceless}
|
||||
// where the ordering matters
|
||||
// P_{traceless} subtracts the trace
|
||||
// P_{antihermitian-Sp-algebra} provides the block structure of the algebra based on U = exp(T) i.e. anti-hermitian generators
|
||||
// P_{antihermitian} does in-adj(in) / 2
|
||||
iMatrix<vtype,N> ret(arg);
|
||||
double factor = (1.0/(double)N);
|
||||
vtype nrm;
|
||||
vtype inner;
|
||||
vtype tmp;
|
||||
nrm = 0.5;
|
||||
|
||||
ret = arg - (trace(arg)*factor);
|
||||
|
||||
for(int c1=0;c1<N/2;c1++)
|
||||
{
|
||||
|
||||
for (int b=0; b<c1; b++) // remove the b-rows from U_c1
|
||||
{
|
||||
decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
|
||||
decltype(ret._internal[b][b]*ret._internal[b][b]) prn;
|
||||
zeroit(pr);
|
||||
zeroit(prn);
|
||||
|
||||
for(int c=0; c<N; c++)
|
||||
{
|
||||
pr += conjugate(ret._internal[c1][c])*ret._internal[b][c]; // <U_c1 | U_b >
|
||||
prn += conjugate(ret._internal[c1][c])*ret._internal[b+N/2][c]; // <U_c1 | U_{b+N} >
|
||||
}
|
||||
|
||||
|
||||
for(int c=0; c<N; c++)
|
||||
{
|
||||
ret._internal[c1][c] -= (conjugate(pr) * ret._internal[b][c] + conjugate(prn) * ret._internal[b+N/2][c] ); // U_c1 -= ( <U_c1 | U_b > U_b + <U_c1 | U_{b+N} > U_{b+N} )
|
||||
}
|
||||
}
|
||||
|
||||
zeroit(inner);
|
||||
for(int c2=0;c2<N;c2++)
|
||||
{
|
||||
inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
|
||||
}
|
||||
|
||||
nrm = sqrt(inner);
|
||||
nrm = 1.0/nrm;
|
||||
for(int c2=0;c2<N;c2++)
|
||||
{
|
||||
ret._internal[c1][c2]*= nrm;
|
||||
}
|
||||
|
||||
|
||||
for(int c2=0;c2<N/2;c2++)
|
||||
{
|
||||
tmp = conjugate(ret._internal[c1][c2]); // (up-left)* of the old matrix
|
||||
ret._internal[c1+N/2][c2+N/2] = -tmp; // down right in the new matrix = -(up-left)* of the old matrix
|
||||
ret._internal[c1][c2] = nrm*(conjugate(ret._internal[c1+N/2][c2+N/2]) + ret._internal[c1][c2]); // new[up-left] = old[up-left]+old*[down-right]
|
||||
ret._internal[c1][c2+N/2] = nrm*(ret._internal[c1][c2+N/2] - conjugate(ret._internal[c1+N/2][c2])); // new[up-right] = old[up-right]-old*[down-left]
|
||||
}
|
||||
|
||||
for(int c2=N/2;c2<N;c2++)
|
||||
{
|
||||
tmp = conjugate(ret._internal[c1][c2]); // (up-right)* of the old
|
||||
ret._internal[c1+N/2][c2-N/2] = tmp; // down left in the new matrix = (up-right)* of the old
|
||||
ret._internal[c1+N/2][c2-N/2] = -conjugate(ret._internal[c1][c2]); // reconstructs lower blocks
|
||||
ret._internal[c1+N/2][c2] = conjugate(ret._internal[c1][c2-N/2]); // from upper blocks
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Ta(ret);
|
||||
ret = (ret - adj(ret))*0.5;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,6 +117,8 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
SU<Nc>::HotConfiguration(pRNG,Umu); //refresh
|
||||
U = PeekIndex<LorentzIndex>(Umu,1);
|
||||
|
||||
std::cout << GridLogMessage << "Testing ProjectOnGaugeGroup" << std::endl;
|
||||
U = U + Delta*identity;
|
||||
@ -214,7 +216,9 @@ int main (int argc, char **argv)
|
||||
std::cout <<GridLogMessage << std::endl;
|
||||
std::cout << GridLogMessage << "Testing SpTa" << std::endl;
|
||||
|
||||
U = PeekIndex<LorentzIndex>(Umu,1);
|
||||
SU<Nc>::HotConfiguration(pRNG,Umu);//refresh
|
||||
U = PeekIndex<LorentzIndex>(Umu,2);
|
||||
|
||||
U = U + Delta*identity;
|
||||
std::cout << GridLogMessage << "Matrix deformed " << std::endl;
|
||||
std::cout << GridLogMessage << "Apply SpTa to deformed matrix" << std::endl;
|
||||
@ -224,19 +228,19 @@ int main (int argc, char **argv)
|
||||
std::cout << GridLogMessage << "SpTa ::: T - Tda = " << norm2(aux) << std::endl;
|
||||
aux = U + adj(U);
|
||||
std::cout << GridLogMessage << "SpTa ::: T + Tda = " << norm2(aux) << std::endl;
|
||||
assert( norm2(aux) - 1 < 1e-8);
|
||||
|
||||
std::cout << GridLogMessage << "Check that Omega U Omega = conj(U)" << std::endl;
|
||||
std::cout << GridLogMessage << "Check that Omega T Omega + conj(T) = 0 " << std::endl;
|
||||
|
||||
LatticeColourMatrixD Omega(&Grid);
|
||||
Sp<Nc>::Omega(Omega);
|
||||
aux = Omega*U*Omega - conjugate(U);
|
||||
std::cout << GridLogMessage << "Omega U Omega - conj(U) = " << norm2(aux) << std::endl;
|
||||
aux = Omega*U*Omega + conjugate(U);
|
||||
assert( norm2(aux) < 1e-8);
|
||||
|
||||
|
||||
std::cout << GridLogMessage << "Checking the structure is " << std::endl;
|
||||
std::cout << GridLogMessage << "U = ( W X ) " << std::endl;
|
||||
std::cout << GridLogMessage << " ( X^* -W^* ) " << std::endl;
|
||||
std::cout << GridLogMessage << " ( -X^* W^* ) " << std::endl;
|
||||
std::cout <<GridLogMessage << std::endl;
|
||||
for (int c1 = 0; c1 < nsp; c1++) //check on W
|
||||
{
|
||||
@ -245,7 +249,7 @@ int main (int argc, char **argv)
|
||||
auto W = PeekIndex<ColourIndex>(U,c1,c2);
|
||||
auto Wstar = PeekIndex<ColourIndex>(U,c1+nsp,c2+nsp);
|
||||
auto Ww = conjugate( Wstar );
|
||||
auto amizero = sum(W + Ww);
|
||||
auto amizero = sum(W - Ww);
|
||||
auto amizeroo = TensorRemove(amizero);
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
amizeroo *= i;
|
||||
@ -261,73 +265,7 @@ int main (int argc, char **argv)
|
||||
auto X = PeekIndex<ColourIndex>(U,c1,c2+nsp);
|
||||
auto minusXstar = PeekIndex<ColourIndex>(U,c1+nsp,c2);
|
||||
auto minusXx = conjugate(minusXstar);
|
||||
auto amizero = sum (X - minusXx);
|
||||
auto amizeroo = TensorRemove(amizero);
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
amizeroo *= i;
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
}
|
||||
}
|
||||
|
||||
//test Ta
|
||||
/*
|
||||
U = U + 666.*identity;
|
||||
Up = Ta(U);
|
||||
aux = Up - adj(Up);
|
||||
std::cout << GridLogMessage << "TA !!! T - Tda = " << norm2(aux) << std::endl;
|
||||
aux = Up + adj(Up);
|
||||
std::cout << GridLogMessage << "TA !!! T + Tda = " << norm2(aux) << std::endl;*/
|
||||
|
||||
// test taProj
|
||||
std::cout << GridLogMessage << "Testing taProj" << std::endl;
|
||||
U = U + Delta*identity;
|
||||
std::cout << GridLogMessage << "Matrix deformed " << std::endl;
|
||||
std::cout << GridLogMessage << "Apply taProj to deformed matrix" << std::endl;
|
||||
Sp<Nc>::taProj(U, Up);
|
||||
aux = Up - adj(Up);
|
||||
std::cout << GridLogMessage << "taProj ::: T - Tda = " << norm2(aux) << std::endl;
|
||||
aux = Up + adj(Up);
|
||||
std::cout << GridLogMessage << "taProj ::: T + Tda = " << norm2(aux) << std::endl;
|
||||
|
||||
std::cout << GridLogMessage << "Check that Omega U Omega = conj(U)" << std::endl;
|
||||
Sp<Nc>::Omega(Omega);
|
||||
aux = Omega*Up*Omega - conjugate(Up);
|
||||
std::cout << GridLogMessage << "Omega U Omega - conj(U) = " << norm2(aux) << std::endl;
|
||||
assert( norm2(aux) < 1e-8);
|
||||
// before it was
|
||||
aux = Omega*U*Omega - conjugate(U);
|
||||
std::cout << GridLogMessage << " before taProj Omega U Omega - conj(U) = " << norm2(aux) << std::endl;
|
||||
|
||||
U = Up;
|
||||
|
||||
std::cout << GridLogMessage << "Checking the structure is " << std::endl;
|
||||
std::cout << GridLogMessage << "U = ( W X ) " << std::endl;
|
||||
std::cout << GridLogMessage << " ( X^* -W^* ) " << std::endl;
|
||||
std::cout <<GridLogMessage << std::endl;
|
||||
for (int c1 = 0; c1 < nsp; c1++) //check on W
|
||||
{
|
||||
for (int c2 = 0; c2 < nsp; c2++)
|
||||
{
|
||||
auto W = PeekIndex<ColourIndex>(U,c1,c2);
|
||||
auto Wstar = PeekIndex<ColourIndex>(U,c1+nsp,c2+nsp);
|
||||
auto Ww = conjugate( Wstar );
|
||||
auto amizero = sum(W + Ww);
|
||||
auto amizeroo = TensorRemove(amizero);
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
amizeroo *= i;
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int c1 = 0; c1 < nsp ; c1++)
|
||||
{
|
||||
for (int c2 = 0; c2 < nsp; c2++)
|
||||
{
|
||||
auto X = PeekIndex<ColourIndex>(U,c1,c2+nsp);
|
||||
auto minusXstar = PeekIndex<ColourIndex>(U,c1+nsp,c2);
|
||||
auto minusXx = conjugate(minusXstar);
|
||||
auto amizero = sum (X - minusXx);
|
||||
auto amizero = sum (X + minusXx);
|
||||
auto amizeroo = TensorRemove(amizero);
|
||||
assert( amizeroo.real() < 10e-6 );
|
||||
amizeroo *= i;
|
||||
|
Loading…
Reference in New Issue
Block a user