6 #ifndef CENTRAL_TPREC_NOSPIN_UTILS_H
7 #define CENTRAL_TPREC_NOSPIN_UTILS_H
8 #include "qdp_config.h"
22 namespace CentralTPrecNoSpinUtils
24 typedef PScalar<PColorMatrix<RComplex<REAL>, 3> > CMat;
25 typedef PSpinVector<PColorVector<RComplex<REAL>, 3>, 2 > HVec_site;
29 void TOp(LatticeHalfFermion&
chi,
30 const LatticeHalfFermion&
psi,
31 const multi1d<LatticeColorMatrix>&
u,
32 const multi2d<int>& tsite,
35 const bool schroedingerTP=
false) {
36 const int t_index = 3;
37 int Nt = tsite.size1();
39 for(
int site=0; site < tsite.size2(); site++) {
60 chi.elem(tsite(site,Nt-1)) = fact.elem()*
psi.elem( tsite(site,Nt-1) );
62 if( ! schroedingerTP ) {
63 chi.elem(tsite(site,Nt-1)) -=
u[t_index].elem(tsite(site,Nt-1)) *
psi.elem( tsite(site,0) );
66 for(
int t=Nt-2;
t >= 0;
t--) {
67 chi.elem( tsite(site,
t) ) = fact.elem()*
psi.elem(tsite(site,
t));
68 chi.elem( tsite(site,
t) ) -=
u[t_index].elem(tsite(site,
t)) *
psi.elem(tsite(site,
t+1) );
87 chi.elem(tsite(site,0)) = fact.elem()*
psi.elem(tsite(site,0));
90 if( !schroedingerTP ) {
91 chi.elem(tsite(site,0)) -= adj(
u[t_index].elem(tsite(site,Nt-1)) ) *
psi.elem(tsite(site,Nt-1));
94 for(
int t=1;
t < Nt;
t++) {
96 chi.elem(tsite(site,
t)) = fact.elem() *
psi.elem(tsite(site,
t));
97 chi.elem(tsite(site,
t)) -= adj(
u[t_index].elem( tsite(site,
t-1) ) ) *
psi.elem(tsite(site,
t-1) );
102 QDPIO::cout <<
"Unknown Sign " << std::endl;
113 void invTOp(LatticeHalfFermion&
chi,
114 const LatticeHalfFermion&
psi,
115 const multi1d<LatticeColorMatrix>&
u,
116 const multi2d<int>& tsite,
117 const multi2d<CMat>& P_mat,
118 const multi2d<CMat>& P_mat_dag,
119 const multi1d<CMat>& Q_mat_inv,
120 const multi1d<CMat>& Q_mat_dag_inv,
124 const bool schroedingerTP=
false)
126 #ifndef QDP_IS_QDPJIT
128 int Nt=tsite.size1();
130 for(
int site=0; site < tsite.size2(); site++) {
154 chi.elem( tsite(site,Nt-1) )= invfact.elem()*
psi.elem( tsite(site,Nt-1) );
158 for(
int t=Nt-2;
t >= 0;
t--) {
159 chi.elem( tsite(site,
t) ) =
psi.elem( tsite(site,
t) );
160 chi.elem( tsite(site,
t) ) +=
u[t_index].elem( tsite(site,
t) ) *
chi.elem( tsite(site,
t+1) );
161 chi.elem( tsite(site,
t) ) *= invfact.elem();
168 if( !schroedingerTP ) {
176 HVec_site x_site = Q_mat_inv(site) *
chi.elem( tsite(site,0) );
183 if( Nt-1-t_max <= 0 ) {
190 for(
int t=Nt-1;
t > loop_end ;
t--) {
191 chi.elem( tsite(site,
t) ) -= P_mat(site,
t) * x_site;
211 chi.elem( tsite(site,0) )= invfact.elem()*
psi.elem( tsite(site,0) );
213 for(
int t=1;
t < Nt;
t++) {
214 chi.elem( tsite(site,
t) ) =
psi.elem( tsite(site,
t) );
215 chi.elem( tsite(site,
t) ) += adj(
u[t_index].elem(tsite(site,
t-1) ) ) *
chi.elem( tsite(site,
t-1) );
216 chi.elem( tsite(site,
t) ) *= invfact.elem();
222 if( !schroedingerTP ) {
226 HVec_site x_site = Q_mat_dag_inv(site) *
chi.elem( tsite(site,Nt-1) );
230 if ( t_max >= Nt-1 ) {
237 for(
int t=0;
t < loop_end;
t++) {
238 chi.elem( tsite(site,
t) ) -= P_mat_dag(site,
t)*x_site;
245 QDPIO::cout <<
"Unknown Sign " << std::endl;
255 void invert3by3( CMat& M_inv,
const CMat& M )
257 #ifndef QDP_IS_QDPJIT
267 PScalar<PColorMatrix<RComplex<REAL>, Nc> > M_tmp;
268 for(
int i=0;
i < 3;
i++) {
269 for(
int j=0;
j < 3;
j++) {
270 M_tmp.elem().elem(
i,
j).real() = 0;
271 M_tmp.elem().elem(
i,
j).imag() = 0;
273 M_tmp.elem().elem(
i,
i).real() = 1;
276 PScalar<PColorMatrix<RComplex<REAL>, Nc> > M_local = M;
295 for(
int i = 1;
i < Nvec;
i++) {
303 REAL maxnorm = M_local.elem().elem(
i,
i).real()*M_local.elem().elem(
i,
i).real()
304 + M_local.elem().elem(
i,
i).imag()*M_local.elem().elem(
i,
i).imag();
309 for(
int row=
i+1; row < Nvec; row++) {
310 REAL normcheck = M_local.elem().elem(row,
i).real()*M_local.elem().elem(row,
i).real()
311 + M_local.elem().elem(row,
i).imag()*M_local.elem().elem(row,
i).imag();
313 if ( toBool( normcheck > maxnorm ) ) {
327 for(
int j=0;
j < Nvec;
j++ ) {
329 tmp.elem().elem().elem() = M_local.elem().elem(
i,
j);
330 M_local.elem().elem(
i,
j) = M_local.elem().elem(maxrow,
j);
331 M_local.elem().elem(maxrow,
j) =
tmp.elem().elem().elem();
334 tmp.elem().elem().elem() = M_tmp.elem().elem(
i,
j);
335 M_tmp.elem().elem(
i,
j) = M_tmp.elem().elem(maxrow,
j);
336 M_tmp.elem().elem(maxrow,
j) =
tmp.elem().elem().elem();
350 for(
int j=0;
j <
i;
j++) {
354 for(
int k = 0;
k <
j;
k++) {
355 sum_LU.elem().elem().elem() += M_local.elem().elem(
i,
k)*M_local.elem().elem(
k,
j);
358 M_local.elem().elem(
i,
j) -= sum_LU.elem().elem().elem();
359 M_local.elem().elem(
i,
j) /= M_local.elem().elem(
j,
j);
362 for(
int j=
i;
j < Nvec;
j++) {
364 for(
int k = 0;
k <
i;
k++) {
365 sum_LU.elem().elem().elem() += M_local.elem().elem(
i,
k)*M_local.elem().elem(
k,
j);
367 M_local.elem().elem(
i,
j) -= sum_LU.elem().elem().elem();
381 multi1d< Complex >
y(Nvec);
383 for(
int k=0;
k < Nvec;
k++) {
385 y[0].elem().elem().elem() = M_tmp.elem().elem(0,
k);
386 for(
int i=1;
i < Nvec;
i++) {
387 y[
i].elem().elem().elem() = M_tmp.elem().elem(
i,
k);
388 for(
int j=0;
j <
i;
j++) {
389 y[
i].elem().elem().elem() -= M_local.elem().elem(
i,
j)*
y[
j].elem().elem().elem();
394 M_inv.elem().elem(Nvec-1,
k) =
y[Nvec-1].elem().elem().elem() / M_local.elem().elem(Nvec-1, Nvec-1);
396 for(
int i = Nvec-2;
i >= 0;
i--) {
397 Complex tmpcmpx =
y[
i];
398 for(
int j=
i+1;
j < Nvec;
j++) {
399 tmpcmpx.elem().elem().elem() -= M_local.elem().elem(
i,
j)*M_inv.elem().elem(
j,
k);
401 M_inv.elem().elem(
i,
k) = tmpcmpx.elem().elem().elem() /M_local.elem().elem(
i,
i);
409 Double logDet(
const CMat& M) {
410 #ifndef QDP_IS_QDPJIT
432 ret_val.elem().elem().elem() = M.elem().elem(0,0)*( M.elem().elem(1,1)*M.elem().elem(2,2) - M.elem().elem(2,1)*M.elem().elem(1,2) );
433 ret_val.elem().elem().elem() -= M.elem().elem(0,1)*( M.elem().elem(1,0)*M.elem().elem(2,2) - M.elem().elem(2,0)*M.elem().elem(1,2) );
434 ret_val.elem().elem().elem() += M.elem().elem(0,2)*( M.elem().elem(1,0)*M.elem().elem(2,1) - M.elem().elem(2,0)*M.elem().elem(1,1) );
436 return Double(log(real(ret_val)));
444 void derivLogDet(multi1d<LatticeColorMatrix>&
F,
445 const multi1d<LatticeColorMatrix>&
U,
446 const multi1d<CMat>&
Q,
447 const multi2d<int>& tsites,
450 const bool schroedingerTP=
false)
452 #ifndef QDP_IS_QDPJIT
464 if( ! schroedingerTP ) {
466 LatticeColorMatrix T1;
467 Real invmass = Real(1)/ NdPlusM;
471 int Nspace=tsites.size2();
472 int Nt = tsites.size1();
475 for(
int t=0;
t < Nt;
t++) {
479 for(
int site=0; site < Nspace; site++) {
482 for(
int t=0;
t < Nt;
t++) {
488 for(
int r=0;
r < 3;
r++) {
489 for(
int c=0;
c < 3;
c++) {
490 F_tmp.elem().elem(
r,
c).real() = 0;
491 F_tmp.elem().elem(
r,
c).imag() = 0;
495 for(
int r=0;
r < 3;
r++) {
496 F_tmp.elem().elem(
r,
r).real() = 1;
497 F_tmp.elem().elem(
r,
r).imag() = 0;
503 for(
int j=
t+1;
j < Nt;
j++) {
505 int s = tsites(site,
j);
506 F_tmp = F_tmp2 *
U[t_dir].elem(
s);
511 F_tmp = F_tmp2 *
Q[site];
514 for(
int j=0;
j <
t;
j++) {
516 int s = tsites(site,
j);
517 F_tmp = F_tmp2*
U[t_dir].elem(
s);
520 T1.elem(tsites(site,
t)) = F_tmp;
526 F[t_dir] = factor*T1;
541 void derivLogDet(multi1d<LatticeColorMatrix>&
F,
542 const multi1d<LatticeColorMatrix>&
U,
543 const multi2d<CMat>&
Q,
544 const multi3d<int>& tsites,
547 const bool schroedingerTP=
false)
549 #ifndef QDP_IS_QDPJIT
561 if( ! schroedingerTP ) {
563 LatticeColorMatrix T1;
564 Real invmass = Real(1)/ NdPlusM;
568 int Nspace=tsites.size2();
569 int Nt = tsites.size1();
572 for(
int t=0;
t < Nt;
t++) {
576 for(
int cb3=0; cb3 < 2; cb3++) {
577 for(
int site=0; site < Nspace; site++) {
580 for(
int t=0;
t < Nt;
t++) {
586 for(
int r=0;
r < 3;
r++) {
587 for(
int c=0;
c < 3;
c++) {
588 F_tmp.elem().elem(
r,
c).real() = 0;
589 F_tmp.elem().elem(
r,
c).imag() = 0;
593 for(
int r=0;
r < 3;
r++) {
594 F_tmp.elem().elem(
r,
r).real() = 1;
595 F_tmp.elem().elem(
r,
r).imag() = 0;
601 for(
int j=
t+1;
j < Nt;
j++) {
603 int s = tsites(cb3,site,
j);
604 F_tmp = F_tmp2 *
U[t_dir].elem(
s);
609 F_tmp = F_tmp2 *
Q[cb3][site];
612 for(
int j=0;
j <
t;
j++) {
614 int s = tsites(cb3,site,
j);
615 F_tmp = F_tmp2*
U[t_dir].elem(
s);
618 T1.elem(tsites(cb3,site,
t)) = F_tmp;
624 F[t_dir] = factor*T1;
Primary include file for CHROMA library code.
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
multi1d< LatticeFermion > chi(Ncb)
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
multi1d< LatticeColorMatrix > U
multi1d< LatticeColorMatrix > Q
static INTERNAL_PRECISION F