Beispiel #1
0
int vla(int n, int m)
   {int rv;
    double f[n][m];

    rv = seta(n, m, f);
    rv = chga(n, m, (double *) f);
    rv = usea(n, m, f);

    return(rv);}
Beispiel #2
0
int dya(int n, int m)
   {int l, rv;
    double *f;

    l = n*m;
    f = malloc(l*sizeof(double));

    rv = 0;
    rv = seta(n, m, (double (*)[m]) f);
    rv = chga(n, m, f);
    rv = usea(n, m, (double (*)[m]) f);

    return(rv);}
Beispiel #3
0
int main(void)
{
	Hidden *hide;

	hide = hidden_new (1, 2);

	hid_print (hide);

	seta (hide, geta(hide) * 10);

	hid_print (hide);

	return 0;
}
Beispiel #4
0
int main (int argc, char *argv[]) {
    cfilesystem loader;
    int index;
    for (index = 0; index < EMUTEX_NULL; index++)
        pthread_mutex_init(&mutexes[index], NULL);
    if ((cengine::initialize("./default.config.xml", &argc, argv)) == EE_OK) {
        if ((cengine::initialize("./default.theme.dgt")) == EE_OK) {
            cengine::gameloop(loop);
            cengine::gamequit(clean);
            loader.init();
            if (loader.initialize("./default.loader.dfs")) {
                alpha[0] = alpha[1] = 0.0f;
                if ((loading[0] = enew ctarga())) {
                    if (loading[0]->initialize(loader.get("down"))) {
                        seta(loading[0], alpha[0]);
                        setx(loading[0], 10);
                        sety(loading[0], 400);
                        if ((loading[1] = enew ctarga())) {
                            if ((loading[1]->initialize(loader.get("up")))) {
                                seta(loading[1], alpha[1]);
                                setx(loading[1], 10);
                                sety(loading[1], 400);
                                cengine::environment[EENVIRONMENT_OVER].add(loading[0], 0);
                                cengine::environment[EENVIRONMENT_OVER].add(loading[1], 1);
                                loader.unload();
                                cengine::start();
                            }
                        } else
                            ekill("out of memory");
                    }
                } else
                    ekill("out of memory");
            }
        }
    }
    return 0;
}
//Beregning av jastrow faktoren
double Wavefunction::Jastrow_Part(const mat &r, int number_particles, double beta)
{
    double r_12;
    double Spin_variable;
    double Jastrow_Part_Argument = 0;
    double Jastrow_P=0;
    int i,j,k;

    for (i=0;i<number_particles-1;i++)
    {
        for (j=i+1;j<number_particles;j++)
        {
            r_12 = 0;
            for (k=0;k<dimension;k++){
                r_12 += (r(i,k)-r(j,k))*(r(i,k)-r(j,k));
            }

            r_12 = sqrt(r_12); //Avstanden mellom 2 atomer

            //Variabelen avhenger av spin opp eller spin ned
            //Vi velger spin opp til å være de første halvparten av atomene, resten ned
/*
            if (((i < number_particles/2) && (j < number_particles/2)) || ((i > number_particles/2) && (j > number_particles/2)))
            {
                Spin_variable = 1.0/4;
            }

            else
            {
                Spin_variable = 1.0/2;
            }
*/
            Spin_variable = seta(i,j, number_particles);

            //Summerer opp argumentene
            Jastrow_Part_Argument += Spin_variable*r_12/(1+beta*r_12);
            //Jastrow_Part_Argument /= number_atoms; // <-- number atoms variabelen brukes her av TEKNISKE grunner
        }
    }
    Jastrow_P = exp(Jastrow_Part_Argument);
    return Jastrow_P;
}
Beispiel #6
0
Tchar getch(void)
{
	int k;
	Tchar i, j;

g0:
	if (ch) {
		i = ch;
		if (cbits(i) == '\n')
			nlflg++;
		ch = 0;
		return(i);
	}

	if (nlflg)
		return('\n');
	i = getch0();
	if (ismot(i))
		return(i);
	k = cbits(i);
	if (k >= sizeof(gchtab)/sizeof(gchtab[0]) || gchtab[k] == 0)	/* nothing special */
		return(i);
	if (k != ESC) {
		if (k == '\n') {
			nlflg++;
			if (ip == 0)
				numtabp[CD].val++; /* line number */
			return(k);
		}
		if (k == FLSS) {
			copyf++; 
			raw++;
			i = getch0();
			if (!fi)
				flss = i;
			copyf--; 
			raw--;
			goto g0;
		}
		if (k == RPT) {
			setrpt();
			goto g0;
		}
		if (!copyf) {
			if (k == 'f' && lg && !lgf) {
				i = getlg(i);
				return(i);
			}
			if (k == fc || k == tabch || k == ldrch) {
				if ((i = setfield(k)) == 0)
					goto g0; 
				else 
					return(i);
			}
			if (k == '\b') {
				i = makem(-width(' ' | chbits));
				return(i);
			}
		}
		return(i);
	}

	k = cbits(j = getch0());
	if (ismot(j))
		return(j);

	switch (k) {
	case 'n':	/* number register */
		setn();
		goto g0;
	case '$':	/* argument indicator */
		seta();
		goto g0;
	case '*':	/* string indicator */
		setstr();
		goto g0;
	case '{':	/* LEFT */
		i = LEFT;
		goto gx;
	case '}':	/* RIGHT */
		i = RIGHT;
		goto gx;
	case '"':	/* comment */
		while (cbits(i = getch0()) != '\n')
			;
		if (ip == 0)
			numtabp[CD].val++; /* line number */
		nlflg++;
		return(i);

/* experiment: put it here instead of copy mode */
	case '(':	/* special char name \(xx */
	case 'C':	/* 		\C'...' */
		if ((i = setch(k)) == 0)
			goto g0;
		goto gx;

	case ESC:	/* double backslash */
		i = eschar;
		goto gx;
	case 'e':	/* printable version of current eschar */
		i = PRESC;
		goto gx;
	case '\n':	/* concealed newline */
		numtabp[CD].val++;
		goto g0;
	case ' ':	/* unpaddable space */
		i = UNPAD;
		goto gx;
	case '\'':	/* \(aa */
		i = ACUTE;
		goto gx;
	case '`':	/* \(ga */
		i = GRAVE;
		goto gx;
	case '_':	/* \(ul */
		i = UNDERLINE;
		goto gx;
	case '-':	/* current font minus */
		i = MINUS;
		goto gx;
	case '&':	/* filler */
		i = FILLER;
		goto gx;
	case 'c':	/* to be continued */
		i = CONT;
		goto gx;
	case '!':	/* transparent indicator */
		i = XPAR;
		goto gx;
	case 't':	/* tab */
		i = '\t';
		return(i);
	case 'a':	/* leader (SOH) */
/* old:		*pbp++ = LEADER; goto g0; */
		i = LEADER;
		return i;
	case '%':	/* ohc */
		i = OHC;
		return(i);
	case 'g':	/* return format of a number register */
		setaf();	/* should this really be in copy mode??? */
		goto g0;
	case '.':	/* . */
		i = '.';
gx:
		setsfbits(i, sfbits(j));
		return(i);
	}
	if (copyf) {
		*pbp++ = j;
		return(eschar);
	}
	switch (k) {

	case 'f':	/* font indicator */
		setfont(0);
		goto g0;
	case 's':	/* size indicator */
		setps();
		goto g0;
	case 'v':	/* vert mot */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		if (i = vmot()) {
			return(i);
		}
		goto g0;
	case 'h': 	/* horiz mot */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		if (i = hmot())
			return(i);
		goto g0;
	case '|':	/* narrow space */
		if (NROFF)
			goto g0;
		return(makem((int)(EM)/6));
	case '^':	/* half narrow space */
		if (NROFF)
			goto g0;
		return(makem((int)(EM)/12));
	case 'w':	/* width function */
		setwd();
		goto g0;
	case 'p':	/* spread */
		spread++;
		goto g0;
	case 'N':	/* absolute character number */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		if ((i = setabs()) == 0)
			goto g0;
		return i;
	case 'H':	/* character height */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		return(setht());
	case 'S':	/* slant */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		return(setslant());
	case 'z':	/* zero with char */
		return(setz());
	case 'l':	/* hor line */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		setline();
		goto g0;
	case 'L':	/* vert line */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		setvline();
		goto g0;
	case 'D':	/* drawing function */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		setdraw();
		goto g0;
	case 'X':	/* \X'...' for copy through */
		setxon();
		goto g0;
	case 'b':	/* bracket */
		setbra();
		goto g0;
	case 'o':	/* overstrike */
		setov();
		goto g0;
	case 'k':	/* mark hor place */
		if ((k = findr(getsn())) != -1) {
			numtabp[k].val = numtabp[HP].val;
		}
		goto g0;
	case '0':	/* number space */
		return(makem(width('0' | chbits)));
	case 'x':	/* extra line space */
		numerr.type = numerr.escarg = 0; numerr.esc = k;
		if (i = xlss())
			return(i);
		goto g0;
	case 'u':	/* half em up */
	case 'r':	/* full em up */
	case 'd':	/* half em down */
		return(sethl(k));
	default:
		return(j);
	}
	/* NOTREACHED */
}
double Wavefunction::Jastrow_Laplace_Ratio(const mat &r, const double &beta, const int &number_particles)
{
    mat Jastrow_Gradient_Radio = zeros(number_particles, dimension);
    Jastrow_Gradient_Radio = Jastrow_Gradient_Ratio(r, number_particles, beta);
    double Laplace_Radio=0, Grad_Radio;
    rowvec r_12_vec(3);
    double r_12, Spin_variable;
    double bb;

    //Tar vekselvirkningene for alle untatt i med seg selv
    for (uint i = 0; i < number_particles; i++)
    {
        for (uint j = 0; j < i; j++)
        {
            r_12 = 0;
            r_12_vec = r.row(i) - r.row(j);
            for (uint k=0; k < dimension; k++)
            {
                r_12 += r_12_vec(k) * r_12_vec(k);
            }
            r_12 = sqrt(r_12);

            /*
            if (((i < number_particles/2) && (j < number_particles/2)) || ((i > number_particles/2) && (j > number_particles/2)))
            {
                Spin_variable = 1.0/4;
            }

            else
            {
                Spin_variable = 1.0/2;
            }
            */

            Spin_variable = seta(i,j,number_particles);

            bb = (1+beta*r_12);
            //bb *= number_atoms; //number_atoms brukes av TEKNISKE grunner

            Laplace_Radio += 2*Spin_variable/(r_12*bb*bb);
            Laplace_Radio -= 2*beta*Spin_variable/(bb*bb*bb);
        }
        for (uint j = i+1; j < number_particles; j++)
        {
            r_12 = 0;
            r_12_vec = r.row(i) - r.row(j);
            for (uint k=0; k < dimension; k++)
            {
                r_12 += r_12_vec(k) * r_12_vec(k);
            }
            r_12 = sqrt(r_12);

            /*
            if (((i < number_particles/2) && (j < number_particles/2)) || ((i > number_particles/2) && (j > number_particles/2)))
            {
                Spin_variable = 1.0/4;
            }

            else
            {
                Spin_variable = 1.0/2;
            }
            */

            Spin_variable = seta(i,j,number_particles);

            bb = (1+beta*r_12);
            //bb *= number_atoms; //number_atoms brukes av TEKNISKE grunner

            Laplace_Radio += 2*Spin_variable/(r_12*bb*bb);
            Laplace_Radio -= 2*beta*Spin_variable/(bb*bb*bb);
        }

        //Tar med faktoren fra gradienten
        Grad_Radio = 0;

        for (uint k = 0; k < dimension; k++)
        {
            Grad_Radio += Jastrow_Gradient_Radio(i, k) * Jastrow_Gradient_Radio(i, k);
        }

        Laplace_Radio += Grad_Radio;
    }

    return Laplace_Radio;
}
mat Wavefunction::Jastrow_Gradient_Ratio(const mat &r, const int &number_particles, const double &beta)
{
    mat Jastrow_Gradient_Radio = zeros(number_particles, dimension);
    rowvec r_12_vec(3);
    rowvec temp_r(3);
    double r_12, arg, Spin_variable;
    double bb;

    for (uint i = 0; i < number_particles; i++)
    {
        for (uint j = 0; j < i; j++)
        {

                temp_r(0)=0;
                temp_r(1) =0;
                temp_r(2)=0;

                r_12_vec = r.row(i) - r.row(j);

                r_12 = 0;
                for (uint k = 0; k < dimension; k++)
                {
                    r_12 += r_12_vec(k) * r_12_vec(k);
                }
                r_12 = sqrt(r_12);

                //Finner spin variablen

                /*
                if (((i < number_particles/2) && (j < number_particles/2)) || ((i > number_particles/2) && (j > number_particles/2)))
                {
                    Spin_variable = 1.0/4;
                }

                else
                {
                    Spin_variable = 1.0/2;
                }
*/
                Spin_variable = seta(i,j,number_particles);

                bb = 1+beta*r_12;
                //bb = number_atoms * bb; //number_atoms brukes av TEKNISKE grunner
                arg = Spin_variable / (bb*bb);
                Jastrow_Gradient_Radio.row(i) += arg * r_12_vec / r_12;
        }

        for (uint j = i+1; j < number_particles; j++)
        {
            r_12_vec = r.row(i) - r.row(j);

            r_12 = 0;
            for (uint k = 0; k < dimension; k++)
            {
                r_12 += r_12_vec(k) * r_12_vec(k);
            }
            r_12 = sqrt(r_12);

            //Finner spin variablen

            /*
            if (((i < number_particles/2) && (j < number_particles/2)) || ((i > number_particles/2) && (j > number_particles/2)))
            {
                Spin_variable = 1.0/4;
            }
            else
            {
                Spin_variable = 1.0/2;
            }
            */

            Spin_variable = seta(i,j,number_particles);

                bb = 1+beta*r_12;
                //bb = number_atoms * bb; //number_atoms brukes av TEKNISKE grunner
                arg = Spin_variable / (bb*bb);
                Jastrow_Gradient_Radio.row(i) += r_12_vec*arg/r_12;
            }
    }
    return Jastrow_Gradient_Radio;
}
Beispiel #9
0
		void set(cells_iterator current, int x, int y, int x1x2, int delta)
		{
			seta(current, x, y, x1x2 * delta, delta);
		}
