示例#1
0
static int
q_I_get(lua_State *L)
{
    switch (qlua_qtype(L, 2)) {
    case qTable: {
        mLatInt *V = qlua_checkLatInt(L, 1, NULL);
        mLattice *S = qlua_ObjLattice(L, 1);
        QLA_Int *locked;
        int *idx = 0;
        int z;

        idx = qlua_checklatcoord(L, 2, S);
        CALL_QDP(L);
        locked = QDP_expose_I(V->ptr);
        int site_node = QDP_node_number_L(S->lat, idx);
        if (site_node == QDP_this_node) {
            z = QLA_elem_I(locked[QDP_index_L(S->lat, idx)]);
        }
        QDP_reset_I(V->ptr);
        qlua_free(L, idx);
        XMP_dist_int_array(site_node, 1, &z);
        lua_pushnumber(L, z);

        return 1;
    }
    case qString:
        return qlua_selflookup(L, 1, luaL_checkstring(L, 2));
    default:
        break;
    }

    return qlua_badindex(L, "Int");
}
示例#2
0
static double
q_CL_f_reader(int mu, int nu, const int p[], int a, int b, int re_im, void *env)
{
    QLA_D_Real xx;
    QCArgs *args = env;
    int i = QDP_index_L(args->lat, p);
    int d, xm, xn;

    for (d = 0, xm = 0; xm < QOP_CLOVER_DIM; xm++) {
        for (xn = xm + 1; xn < QOP_CLOVER_DIM; xn++, d++) {
            if ((xn == nu) && (xm == mu))
                goto found;
        }
    }
    return 0.0; /* should never happen */

found:
    /* NB:m stores F * 8i */
    if (re_im == 0) {
        QLA_r_eq_Im_c(xx, QLA_elem_M(args->uf[Nu + d][i], a, b));
        xx = xx / 8;
    } else {
        QLA_r_eq_Re_c(xx, QLA_elem_M(args->uf[Nu + d][i], a, b));
        xx = -xx / 8;
    }

    return xx;
}
示例#3
0
static void
q_CL_P_writer(const int p[], int c, int d, int re_im, double v, void *e)
{
    qCL_P_env *env = e;
    int i = QDP_index_L(env->lat, p);

    if (re_im == 0) {
        QLA_real(QLA_elem_P(env->out[i], c, d, env->c, env->d)) = v;
    } else {
        QLA_imag(QLA_elem_P(env->out[i], c, d, env->c, env->d)) = v;
    }
}
示例#4
0
static void
q_CL_D_writer(const int p[], int c, int d, int re_im, double v, void *e)
{
    CL_D_env *env = e;
    int i = QDP_index_L(env->lat, p);
    QLA_D3_DiracFermion *f = env->f;
 
    if (re_im == 0) {
        QLA_real(QLA_elem_D(f[i], c, d)) = v;
    } else {
        QLA_imag(QLA_elem_D(f[i], c, d)) = v;
    }
}
示例#5
0
static double
q_CL_P_reader(const int p[], int c, int d, int re_im, void *e)
{
    qCL_P_env *env = e;
    int i = QDP_index_L(env->lat, p);
    QLA_D_Real xx;

    if (re_im == 0) {
        QLA_r_eq_Re_c(xx, QLA_elem_P(env->in[i], c, d, env->c, env->d));
    } else {
        QLA_r_eq_Im_c(xx, QLA_elem_P(env->in[i], c, d, env->c, env->d));
    }

    return xx;
}
示例#6
0
static double
q_CL_D_reader(const int p[], int c, int d, int re_im, void *e)
{
    CL_D_env *env = e;
    int i = QDP_index_L(env->lat, p);
    QLA_D3_DiracFermion *f = env->f;
    QLA_D_Real xx;

    if (re_im == 0) {
        QLA_r_eq_Re_c(xx, QLA_elem_D(f[i], c, d));
    } else {
        QLA_r_eq_Im_c(xx, QLA_elem_D(f[i], c, d));
    }

    return xx;
}
示例#7
0
static double
q_CL_u_reader(int d, const int p[], int a, int b, int re_im, void *env)
{
    QLA_D_Complex z;
    QCArgs *args = env;
    int i = QDP_index_L(args->lat, p);

    if (p[d] == (args->lattice[d] - 1)) {
        QLA_c_eq_c_times_c(z, args->bf[d], QLA_elem_M(args->uf[d][i], a, b));
    } else {
        QLA_c_eq_c(z, QLA_elem_M(args->uf[d][i], a, b));
    }

    if (re_im == 0) 
        return QLA_real(z);
    else
        return QLA_imag(z);
}
示例#8
0
static int
q_I_put(lua_State *L)
{
    mLatInt *V = qlua_checkLatInt(L, 1, NULL);
    mLattice *S = qlua_ObjLattice(L, 1);
    QLA_Int *locked;
    int *idx = 0;
    int z = luaL_checkint(L, 3);

    idx = qlua_checklatcoord(L, 2, S);
    CALL_QDP(L);
    locked = QDP_expose_I(V->ptr);
    if (QDP_node_number_L(S->lat, idx) == QDP_this_node) {
        QLA_elem_I(locked[QDP_index_L(S->lat, idx)]) = z;
    }
    QDP_reset_I(V->ptr);
    qlua_free(L, idx);

    return 0;
}
示例#9
0
文件: qopwilson.c 项目: jcosborn/qll
void
fromQDP_F(real *yy, Layout *l, real *xx, QDP_Lattice *lat, int nelem, int swap)
{
  int nd = l->nDim;
  int nl = l->nSitesInner;
  int ysize = nelem * nl;
  //double n2=0;
  int nsites = l->nSites;
  if(nsites!=QDP_sites_on_node_L(lat)) {
    printf("%s: nsites(%i) != QDP_sites_on_node_L(lat)(%i)\n",
	   __func__, nsites, QDP_sites_on_node_L(lat));
    QDP_abort(-1);
  }
  for(int j=0; j<nsites; j++) { // qll sites
    int x[nd];
    LayoutIndex li;
    li.rank = myrank;
    li.index = j;
    layoutCoord(l, x, &li);
    int r = QDP_node_number_L(lat, x);
    if(r==QDP_this_node) {
      int i = QDP_index_L(lat, x);
      int oi = j / l->nSitesInner;
      int ii = j % l->nSitesInner;
      real *yi = yy + (ysize*oi + ii);
      for(int e=0; e<nelem; e++) {
	int e2 = e/2;
	int ei = e2 % swap;
	int eo = e2 / swap;
	int es = ei*(nelem/swap) + eo*2 + (e&1);
	yi[nl*e] = xx[i*nelem+es];
	//n2 += er*er + ei*ei;
      }
    } else {
      printf("unpack: site on wrong node!\n");
      QDP_abort(-1);
    }
  }
  //printf("unpack2: %g\n", n2);
}