00001 #include <config.h>
00002 #include <stdio.h>
00003 #include <util/gjp.h>
00004 #include <util/site.h>
00005 #include <util/qcdio.h>
00006 #include <alg/alg_tcharge.h>
00007 #include <comms/glb.h>
00008 CPS_START_NAMESPACE
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 void ZeroReal(Matrix& m)
00025 {
00026 Matrix temp;
00027 temp.Dagger( m );
00028 m-=temp;
00029 m*=0.5;
00030 }
00031
00050 Complex MkTop( Matrix plaqs1[], Matrix plaqs2[] )
00051 {
00052 const Float nfactor(-1.0/( 4 * 3.141592654 * 3.141592654 ));
00053
00054 Matrix Top;
00055
00056
00057
00058 Top.DotMEqual( plaqs1[1] , plaqs2[4] );
00059
00060 Top *= -1.0 ;
00061
00062
00063 Top.DotMPlus ( plaqs1[2] , plaqs2[3] );
00064 Top.DotMPlus ( plaqs1[5] , plaqs2[0] );
00065
00066 return nfactor*Top.Tr();
00067 }
00068
00069
00070
00075 void CloverLeaf(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
00076 {
00077 Matrix P0,P1,P2,P3;
00078
00079 P0.ZeroMatrix();
00080 P1.ZeroMatrix();
00081 P2.ZeroMatrix();
00082 P3.ZeroMatrix();
00083
00084
00085
00086
00087
00088 int dirs0[4]={mu,nu, mu+4, nu+4};
00089 lattice.PathOrdProdPlus(P0, pos, dirs0, 4);
00090
00091
00092 int dirs1[4]={nu+4,mu+4, nu, mu};
00093 lattice.PathOrdProdPlus(P1, pos, dirs1, 4);
00094
00095 int dirs2[4]={nu,mu+4, nu+4, mu};
00096 lattice.PathOrdProdPlus(P2, pos, dirs2, 4);
00097
00098 int dirs3[4]={mu,nu+4, mu+4, nu};
00099 lattice.PathOrdProdPlus(P3, pos, dirs3, 4);
00100
00101
00102
00103 P0 -= P1;
00104 P0 += P2;
00105 P0 -= P3;
00106 P0 *= 0.25;
00107
00108 moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
00109
00110 }
00111
00112
00113
00114
00115
00116 void CloverLeafRect(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
00117 {
00118 Matrix P0,P1,P2,P3;
00119
00120
00121
00122 P0.ZeroMatrix();
00123 P1.ZeroMatrix();
00124 P2.ZeroMatrix();
00125 P3.ZeroMatrix();
00126
00127
00128
00129
00130
00131 {
00132 int dirs0[6]={mu,mu, nu, mu+4,mu+4, nu+4};
00133 lattice.PathOrdProdPlus(P0, pos, dirs0, 6);
00134
00135
00136 int dirs1[6]={nu+4,mu+4,mu+4, nu, mu,mu};
00137 lattice.PathOrdProdPlus(P1, pos, dirs1, 6);
00138
00139 int dirs2[6]={nu,mu+4,mu+4, nu+4, mu,mu};
00140 lattice.PathOrdProdPlus(P2, pos, dirs2, 6);
00141
00142 int dirs3[6]={mu,mu, nu+4, mu+4,mu+4, nu};
00143 lattice.PathOrdProdPlus(P3, pos, dirs3, 6);
00144 }
00145
00146 P0 -= P1;
00147 P0 += P2;
00148 P0 -= P3;
00149
00150
00151 moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
00152
00153
00154 P0.ZeroMatrix();
00155 P1.ZeroMatrix();
00156 P2.ZeroMatrix();
00157 P3.ZeroMatrix();
00158
00159
00160
00161
00162
00163 {
00164 int dirs0[6]={mu,nu,nu, mu+4, nu+4,nu+4};
00165 lattice.PathOrdProdPlus(P0, pos, dirs0, 6);
00166
00167
00168 int dirs1[6]={nu+4,nu+4,mu+4, nu,nu, mu};
00169 lattice.PathOrdProdPlus(P1, pos, dirs1, 6);
00170
00171 int dirs2[6]={nu,nu,mu+4, nu+4,nu+4, mu};
00172 lattice.PathOrdProdPlus(P2, pos, dirs2, 6);
00173
00174 int dirs3[6]={mu,nu+4,nu+4, mu+4, nu, nu};
00175 lattice.PathOrdProdPlus(P3, pos, dirs3, 6);
00176 }
00177
00178 P0 -= P1;
00179 P0 += P2;
00180 P0 -= P3;
00181
00182 pl += P0;
00183 pl *= 1.0/16.0;
00184 }
00185
00186 void CloverLeaf1x3(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
00187 {
00188 Matrix P0,P1,P2,P3;
00189
00190
00191
00192 P0.ZeroMatrix();
00193 P1.ZeroMatrix();
00194 P2.ZeroMatrix();
00195 P3.ZeroMatrix();
00196
00197
00198
00199
00200
00201 {
00202 int dirs0[8]={mu,mu, mu,
00203 nu,
00204 mu+4,mu+4,mu+4,
00205 nu+4};
00206 lattice.PathOrdProdPlus(P0, pos, dirs0, 8);
00207
00208
00209 int dirs1[8]={nu+4,
00210 mu+4,mu+4, mu+4,
00211 nu,
00212 mu,mu,mu };
00213 lattice.PathOrdProdPlus(P1, pos, dirs1, 8);
00214
00215 int dirs2[8]={nu,
00216 mu+4,mu+4,mu+4,
00217 nu+4,
00218 mu,mu,mu};
00219 lattice.PathOrdProdPlus(P2, pos, dirs2, 8);
00220
00221 int dirs3[8]={mu,mu,mu,
00222 nu+4,
00223 mu+4,mu+4, mu+4,
00224 nu};
00225 lattice.PathOrdProdPlus(P3, pos, dirs3, 8);
00226 }
00227
00228 P0 -= P1;
00229 P0 += P2;
00230 P0 -= P3;
00231
00232
00233 moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
00234
00235
00236 P0.ZeroMatrix();
00237 P1.ZeroMatrix();
00238 P2.ZeroMatrix();
00239 P3.ZeroMatrix();
00240
00241
00242
00243 {
00244 int dirs0[8]={mu,
00245 nu,nu,nu,
00246 mu+4,
00247 nu+4,nu+4,nu+4};
00248 lattice.PathOrdProdPlus(P0, pos, dirs0, 8);
00249
00250 int dirs1[8]={nu+4,nu+4,nu+4,
00251 mu+4,
00252 nu,nu,nu,
00253 mu};
00254 lattice.PathOrdProdPlus(P1, pos, dirs1, 8);
00255
00256 int dirs2[8]={nu,nu,nu,
00257 mu+4,
00258 nu+4,nu+4,nu+4,
00259 mu};
00260 lattice.PathOrdProdPlus(P2, pos, dirs2, 8);
00261
00262 int dirs3[8]={mu,
00263 nu+4,nu+4,nu+4,
00264 mu+4,
00265 nu, nu, nu};
00266 lattice.PathOrdProdPlus(P3, pos, dirs3, 8);
00267 }
00268
00269 P0 -= P1;
00270 P0 += P2;
00271 P0 -= P3;
00272
00273 pl += P0;
00274 pl *= 1.0/24.0;
00275 }
00276
00277 void CloverLeaf2x2(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
00278 {
00279 Matrix P0,P1,P2,P3;
00280
00281 P0.ZeroMatrix();
00282 P1.ZeroMatrix();
00283 P2.ZeroMatrix();
00284 P3.ZeroMatrix();
00285
00286
00287
00288 int dirs0[8]={mu,mu, nu, nu, mu+4,mu+4, nu+4, nu+4};
00289 lattice.PathOrdProdPlus(P0, pos, dirs0, 8);
00290
00291 int dirs1[8]={nu+4, nu+4, mu+4, mu+4, nu, nu, mu,mu };
00292 lattice.PathOrdProdPlus(P1, pos, dirs1, 8);
00293
00294 int dirs2[8]={nu, nu, mu+4, mu+4, nu+4, nu+4, mu, mu };
00295 lattice.PathOrdProdPlus(P2, pos, dirs2, 8);
00296
00297 int dirs3[8]={mu,mu, nu+4, nu+4, mu+4, mu+4, nu, nu };
00298 lattice.PathOrdProdPlus(P3, pos, dirs3, 8);
00299
00300 P0 -= P1;
00301 P0 += P2;
00302 P0 -= P3;
00303 P0 *= 1.0/16;
00304
00305 moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
00306
00307 }
00308
00309 void CloverLeaf3x3(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
00310 {
00311 Matrix P0,P1,P2,P3;
00312
00313 P0.ZeroMatrix();
00314 P1.ZeroMatrix();
00315 P2.ZeroMatrix();
00316 P3.ZeroMatrix();
00317
00318
00319
00320 int dirs0[12]={ mu, mu, mu,
00321 nu, nu, nu,
00322 mu+4, mu+4, mu+4,
00323 nu+4, nu+4, nu+4 };
00324 lattice.PathOrdProdPlus(P0, pos, dirs0, 12);
00325
00326 int dirs1[12]={nu+4, nu+4, nu+4,
00327 mu+4, mu+4, mu+4,
00328 nu, nu, nu,
00329 mu, mu, mu };
00330 lattice.PathOrdProdPlus(P1, pos, dirs1, 12);
00331
00332 int dirs2[12]={nu, nu, nu,
00333 mu+4, mu+4, mu+4,
00334 nu+4, nu+4, nu+4,
00335 mu, mu , mu };
00336 lattice.PathOrdProdPlus(P2, pos, dirs2, 12);
00337
00338 int dirs3[12]={mu , mu, mu,
00339 nu+4, nu+4, nu+4,
00340 mu+4, mu+4, mu+4,
00341 nu , nu , nu };
00342 lattice.PathOrdProdPlus(P3, pos, dirs3, 12);
00343
00344 P0 -= P1;
00345 P0 += P2;
00346 P0 -= P3;
00347 P0 *= 1./(9*4);
00348
00349 moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
00350 }
00351
00352
00353
00354 const int nfunc(5);
00355
00356 typedef void (*leaf_function)(Lattice&, Matrix&, int*, int, int);
00357
00358
00359 leaf_function leaf_map[5] = { &CloverLeaf,
00360 &CloverLeafRect,
00361 &CloverLeaf2x2,
00362 &CloverLeaf3x3,
00363 &CloverLeaf1x3 };
00364
00365 const char* names[5] = { "1x1",
00366 "1x2",
00367 "2x2",
00368 "3x3",
00369 "1x3" };
00370
00371
00372 void AlgTcharge::run()
00373 {
00374 Lattice& lattice( AlgLattice() );
00375
00376 Float tmat[nfunc][nfunc];
00377 for (int f1(0);f1<nfunc;f1++)
00378 for (int f2(0);f2<nfunc;f2++)
00379 tmat[f1][f2] = 0;
00380
00381
00382 Site nloop;
00383
00384 while ( nloop.LoopsOverNode() )
00385 {
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396 Matrix plaqs[nfunc][6];
00397
00398
00399
00400
00401
00402 int mu;
00403 int nu;
00404 int index(0);
00405
00406 for (mu=0;mu<3;++mu)
00407 {
00408 for (nu=mu+1;nu<4;nu++)
00409 {
00410 for (int f(0);f<nfunc;f++)
00411 {
00412 (*(leaf_map[f]))( lattice, plaqs[f][index], nloop.pos(), mu, nu );
00413 ZeroReal(plaqs[f][index]);
00414 }
00415 index++;
00416 }
00417 }
00418 for (int f1(0);f1<nfunc;f1++)
00419 {
00420 for (int f2(f1);f2<nfunc;f2++)
00421 {
00422 tmat[f1][f2] += MkTop(plaqs[f1],plaqs[f2]).real();
00423 }
00424 }
00425 }
00426
00427
00428 for (int f1(0);f1<nfunc;f1++)
00429 {
00430 for (int f2(f1);f2<nfunc;f2++)
00431 {
00432 glb_sum( &tmat[f1][f2] );
00433 }
00434 }
00435
00436
00437
00438
00439 if(common_arg->filename != 0)
00440 {
00441 char *fname = "alg_tcharge()";
00442 FILE *fp;
00443 if( (fp = Fopen(common_arg->filename, "a")) == NULL ) {
00444 ERR.FileA(cname,fname,common_arg->filename);
00445 }
00446 Fprintf(fp,"AlgTcharge:\n");
00447 Fprintf(fp,"nleaf : %i\n",nfunc);
00448 for (int f(0);f<nfunc;f++)
00449 Fprintf(fp," %i : %s\n",f,names[f]);
00450 for (int f1(0);f1<nfunc;f1++)
00451 {
00452 for (int f2(f1);f2<nfunc;f2++)
00453 {
00454 Fprintf(fp,"%i %i : %15e\n",f1,f2,tmat[f1][f2]);
00455 }
00456 }
00457 Fclose(fp);
00458 }
00459
00460 }
00461 CPS_END_NAMESPACE
00462