Beispiel #10
0
int loop (void) {
    pthread_t link;
    pthread_attr_t attributes;
    int result = EE_OK, index;
    skeyboard *key = cengine::inputs.key();
    if (key) {
        if (key->key == (char)27) /* esc key */
            result = EE_DONE;
        efree(key);
    }
    pthread_mutex_lock(&mutexes[EMUTEX_STATUS]);
    fflush(stdout);
    switch (status) {
        case ESTATUS_LOAD_ENTER:
            cengine::inputs.listening(EINPUT_KEYBOARD, false);
            cengine::inputs.listening(EINPUT_SPECIAL, false);
            cengine::inputs.listening(EINPUT_MOUSE, false);
            for (index = 0; index < EMUTEX_STATUS; index++)
                pthread_mutex_init(&mutexes[index], NULL);
            pthread_attr_init(&attributes);
            if (pthread_create(&link, &attributes, &building, NULL) == 0)
                pthread_detach(link);
            else
                result = EE_ERROR;
            status = ESTATUS_LOAD;
            break;
        case ESTATUS_LOAD:
            alpha[0] = EE_MIN((alpha[0]+0.01f), 1.0f);
            alpha[1] = EE_MIN((alpha[1]+0.01f), 1.0f);
            seta(loading[0], alpha[0]);
            seta(loading[1], alpha[1]);
            loading[0]->rotation += 0.25f;
            break;
        case ESTATUS_LOAD_EXIT:
            if ((alpha[0] > 0.0f) || (alpha[1] > 0.0f)) {
                alpha[0] = EE_MAX((alpha[0]-0.01f), 0.0f);
                alpha[1] = EE_MAX((alpha[1]-0.01f), 0.0f);
                seta(loading[0], alpha[0]);
                seta(loading[1], alpha[1]);
                loading[0]->rotation += 0.25f;
            } else {
                if ((cengine::environment[EENVIRONMENT_OVER].get(loading[0])))
                    cengine::environment[EENVIRONMENT_OVER].del();
                if ((cengine::environment[EENVIRONMENT_OVER].get(loading[1])))
                    cengine::environment[EENVIRONMENT_OVER].del();
                loading[0]->unload();
                delete(loading[0]);
                loading[1]->unload();
                delete(loading[1]);
                status = ESTATUS_MENU_ENTER;
            }
            break;
        case ESTATUS_MENU_ENTER:
            /* prepare menu interface */
            cengine::inputs.listening(EINPUT_KEYBOARD, true);
            cengine::inputs.listening(EINPUT_SPECIAL, true);
            cengine::inputs.listening(EINPUT_MOUSE, true);
            status = ESTATUS_MENU;
            break;
        case ESTATUS_MENU:
            /* menu management */
            break;
        case ESTATUS_MENU_EXIT:
            cengine::inputs.listening(EINPUT_KEYBOARD, false);
            cengine::inputs.listening(EINPUT_SPECIAL, false);
            cengine::inputs.listening(EINPUT_MOUSE, false);
            break;
        case ESTATUS_PLAY_ENTER:
        case ESTATUS_PLAY:
        case ESTATUS_PLAY_EXIT:
        case ESTATUS_PAUSE_ENTER:
        case ESTATUS_PAUSE:
        case ESTATUS_PAUSE_EXIT:
            break;
    }
    pthread_mutex_unlock(&mutexes[EMUTEX_STATUS]);
    return result;
}