Example #1
0
int
cnumb(void)
{
	int c, n;

	c = *f.charp++;
	if(c == '<') {
		n = f.nextiter;
		if(n >= 0) {
			f.nextiter = n+f.diriter;
			if(n == f.lastiter) {
				f.nextiter = -1;
				f.lastiter = -1;
			}
			do {
				c = *f.charp++;
			} while (c != '>');
			return n;
		}
		n = cnumb();
		if(*f.charp++ != '-') {
			cdiag("- expected", f.charp[-1]);
			return 0;
		}
		c = cnumb();
		if(*f.charp++ != '>') {
			cdiag("> expected", f.charp[-1]);
			return 0;
		}
		f.lastiter = c;
		f.diriter = 1;
		if(n > c)
			f.diriter = -1;
		f.nextiter = n+f.diriter;
		return n;
	}
	if(!isascii(c) || !isdigit(c)) {
		cdiag("number expected", c);
		return 0;
	}
	n = 0;
	while(isascii(c) && isdigit(c)) {
		n = n*10 + (c-'0');
		c = *f.charp++;
	}
	f.charp--;
	return n;
}
Example #2
0
Device*
iconfig(char *s)
{
	Device *d;

	f.nextiter = -1;
	f.lastiter = -1;
	f.error = 0;
	f.icharp = s;
	f.charp = f.icharp;
	d = config();
	if(*f.charp) {
		cdiag("junk on end", *f.charp);
		f.error = 1;
	}
	return d;
}
Example #3
0
CPS_START_NAMESPACE

// 1. 2 pion contractions, D and C diagram only (for I=2 pi pi
// scattering), no separation.
//
// 2. Assuming cosine source with antiperiodic boundary condition, use
// momentum sink.
//
// 3. pd: momentum in the d quark propagator.
//
// FIXME: there may be one or more factors of 2 in the sink side.
void run_2pionDC(const AllProp &uprop,
                 const AllProp &dprop,
                 const std::string &fn,
                 PROP_TYPE ptype, const int pd[3])
{
    const int t_scale = ptype == PROP_PA ? 2 : 1;
    const int t_size = GJP.TnodeSites() * GJP.Tnodes();
    const int t_size_ap = t_scale * t_size;

    std::vector<std::vector<WilsonMatrix> > us, dsp, dsm;

    run_wall_snk(&us, uprop, ptype);

    run_wall_snk(&dsp, dprop, ptype, pd);

    int pdm[3] = {-pd[0], -pd[1], -pd[2]};
    run_wall_snk(&dsm, dprop, ptype, pdm);

    FILE *fp = Fopen(fn.c_str(), "w");

    for(unsigned src = 0; src < t_size; ++src) {
        if( us[src].empty()) continue;
        if(dsp[src].empty()) continue;
        if(dsm[src].empty()) continue;

        std::vector<Rcomplex> ddiag(t_size_ap, Rcomplex(0, 0));
        std::vector<Rcomplex> cdiag(t_size_ap, Rcomplex(0, 0));

        for(unsigned dt = 0; dt < t_size_ap; ++dt) {
            unsigned snk = (src + dt) % t_size_ap;

            WilsonMatrix w[2];

            w[0] = dsp[src][snk];
            w[0].hconj();
            w[0] *= us[src][snk];

            w[1] = dsm[src][snk];
            w[1].hconj();
            w[1] *= us[src][snk];

            ddiag[dt] = w[0].Trace() * w[1].Trace();
            cdiag[dt] = Trace(w[0], w[1]);
        } // dt

        for(unsigned t = 0; t < t_size_ap; ++t) {
            Fprintf(fp, "%3u %3u %17.10e %17.10e %17.10e %17.10e\n",
                    src, t,
                    real(ddiag[t]), imag(ddiag[t]),
                    real(cdiag[t]), imag(cdiag[t]));
        }
    } // src
    
    Fclose(fp);
}
Example #4
0
Device*
config(void)
{
	int c, m;
	Device *d;
	char *icp;

	if(f.error)
		return devnone;
	d = malloc(sizeof(Device));

	c = *f.charp++;
	switch(c) {
	default:
		cdiag("unknown type", c);
		return devnone;

	case '(':	/* (d+) one or multiple cat */
	case '[':	/* [d+] one or multiple interleave */
	case '{':	/* {d+} a mirrored device and optional mirrors */
		return config1(c);

	case 'f':	/* fd fake worm */
		d->type = Devfworm;
		d->fw.fw = config();
		break;

	case 'n':
		d->type = Devnone;
		break;

	case 'w':	/* w[#.]#[.#] wren	[ctrl] unit [lun] */
	case 'r':	/* r# worm side */
	case 'l':	/* l# labelled-worm side */
		icp = f.charp;
		d->type = Devwren;
		d->wren.ctrl = 0;
		d->wren.targ = cnumb();
		d->wren.lun = 0;
		m = *f.charp;
		if(m == '.') {
			f.charp++;
			d->wren.lun = cnumb();
			m = *f.charp;
			if(m == '.') {
				f.charp++;
				d->wren.ctrl = d->wren.targ;
				d->wren.targ = d->wren.lun;
				d->wren.lun = cnumb();
			}
		}
		if(f.nextiter >= 0)
			f.charp = icp-1;
		if(c == 'r')		/* worms are virtual and not uniqued */
			d->type = Devworm;
		else if(c == 'l')
			d->type = Devlworm;
		else
			map(d);		/* subject wrens to optional mapping */
		break;

	case 'o':	/* o ro part of last cw */
		if(f.lastcw == 0) {
			cdiag("no cw to match", c);
			return devnone;
		}
		return f.lastcw->cw.ro;

	case 'j':	/* DD jukebox */
		d->type = Devjuke;
		d->j.j = config();
		d->j.m = config();
		break;

	case 'c':	/* cache/worm */
		d->type = Devcw;
		d->cw.c = config();
		d->cw.w = config();
		d->cw.ro = malloc(sizeof(Device));
		d->cw.ro->type = Devro;
		d->cw.ro->ro.parent = d;
		f.lastcw = d;
		break;

	case 'p':	/* pd#.# partition base% size% */
		d->type = Devpart;
		d->part.d = config();
		d->part.base = cnumb();
		c = *f.charp++;
		if(c != '.')
			cdiag("dot expected", c);
		d->part.size = cnumb();
		break;

	case 'x':	/* xD swab a device's metadata */
		d->type = Devswab;
		d->swab.d = config();
		break;
	}
	d->dlink = f.devlist;
	f.devlist = d;
	return d;
}