Ejemplo n.º 1
0
double get_dp_pop_srh(double top, double T, int trap, int mat)
{
	double ret = 0.0;
	double c0 = 0.0;
	double c1 = 0.0;
	double x0 = 0.0;
	double x1 = 0.0;
	double t0 = 0.0;
	double t1 = 0.0;
	double c = 0.0;
	double xr = 0.0;
	double tr = 0.0;
	double c00 = 0.0;
	double c01 = 0.0;
	double c10 = 0.0;
	double c11 = 0.0;

	int t = 0;
	int x;

#ifdef dos_warn
	if ((dosp[mat].x[0] > top) || (dosp[mat].x[dosp[mat].xlen - 1] < top)) {
		ewe("Holes asking for %e but range %e %e\n", top,
		    dosp[mat].x[0], dosp[mat].x[dosp[mat].xlen - 1]);
		//if (get_dump_status(dump_exit_on_dos_error)==TRUE) server_stop_and_exit();
		//exit(0);
	}
#endif

	x = hashget(dosp[mat].x, dosp[mat].xlen, top);

	x0 = dosp[mat].x[x];
	x1 = dosp[mat].x[x + 1];
	xr = 1.0 / (x1 - x0);

	if (dosp[mat].tlen > 1) {
		t = hashget(dosp[mat].t, dosp[mat].tlen, T);
		t0 = dosp[mat].t[t];
		t1 = dosp[mat].t[t + 1];
		tr = (T - t0) / (t1 - t0);
	} else {
		tr = 0.0;
	}

	c00 = dosp[mat].srh_c[t][x][trap];
	c01 = dosp[mat].srh_c[t][x + 1][trap];
	c0 = xr * (c01 - c00);

	if (dosp[mat].tlen > 1) {
		c10 = dosp[mat].srh_c[t + 1][x][trap];
		c11 = dosp[mat].srh_c[t + 1][x + 1][trap];
		c1 = xr * (c11 - c10);
	}

	c = c0 + tr * (c1 - c0);

	ret = c;

	return ret;
}
Ejemplo n.º 2
0
int compute(struct In *input, struct Out *output) {
  Student_handle_t handle;
  tree_t Age_index;

  hashget(&handle, &(input->db_handle));
  Age_index.root = handle.Age_index;

  CQL("SELECT KEY, FName, LName, Age, Major, State, PhoneNum, Class, Credits, Average, Honored FROM Student WHERE Age > 20 AND Age < 27 LIMIT 5", output->result);
  return 0;
}
Ejemplo n.º 3
0
void compute(struct In *input, struct Out *output){
  int i=0;
  /*
  for (i=0; i<SIZE-1; i++)
    input->data[i] = input->data[i] * input->data[i+1];
  */
  hashput(&(output->hash), input);
  
  hashget(input, &(output->hash));
}
Ejemplo n.º 4
0
void
ppassert(int op, char* pred, char* args)
{
	register struct pplist*		a;
	register struct ppsymbol*	sym;
	register struct pplist*		p;
	register struct pplist*		q;

	if (!args) switch (op)
	{
	case DEFINE:
		goto mark;
	case UNDEF:
		a = 0;
		goto unmark;
	}
	if (a = (struct pplist*)hashget(pp.prdtab, pred))
	{
		p = 0;
		q = a;
		while (q)
		{
			if (streq(q->value, args))
			{
				if (op == DEFINE) return;
				q = q->next;
				if (p) p->next = q;
				else a = q;
			}
			else
			{
				p = q;
				q = q->next;
			}
		}
		if (op == UNDEF)
		{
		unmark:
			hashput(pp.prdtab, pred, a);
			if (sym = ppsymref(pp.symtab, pred))
				sym->flags &= ~SYM_PREDICATE;
			return;
		}
	}
	if (op == DEFINE)
	{
		p = newof(0, struct pplist, 1, 0);
		p->next = a;
		p->value = strdup(args);
		hashput(pp.prdtab, NiL, p);
	mark:
		if ((pp.state & COMPILE) && pp.truncate) return;
		if (sym = ppsymset(pp.symtab, pred))
			sym->flags |= SYM_PREDICATE;
	}
Ejemplo n.º 5
0
void
fileskip(register Archive_t* ap, register File_t* f)
{
	Member_t*	d;
	off_t		n;

	if (ap->delta && (d = (Member_t*)hashget(ap->delta->tab, f->name)))
		d->info->delta.op = DELTA_delete;
	if ((!ap->format->getdata || !(*ap->format->getdata)(&state, ap, f, -1)) && ((n = f->st->st_size) > 0 && f->type == X_IFREG || (n = f->datasize)) && bread(ap, NiL, (off_t)0, n, 1) < 0)
		error(ERROR_SYSTEM|2, "%s: skip error", f->name);
}
Ejemplo n.º 6
0
void
getdeltaheader(register Archive_t* ap, register File_t* f)
{
	register char*	s;
	int		n;
	unsigned long	sum;
	Sfio_t*		sp;
	char		c;

	if (!(ap->format->flags & COMPRESSED))
	{
		if (ap->delta && ap->delta->format && (ap->delta->format->variant == DELTA_94 || ap->delta->format->variant == DELTA_IGNORE && state.delta2delta))
		{
			ap->delta->index++;
			if (ap->delta->tab && f->name && (f->delta.base = (Member_t*)hashget(ap->delta->tab, f->name)))
				f->delta.base->mark = 1;
			if (!(ap->format->flags & DELTAINFO))
			{
				if (f->st->st_size <= 0 || bread(ap, &c, (off_t)1, (off_t)1, 1) <= 0)
					f->delta.op = DELTA_create;
				else
				{
					f->st->st_size--;
					f->delta.op = c;
					getdeltaops(ap, f);
					if (f->st->st_size >= 12 && (f->delta.op == DELTA_create || f->delta.op == DELTA_update))
					{
						sum = ap->memsum;
						s = ap->delta->hdrbuf;
						n = 12;
						if (bread(ap, s, (off_t)n, (off_t)n, 1) > 0)
						{
							if (ap->delta->format->variant == DELTA_88)
							{
								unsigned char*	u = (unsigned char*)s;
								int		i;

								i = *u++;
								u += (i >> 3) & 07;
								f->uncompressed = 0;
								i &= 07;
								while (i-- > 0)
									f->uncompressed = f->uncompressed * 256 + *u++;
							}
							else if (sp = sfnew(NiL, s + 4, n, -1, SF_READ|SF_STRING))
							{
								f->uncompressed = sfgetu(sp);
								sfclose(sp);
							}
							bunread(ap, s, n);
						}
						ap->memsum = sum;
					}
				}
Ejemplo n.º 7
0
int compute(struct In* input, struct Out* output){
  //Unpack the database
  struct pathdb db;
  //TODO change to decommit
  //hashget(&db, &input->commitment);
  setcommitmentCK(&input->commitmentCK);
  hash_t hash_of_db;
  commitmentget(&hash_of_db, &input->commitment);
  hashget(&db, &hash_of_db);

  return verified_tolling(&db, &input->verifier_in, output);
}
Ejemplo n.º 8
0
void compute(struct In *input, struct Out *output){
  /*ramput(0, input);*/
  hash_t hash;
  ramget(&(hash), 0);
  ramget(&(output->data1), 1);
  /*ramget(output, 0);*/

  /*hash_t hash;*/
  /*hashput(&(hash), input);*/
  /*hashput(&(output->hash), input);*/
  hashget(&(output->data), &(hash));
  /*hashget(output, &(hash));*/
  /*output->success = 1;*/
}
Ejemplo n.º 9
0
void compute(struct In *input, struct Out *output) {
  uint32_t tempInt, tempRowID;
  uint32_t nextRowID, numberOfRows, rowOffset, i;

  Student_t tempStudent, tempOldStudent;
  tree_t Age_index;
  Age_t tempAge;
  tree_result_set_t result;
  memset(&Age_index, 0, sizeof(tree_t));
  memset(&result, 0, sizeof(tree_result_set_t));

  /*SELECT KEY, Age FROM Student WHERE Age < 24*/
  Age_index.root = input->hash;
  tempAge = 24;
  tree_find_lt(&(Age_index), (tempAge), FALSE, &(result));
  output->rows = result.num_results;
  for (i = 0; i < 3; i++) {
    if (i < result.num_results) {
      hashget(&(tempStudent), &(result.results[i].value));
      output->result[i].KEY = tempStudent.KEY;
      output->result[i].FName = tempStudent.FName;
      output->result[i].LName = tempStudent.LName;
      output->result[i].Age = tempStudent.Age;
      output->result[i].Major = tempStudent.Major;
      output->result[i].State = tempStudent.State;
      output->result[i].PhoneNum = tempStudent.PhoneNum;
      output->result[i].Class = tempStudent.Class;
      output->result[i].Credits = tempStudent.Credits;
      output->result[i].Average = tempStudent.Average;
    } else {
      output->result[i].KEY = 0;
      output->result[i].FName = 0;
      output->result[i].LName = 0;
      output->result[i].Age = 0;
      output->result[i].Major = 0;
      output->result[i].State = 0;
      output->result[i].PhoneNum = 0;
      output->result[i].Class = 0;
      output->result[i].Credits = 0;
      output->result[i].Average = 0;
    }
  }
}
Ejemplo n.º 10
0
object *make_symbol(char *value) {
    object *obj;
    // is object already in has table (based upon value)?
    obj = hashget(value);
    // if (not found)
    if (obj == NULL) {
    //      allocate new object
            obj = alloc_object();
            obj->type = SYMBOL;
            obj->data.symbol.value = malloc(strlen(value) + 1);
            if (obj->data.symbol.value == NULL) {
                fprintf(stderr, "out of memory\n");
                exit(EXIT_FAILURE);
            }
            strcpy(obj->data.symbol.value, value);
    //      put it onto the hash table
            hashpost(value, obj);
    // endif
    }
    // return object
    return obj;
}
Ejemplo n.º 11
0
double get_p_srh(double top, double T, int trap, int r, int mat)
{
	double ret = 0.0;
	double c0 = 0.0;
	double c1 = 0.0;
	double x0 = 0.0;
	double x1 = 0.0;
	double t0 = 0.0;
	double t1 = 0.0;
	double c = 0.0;
	double xr = 0.0;
	double tr = 0.0;
	double c00 = 0.0;
	double c01 = 0.0;
	double c10 = 0.0;
	double c11 = 0.0;
	int t = 0;
	int x = 0;

#ifdef dos_warn
	if ((dosp[mat].x[0] > top) || (dosp[mat].x[dosp[mat].xlen - 1] < top)) {
		ewe("Holes asking for %e but range %e %e\n", top,
		    dosp[mat].x[0], dosp[mat].x[dosp[mat].xlen - 1]);
		//if (get_dump_status(dump_exit_on_dos_error)==TRUE) server_stop_and_exit();
		//exit(0);
	}
#endif

	x = hashget(dosp[mat].x, dosp[mat].xlen, top);
//if (x<0) x=0;

	x0 = dosp[mat].x[x];
	x1 = dosp[mat].x[x + 1];
	xr = (top - x0) / (x1 - x0);

	if (dosp[mat].tlen > 1) {
		t = hashget(dosp[mat].t, dosp[mat].tlen, T);
		if (t < 0)
			t = 0;

		t0 = dosp[mat].t[t];
		t1 = dosp[mat].t[t + 1];
		tr = (T - t0) / (t1 - t0);
	} else {
		tr = 0.0;
	}

	switch (r) {
	case 1:
		c00 = dosp[mat].srh_r1[t][x][trap];
		c01 = dosp[mat].srh_r1[t][x + 1][trap];
		c0 = c00 + xr * (c01 - c00);

		if (dosp[mat].tlen > 1) {
			c10 = dosp[mat].srh_r1[t + 1][x][trap];
			c11 = dosp[mat].srh_r1[t + 1][x + 1][trap];
			c1 = c10 + xr * (c11 - c10);
		}
		break;

	case 2:
		c00 = dosp[mat].srh_r2[t][x][trap];
		c01 = dosp[mat].srh_r2[t][x + 1][trap];
		c0 = c00 + xr * (c01 - c00);

		if (dosp[mat].tlen > 1) {
			c10 = dosp[mat].srh_r2[t + 1][x][trap];
			c11 = dosp[mat].srh_r2[t + 1][x + 1][trap];
			c1 = c10 + xr * (c11 - c10);
		}
		break;

	case 3:
		c00 = dosp[mat].srh_r3[t][x][trap];
		c01 = dosp[mat].srh_r3[t][x + 1][trap];
		c0 = c00 + xr * (c01 - c00);

		if (dosp[mat].tlen > 1) {
			c10 = dosp[mat].srh_r3[t + 1][x][trap];
			c11 = dosp[mat].srh_r3[t + 1][x + 1][trap];
			c1 = c10 + xr * (c11 - c10);
		}
		break;

	case 4:
		c00 = dosp[mat].srh_r4[t][x][trap];
		c01 = dosp[mat].srh_r4[t][x + 1][trap];
		c0 = c00 + xr * (c01 - c00);

		if (dosp[mat].tlen > 1) {
			c10 = dosp[mat].srh_r4[t + 1][x][trap];
			c11 = dosp[mat].srh_r4[t + 1][x + 1][trap];
			c1 = c10 + xr * (c11 - c10);
		}
		break;
	}

	c = c0 + tr * (c1 - c0);
	ret = c;

	return ret;
}
Ejemplo n.º 12
0
void
ppbuiltin(void)
{
	register int		c;
	register char*		p;
	register char*		a;

	int			n;
	int			op;
	char*			token;
	char*			t;
	long			number;
	long			onumber;
	struct ppinstk*		in;
	struct pplist*		list;
	struct ppsymbol*	sym;
	Sfio_t*			sp;

	number = pp.state;
	pp.state |= DISABLE|FILEPOP|NOSPACE;
	token = pp.token;
	p = pp.token = pp.tmpbuf;
	*(a = pp.args) = 0;
	if ((c = pplex()) != T_ID)
	{
		error(2, "%s: #(<identifier>...) expected", p);
		*p = 0;
	}
	switch (op = (int)hashget(pp.strtab, p))
	{
	case V_DEFAULT:
		n = 0;
		p = pp.token = pp.valbuf;
		if ((c = pplex()) == ',')
		{
			op = -1;
			c = pplex();
		}
		pp.state &= ~NOSPACE;
		for (;;)
		{
			if (!c)
			{
				error(2, "%s in #(...) argument", pptokchr(c));
				break;
			}
			if (c == '(') n++;
			else if (c == ')' && !n--) break;
			else if (c == ',' && !n && op > 0) op = 0;
			if (op) pp.token = pp.toknxt;
			c = pplex();
		}
		*pp.token = 0;
		pp.token = token;
		pp.state = number;
		break;
	case V_EMPTY:
		p = pp.valbuf;
		if ((c = pplex()) == ')') *p = '1';
		else
		{
			*p = '0';
			n = 0;
			for (;;)
			{
				if (!c)
				{
					error(2, "%s in #(...) argument", pptokchr(c));
					break;
				}
				if (c == '(') n++;
				else if (c == ')' && !n--) break;
				c = pplex();
			}
		}
		*(p + 1) = 0;
		pp.token = token;
		pp.state = number;
		break;
	case V_ITERATE:
		n = 0;
		pp.token = pp.valbuf;
		if ((c = pplex()) != T_ID || !(sym = ppsymref(pp.symtab, pp.token)) || !sym->macro || sym->macro->arity != 1 || (c = pplex()) != ',')
		{
			error(2, "#(%s <macro(x)>, ...) expected", p);
			for (;;)
			{
				if (!c)
				{
					error(2, "%s in #(...) argument", pptokchr(c));
					break;
				}
				if (c == '(') n++;
				else if (c == ')' && !n--) break;
				c = pplex();
			}
			*pp.valbuf = 0;
		}
		else while (c != ')')
		{
			p = pp.token;
			if (pp.token > pp.valbuf) *pp.token++ = ' ';
			STRCOPY(pp.token, sym->name, a);
			*pp.token++ = '(';
			if (!c || !(c = pplex()))
			{
				pp.token = p;
				error(2, "%s in #(...) argument", pptokchr(c));
				break;
			}
			pp.state &= ~NOSPACE;
			while (c)
			{
				if (c == '(') n++;
				else if (c == ')' && !n--) break;
				else if (c == ',' && !n) break;
				pp.token = pp.toknxt;
				c = pplex();
			}
			*pp.token++ = ')';
			pp.state |= NOSPACE;
		}
		p = pp.valbuf;
		pp.token = token;
		pp.state = number;
		break;
	default:
		pp.token = token;
		while (c != ')')
		{
			if (!c)
			{
				error(2, "%s in #(...) argument", pptokchr(c));
				break;
			}
			if ((c = pplex()) == T_ID && !*a)
				strcpy(a, pp.token);
		}
		pp.state = number;
		switch (op)
		{
		case V_ARGC:
			c = -1;
			for (in = pp.in; in; in = in->prev)
				if ((in->type == IN_MACRO || in->type == IN_MULTILINE) && (in->symbol->flags & SYM_FUNCTION))
				{
					c = *((unsigned char*)(pp.macp->arg[0] - 2));
					break;
				}
			sfsprintf(p = pp.valbuf, MAXTOKEN, "%d", c);
			break;
		case V_BASE:
			p = (a = strrchr(error_info.file, '/')) ? a + 1 : error_info.file;
			break;
		case V_DATE:
			if (!(p = pp.date))
			{
				time_t	tm;

				time(&tm);
				a = p = ctime(&tm) + 4;
				*(p + 20) = 0;
				for (p += 7; *p = *(p + 9); p++);
				pp.date = p = strdup(a);
			}
			break;
		case V_FILE:
			p = error_info.file;
			break;
		case V_LINE:
			sfsprintf(p = pp.valbuf, MAXTOKEN, "%d", error_info.line);
			break;
		case V_PATH:
			p = pp.path;
			break;
		case V_SOURCE:
			p = error_info.file;
			for (in = pp.in; in->prev; in = in->prev)
				if (in->prev->type == IN_FILE && in->file)
					p = in->file;
			break;
		case V_STDC:
			p = pp.valbuf;
			p[0] = ((pp.state & (COMPATIBILITY|TRANSITION)) || (pp.mode & (HOSTED|HOSTEDTRANSITION)) == (HOSTED|HOSTEDTRANSITION)) ? '0' : '1';
			p[1] = 0;
			break;
		case V_TIME:
			if (!(p = pp.time))
			{
				time_t	tm;

				time(&tm);
				p = ctime(&tm) + 11;
				*(p + 8) = 0;
				pp.time = p = strdup(p);
			}
			break;
		case V_VERSION:
			p = (char*)pp.version;
			break;
		case V_DIRECTIVE:
			pp.state |= NEWLINE;
			pp.mode |= RELAX;
			strcpy(p = pp.valbuf, "#");
			break;
		case V_GETENV:
			if (!(p = getenv(a))) p = "";
			break;
		case V_GETMAC:
			p = (sym = pprefmac(a, REF_NORMAL)) ? sym->macro->value : "";
			break;
		case V_GETOPT:
			sfsprintf(p = pp.valbuf, MAXTOKEN, "%ld", ppoption(a));
			break;
		case V_GETPRD:
			p = (list = (struct pplist*)hashget(pp.prdtab, a)) ? list->value : "";
			break;
		case V__PRAGMA:
			if ((c = pplex()) == '(')
			{
				number = pp.state;
				pp.state |= NOSPACE|STRIP;
				c = pplex();
				pp.state = number;
				if (c == T_STRING || c == T_WSTRING)
				{
					if (!(sp = sfstropen()))
						error(3, "temporary buffer allocation error");
					sfprintf(sp, "#%s %s\n", dirname(PRAGMA), pp.token);
					a = sfstruse(sp);
					if ((c = pplex()) == ')')
					{
						pp.state |= NEWLINE;
						PUSH_BUFFER(p, a, 1);
					}
					sfstrclose(sp);
				}
			}
			if (c != ')')
				error(2, "%s: (\"...\") expected", p);
			return;
		case V_FUNCTION:

#define BACK(a,p)	((a>p)?*--a:(number++?0:((p=pp.outbuf+PPBUFSIZ),(a=pp.outbuf+2*PPBUFSIZ),*--a)))
#define PEEK(a,p)	((a>p)?*(a-1):(number?0:*(pp.outbuf+2*PPBUFSIZ-1)))

			number = pp.outbuf != pp.outb;
			a = pp.outp;
			p = pp.outb;
			op = 0;
			while (c = BACK(a, p))
			{
				if (c == '"' || c == '\'')
				{
					op = 0;
					while ((n = BACK(a, p)) && n != c || PEEK(a, p) == '\\');
				}
				else if (c == '\n')
				{
					token = a;
					while (c = BACK(a, p))
						if (c == '\n')
						{
							a = token;
							break;
						}
						else if (c == '#' && PEEK(a, p) == '\n')
							break;
				}
				else if (c == ' ')
					/*ignore*/;
				else if (c == '{') /* '}' */
					op = 1;
				else if (op == 1)
				{
					if (c == ')')
					{
						op = 2;
						n = 1;
					}
					else
						op = 0;
				}
				else if (op == 2)
				{
					if (c == ')')
						n++;
					else if (c == '(' && !--n)
						op = 3;
				}
				else if (op == 3)
				{
					if (ppisidig(c))
					{
						for (t = p, token = a, onumber = number; ppisidig(PEEK(a, p)) && a >= p; BACK(a, p));
						p = pp.valbuf + 1;
						if (a > token)
						{
							for (; a < pp.outbuf+2*PPBUFSIZ; *p++ = *a++);
							a = pp.outbuf;
						}
						for (; a <= token; *p++ = *a++);
						*p = 0;
						p = pp.valbuf + 1;
						if (streq(p, "for") || streq(p, "if") || streq(p, "switch") || streq(p, "while"))
						{
							op = 0;
							p = t;
							number = onumber;
							continue;
						}
					}
					else
						op = 0;
					break;
				}
			}
			if (op == 3)
				p = strncpy(pp.funbuf, p, sizeof(pp.funbuf) - 1);
			else if (*pp.funbuf)
				p = pp.funbuf;
			else
				p = "__FUNCTION__";
			break;
		default:
			if (pp.builtin && (a = (*pp.builtin)(pp.valbuf, p, a)))
				p = a;
			break;
		}
		break;
	}
	if (strchr(p, MARK))
	{
		a = pp.tmpbuf;
		strcpy(a, p);
		c = p != pp.valbuf;
		p = pp.valbuf + c;
		for (;;)
		{
			if (p < pp.valbuf + MAXTOKEN - 2)
				switch (*p++ = *a++)
				{
				case 0:
					break;
				case MARK:
					*p++ = MARK;
					/*FALLTHROUGH*/
				default:
					continue;
				}
			break;
		}
		p = pp.valbuf + c;
	}
	if (p == pp.valbuf)
		PUSH_STRING(p);
	else
	{
		if (p == pp.valbuf + 1)
			*pp.valbuf = '"';
		else
		{
			if (strlen(p) > MAXTOKEN - 2)
				error(1, "%-.16s: builtin value truncated", p);
			sfsprintf(pp.valbuf, MAXTOKEN, "\"%-.*s", MAXTOKEN - 2, p);
		}
		PUSH_QUOTE(pp.valbuf, 1);
	}
}
Ejemplo n.º 13
0
long double get_dp_srh(struct simulation *sim,struct device *in,long double top,long double T,int trap,int r,int mat)
{
long double ret=0.0;
long double c0=0.0;
long double c1=0.0;
long double x0=0.0;
long double x1=0.0;
long double t0=0.0;
long double t1=0.0;
long double c=0.0;
long double xr=0.0;
long double tr=0.0;
long double c00=0.0;
long double c01=0.0;
long double c10=0.0;
long double c11=0.0;


int t=0;
int x;

#ifdef dos_warn
if ((in->dosp[mat].x[0]>top)||(in->dosp[mat].x[in->dosp[mat].xlen-1]<top))
{
	ewe(sim,"Holes asking for %e but range %e %e\n",top,in->dosp[mat].x[0],in->dosp[mat].x[in->dosp[mat].xlen-1]);
	//if (get_dump_status(dump_exit_on_dos_error)==TRUE) server_stop_and_exit();
	//exit(0);
}
#endif


x=hashget(in->dosp[mat].x,in->dosp[mat].xlen,top);

x0=in->dosp[mat].x[x];
x1=in->dosp[mat].x[x+1];
xr=1.0/(x1-x0);

if (in->dosp[mat].tlen>1)
{
	t=hashget(in->dosp[mat].t,in->dosp[mat].tlen,T);
	t0=in->dosp[mat].t[t];
	t1=in->dosp[mat].t[t+1];
	tr=(T-t0)/(t1-t0);
}else
{
	tr=0.0;
}

switch (r)
{
case 1:
	c00=in->dosp[mat].srh_r1[t][x][trap];
	c01=in->dosp[mat].srh_r1[t][x+1][trap];
	c0=xr*(c01-c00);

	if (in->dosp[mat].tlen>1)
	{
		c10=in->dosp[mat].srh_r1[t+1][x][trap];
		c11=in->dosp[mat].srh_r1[t+1][x+1][trap];
		c1=xr*(c11-c10);
	}
break;

case 2:
	c00=in->dosp[mat].srh_r2[t][x][trap];
	c01=in->dosp[mat].srh_r2[t][x+1][trap];
	c0=xr*(c01-c00);

	if (in->dosp[mat].tlen>1)
	{
		c10=in->dosp[mat].srh_r2[t+1][x][trap];
		c11=in->dosp[mat].srh_r2[t+1][x+1][trap];
		c1=xr*(c11-c10);
	}
break;

case 3:
	c00=in->dosp[mat].srh_r3[t][x][trap];
	c01=in->dosp[mat].srh_r3[t][x+1][trap];
	c0=xr*(c01-c00);

	if (in->dosp[mat].tlen>1)
	{
		c10=in->dosp[mat].srh_r3[t+1][x][trap];
		c11=in->dosp[mat].srh_r3[t+1][x+1][trap];
		c1=xr*(c11-c10);
	}
break;

case 4:
	c00=in->dosp[mat].srh_r4[t][x][trap];
	c01=in->dosp[mat].srh_r4[t][x+1][trap];
	c0=xr*(c01-c00);

	if (in->dosp[mat].tlen>1)
	{
		c10=in->dosp[mat].srh_r4[t+1][x][trap];
		c11=in->dosp[mat].srh_r4[t+1][x+1][trap];
		c1=xr*(c11-c10);
	}
break;
}

c=c0+tr*(c1-c0);

ret=c;

return ret;
}
Ejemplo n.º 14
0
long double get_n_pop_srh(struct simulation *sim,struct device *in,long double top,long double T,int trap,int mat)
{
long double ret=0.0;
long double c0=0.0;
long double c1=0.0;
long double x0=0.0;
long double x1=0.0;
long double t0=0.0;
long double t1=0.0;
long double c=0.0;
long double xr=0.0;
long double tr=0.0;
long double c00=0.0;
long double c01=0.0;
long double c10=0.0;
long double c11=0.0;
int t=0;
int x=0;

#ifdef dos_warn
if ((in->dosn[mat].x[0]>top)||(in->dosn[mat].x[in->dosn[mat].xlen-1]<top))
{
	ewe(sim,"Electrons asking for %e but range %e %e\n",top,in->dosn[mat].x[0],in->dosn[mat].x[in->dosn[mat].xlen-1]);
	//if (get_dump_status(dump_exit_on_dos_error)==TRUE) server_stop_and_exit();
	//exit(0);
}
#endif

x=hashget(in->dosn[mat].x,in->dosn[mat].xlen,top);


x0=in->dosn[mat].x[x];
x1=in->dosn[mat].x[x+1];
xr=(top-x0)/(x1-x0);
if (in->dosn[mat].tlen>1)
{
	t=hashget(in->dosn[mat].t,in->dosn[mat].tlen,T);

	t0=in->dosn[mat].t[t];
	t1=in->dosn[mat].t[t+1];
	tr=(T-t0)/(t1-t0);
}else
{
tr=0.0;
}


c00=in->dosn[mat].srh_c[t][x][trap];
c01=in->dosn[mat].srh_c[t][x+1][trap];
c0=c00+xr*(c01-c00);

if (in->dosn[mat].tlen>1)
{
	c10=in->dosn[mat].srh_c[t+1][x][trap];
	c11=in->dosn[mat].srh_c[t+1][x+1][trap];
	c1=c10+xr*(c11-c10);
}

c=c0+tr*(c1-c0);
ret=c;

return ret;
}
Ejemplo n.º 15
0
int
ppoption(char* s)
{
	switch ((int)hashget(pp.strtab, s))
	{
	case X_ALLMULTIPLE:
		return pp.mode & ALLMULTIPLE;
	case X_BUILTIN:
		return pp.mode & BUILTIN;
	case X_CATLITERAL:
		return pp.mode & CATLITERAL;
	case X_COMPATIBILITY:
		return pp.state & COMPATIBILITY;
	case X_DEBUG:
		return -error_info.trace;
	case X_ELSEIF:
		return pp.option & ELSEIF;
	case X_FINAL:
		return pp.option & FINAL;
	case X_HOSTDIR:
		return pp.mode & HOSTED;
	case X_HOSTED:
		return pp.flags & PP_hosted;
	case X_INITIAL:
		return pp.option & INITIAL;
	case X_KEYARGS:
		return pp.option & KEYARGS;
	case X_LINEBASE:
		return pp.flags & PP_linebase;
	case X_LINEFILE:
		return pp.flags & PP_linefile;
	case X_LINETYPE:
		return pp.flags & PP_linetype;
	case X_PLUSCOMMENT:
		return pp.option & PLUSCOMMENT;
	case X_PLUSPLUS:
		return pp.option & PLUSPLUS;
	case X_PLUSSPLICE:
		return pp.option & PLUSSPLICE;
	case X_PRAGMAEXPAND:
		return pp.option & PRAGMAEXPAND;
	case X_PREDEFINED:
		return pp.option & PREDEFINED;
	case X_PREFIX:
		return pp.option & PREFIX;
	case X_PROTOTYPED:
		return pp.option & PROTOTYPED;
	case X_READONLY:
		return pp.mode & READONLY;
	case X_REGUARD:
		return pp.option & REGUARD;
	case X_SPACEOUT:
		return pp.state & SPACEOUT;
	case X_SPLICECAT:
		return pp.option & SPLICECAT;
	case X_SPLICESPACE:
		return pp.option & SPLICESPACE;
	case X_STRICT:
		return pp.state & STRICT;
	case X_STRINGSPAN:
		return pp.option & STRINGSPAN;
	case X_STRINGSPLIT:
		return pp.option & STRINGSPLIT;
	case X_TEST:
		return pp.test;
	case X_TEXT:
		return !(pp.state & NOTEXT);
	case X_TRANSITION:
		return pp.state & TRANSITION;
	case X_TRUNCATE:
		return pp.truncate;
	case X_WARN:
		return pp.state & WARN;
	default:
		if (pp.state & WARN) error(1, "%s: unknown option name", s);
		return 0;
	}
}
Ejemplo n.º 16
0
static int
predicate(int warn)
{
	register char*			args;
	register struct pplist*		p;
	register struct ppsymbol*	sym;
	register int			type;
	int				index;

	static char			pred[MAXID + 1];

	/*
	 * first gather the args
	 */

	index = (int)hashref(pp.strtab, pp.token);
	if (warn && peekchr() != '(') switch (index)
	{
	case X_DEFINED:
	case X_EXISTS:
	case X_INCLUDED:
	case X_MATCH:
	case X_NOTICED:
	case X_OPTION:
	case X_SIZEOF:
	case X_STRCMP:
		break;
	default:
		if (pp.macref) pprefmac(pp.token, REF_IF);
		return 0;
	}
	strcpy(pred, pp.token);
	pp.state |= DISABLE;
	type = pppredargs();
	pp.state &= ~DISABLE;
	switch (type)
	{
	case T_ID:
	case T_STRING:
		break;
	default:
		unlex(type);
		/*FALLTHROUGH*/
	case 0:
		if (index && !(pp.state & STRICT))
			error(1, "%s: predicate argument expected", pred);
		if (pp.macref) pprefmac(pred, REF_IF);
		return 0;
	}
	args = pp.args;

	/*
	 * now evaluate
	 */

	debug((-6, "pred=%s args=%s", pred, args));
	if ((pp.state & STRICT) && !(pp.mode & HOSTED)) switch (index)
	{
	case X_DEFINED:
	case X_SIZEOF:
		break;
	default:
		error(1, "%s(%s): non-standard predicate test", pred, args);
		return 0;
	}
	switch (index)
	{
	case X_DEFINED:
		if (type != T_ID) error(1, "%s: identifier argument expected", pred);
		else if ((sym = pprefmac(args, REF_IF)) && sym->macro) return 1;
		else if (args[0] == '_' && args[1] == '_' && !strncmp(args, "__STDPP__", 9))
		{
			if (pp.hosted == 1 && pp.in->prev->type == IN_FILE)
			{
				pp.mode |= HOSTED;
				pp.flags |= PP_hosted;
			}
			return *(args + 9) ? (int)hashref(pp.strtab, args + 9) : 1;
		}
		break;
	case X_EXISTS:
	case X_INCLUDED:
		return exists(index, pred, args);
	case X_MATCH:
	case X_STRCMP:
		return compare(pred, args, index == X_MATCH);
	case X_NOTICED:
		if (type != T_ID) error(1, "%s: identifier argument expected", pred);
		else if (((sym = pprefmac(args, REF_IF)) || (sym = ppsymref(pp.symtab, args))) && (sym->flags & SYM_NOTICED)) return 1;
		break;
	case X_OPTION:
		return ppoption(args);
	case X_SIZEOF:
		error(2, "%s invalid in #%s expressions", pred, dirname(IF));
		break;
	default:
		if (warn && !(pp.mode & HOSTED) && (sym = ppsymref(pp.symtab, pred)) && (sym->flags & SYM_PREDICATE))
			error(1, "use #%s(%s) to disambiguate", pred, args);
		if (p = (struct pplist*)hashget(pp.prdtab, pred))
		{
			if (!*args) return 1;
			while (p)
			{
				if (streq(p->value, args)) return 1;
				p = p->next;
			}
		}
		break;
	}
	return 0;
}