Exemple #1
0
QDP_Subset *
qhmc_qopqdp_qsubset_from_string(lua_State *L, lattice_t *lat,
				const char *s, int *n)
{
  *n = 0;
  if(s==NULL) return NULL;
  QDP_Subset *subs = NULL;
  QDP_Lattice *qlat = lat->qlat;
  switch(s[0]) {
  case 'a':
    subs = QDP_all_and_empty_L(qlat);
    if(strcmp(s,"all")==0) *n = 1;
    else *n = 2;
    break;
  case 'e':
    *n = 1;
    if(strncmp(s,"evenodd",7)==0 || strncmp(s,"evenandodd",10)==0) *n = 2;
    subs = QDP_even_and_odd_L(qlat);
    {
      int t=0;
      int nn = sscanf(s,"%*[^0-9]%i",&t);
      if(nn && t>=1 && t<=lat->nd) {
	subs = qhmcqdp_get_eodir(lat, t-1);
      }
    }
    break;
  case 'o':
    *n = 1;
    subs = 1 + QDP_even_and_odd_L(qlat);
    {
      int t=0;
      int nn = sscanf(s,"%*[^0-9]%i",&t);
      if(nn && t>=1 && t<=lat->nd) {
	subs = 1 + qhmcqdp_get_eodir(lat, t-1);
      }
    }
    break;
  case 's':
    if(strncmp(s,"staggered",9)==0) {
      int ns = 1 << QDP_ndim_L(qlat);
      if(strcmp(s+9,"")==0) {
	subs = qhmcqdp_get_staggered(lat);
	*n = ns;
      } else {
	int t=0;
	int nn = sscanf(s+9,"%i",&t);
	if(nn && t>=0 && t<ns) {
	  subs = &qhmcqdp_get_staggered(lat)[t];
	  *n = 1;
	}
      }
    }
    break;
  case 't':
    if(strncmp(s,"timeslice",9)==0) {
      int nt = QDP_coord_size_L(qlat,QDP_ndim_L(qlat)-1);
      if(strcmp(s+9,"s")==0) {
	subs = qhmcqdp_get_timeslices(lat);
	*n = nt;
      } else {
	int t=0;
	int nn = sscanf(s+9,"%i",&t);
	if(nn && t>=0 && t<nt) {
	  subs = &qhmcqdp_get_timeslices(lat)[t];
	  *n = 1;
	}
      }
    }
    break;
  }
  return subs;
}
void 
QOP_symanzik_1loop_gauge_heatbath_qdp(QOP_info_t *info,
				      QDP_ColorMatrix *links[],
				      QLA_Real beta,
				      QOP_gauge_coeffs_t *coeffs,
				      QDP_RandomState *rs0,
				      int nup, int nhb, int nover)
{
#define NC QDP_get_nc(links[0])
  double dtime = QOP_time();
  double nflops = 0;
  if(coeffs->adjoint_plaquette) {
    QOP_error("%s: adj plaq not supported\n", __func__);
  }
  fac = beta/QLA_Nc;
  int imp = (coeffs->rectangle!=0)||(coeffs->parallelogram!=0);
  QDP_Lattice *lat = QDP_get_lattice_M(links[0]);
  int nd = QDP_ndim_L(lat);
  QDP_Subset *cbs=QDP_even_and_odd_L(lat);
  int ncb = 2;
  if(imp) {
    ncb = 32;
    cbs = QOP_get_sub32(lat);
  }

  QDP_ColorMatrix *staple = QDP_create_M_L(lat);
  QDP_ColorMatrix *v = QDP_create_M_L(lat);
  QDP_ColorMatrix *tmp = QDP_create_M_L(lat);
  rs = QDP_expose_S(rs0);

  for(int up=0; up<nup; up++) {
    for(int hb=0; hb<nhb; hb++) {
      for(int cb=0; cb<ncb; cb++) {
	QDP_Subset subset = cbs[cb];
	for(int mu=0; mu<nd; mu++) {
	  QDP_M_eq_zero(staple, subset);
	  QOP_symanzik_1loop_gauge_staple_qdp(info, links, staple, mu, coeffs, cbs, cb);
	  QDP_M_eq_M_times_Ma(v, links[mu], staple, subset);
	  QDP_M_eq_funcit(v, hb_func, subset);
	  QDP_M_eq_M_times_M(tmp, v, links[mu], subset);
	  QDP_M_eq_M(links[mu], tmp, subset);
	}
      }
    }
    for(int over=0; over<nover; over++) {
      for(int cb=0; cb<ncb; cb++) {
	QDP_Subset subset = cbs[cb];
	for(int mu=0; mu<nd; mu++) {
	  QDP_M_eq_zero(staple, subset);
	  QOP_symanzik_1loop_gauge_staple_qdp(info, links, staple, mu, coeffs, cbs, cb);
	  QDP_M_eq_M_times_Ma(v, links[mu], staple, subset);
	  QDP_M_eq_funcit(v, over_func, subset);
	  QDP_M_eq_M_times_M(tmp, v, links[mu], subset);
	  QDP_M_eq_M(links[mu], tmp, subset);
	}
      }
    }
  }

  QDP_reset_S(rs0);
  QDP_destroy_M(tmp);
  QDP_destroy_M(v);
  QDP_destroy_M(staple);

  info->final_sec = QOP_time() - dtime;
  info->final_flop = nflops*QDP_sites_on_node; 
  info->status = QOP_SUCCESS;
#undef NC
}